-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlakefile.lean
More file actions
251 lines (218 loc) · 11.6 KB
/
lakefile.lean
File metadata and controls
251 lines (218 loc) · 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
import Lake
open System Lake DSL
-- Link arguments (pure C, no C++ dependencies)
package arrowLean where
extraDepTargets := #[`libarrow_wrapper]
moreLinkArgs := #[
"-L/usr/local/lib",
"-Wl,-rpath,/usr/local/lib",
"-Wl,--allow-shlib-undefined",
"-lzlog",
"-lzstd"
]
@[default_target]
lean_lib ArrowLean
lean_lib Examples where
globs := #[.submodules `Examples]
target arrow_schema_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "arrow_schema.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "arrow_schema.c") flags
return .pure oFile
target arrow_array_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "arrow_array.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "arrow_array.c") flags
return .pure oFile
target arrow_stream_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "arrow_stream.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "arrow_stream.c") flags
return .pure oFile
target arrow_data_access_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "arrow_data_access.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "arrow_data_access.c") flags
return .pure oFile
target arrow_buffer_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "arrow_buffer.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "arrow_buffer.c") flags
return .pure oFile
target lean_arrow_wrapper_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "lean_arrow_wrapper.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "lean_arrow_wrapper.c") flags
return .pure oFile
target lean_arrow_finalizers_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "lean_arrow_finalizers.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "lean_arrow_finalizers.c") flags
return .pure oFile
target lean_parquet_wrapper_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "lean_parquet_wrapper.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "lean_parquet_wrapper.c") flags
return .pure oFile
target parquet_reader_writer_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "parquet_reader_writer.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "parquet_reader_writer.c") flags
return .pure oFile
-- Pure C Parquet writer implementation (Thrift serialization, data pages, footer)
target parquet_writer_impl_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "parquet_writer_impl.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "parquet_writer_impl.c") flags
return .pure oFile
-- Pure C Parquet reader implementation (Thrift decoding, page reading)
target parquet_reader_impl_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "parquet_reader_impl.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "parquet_reader_impl.c") flags
return .pure oFile
target arrow_ipc_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "arrow_ipc.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "arrow_ipc.c") flags
return .pure oFile
target lean_arrow_ipc_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "lean_arrow_ipc.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "lean_arrow_ipc.c") flags
return .pure oFile
-- Typed column builders for direct Arrow array construction (pure C)
target arrow_builders_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "arrow_builders.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "arrow_builders.c") flags
return .pure oFile
-- Lean FFI wrappers for typed builders (pure C)
target lean_builder_wrapper_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "lean_builder_wrapper.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "lean_builder_wrapper.c") flags
return .pure oFile
-- Nested type builders (List, Struct, Decimal128, Dictionary, Map)
target arrow_nested_builders_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "arrow_nested_builders.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "arrow_nested_builders.c") flags
return .pure oFile
-- Arrow compute functions (arithmetic, comparisons, aggregations)
target arrow_compute_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "arrow_compute.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "arrow_compute.c") flags
return .pure oFile
-- Lean FFI wrappers for Arrow compute functions
target lean_arrow_compute_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "lean_arrow_compute.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "lean_arrow_compute.c") flags
return .pure oFile
-- ChunkedArray and Table implementation
target arrow_chunked_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "arrow_chunked.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "arrow_chunked.c") flags
return .pure oFile
-- Lean FFI wrappers for ChunkedArray and Table
target lean_arrow_chunked_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "lean_arrow_chunked.o"
IO.FS.createDirAll oFile.parent.get!
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "arrow").toString]
compileO oFile (pkg.dir / "arrow" / "lean_arrow_chunked.c") flags
return .pure oFile
-- Stub for CSV/Parquet functions (C++ dependency removed)
-- Use the new typed builders + IPC for data serialization instead
target csv_parquet_stub_o pkg : FilePath := do
let oFile := pkg.buildDir / "arrow" / "csv_parquet_stub.o"
IO.FS.createDirAll oFile.parent.get!
let stubSrc := pkg.buildDir / "arrow" / "csv_parquet_stub.c"
IO.FS.writeFile stubSrc "
#include <lean/lean.h>
// CSV to Parquet functionality has been replaced with typed builders
// Use ArrowLean.TypedBuilders and ArrowLean.ToArrow for direct Arrow construction
// Use ArrowLean.IPC for serialization (pure C implementation)
LEAN_EXPORT lean_obj_res lean_csv_to_parquet(b_lean_obj_arg csv, b_lean_obj_arg path, b_lean_obj_arg comp, lean_obj_arg w) {
lean_object* except = lean_alloc_ctor(0, 1, 0);
lean_ctor_set(except, 0, lean_mk_string(\"CSV to Parquet via C++ removed. Use TypedBuilders + IPC instead.\"));
return lean_io_result_mk_ok(except);
}
LEAN_EXPORT lean_obj_res lean_merge_csv_to_parquet(b_lean_obj_arg csvs, b_lean_obj_arg path, b_lean_obj_arg comp, lean_obj_arg w) {
lean_object* except = lean_alloc_ctor(0, 1, 0);
lean_ctor_set(except, 0, lean_mk_string(\"CSV to Parquet via C++ removed. Use TypedBuilders + IPC instead.\"));
return lean_io_result_mk_ok(except);
}
LEAN_EXPORT lean_obj_res lean_arrow_parquet_available(lean_obj_arg w) {
// Return false - C++ Parquet support removed
return lean_io_result_mk_ok(lean_box(0));
}
LEAN_EXPORT lean_obj_res lean_arrow_version(lean_obj_arg w) {
return lean_io_result_mk_ok(lean_mk_string(\"pure-c-1.0.0\"));
}
"
let flags := #["-fPIC", "-O2", "-std=c99", "-I", (← getLeanIncludeDir).toString]
compileO oFile stubSrc flags
return .pure oFile
extern_lib libarrow_wrapper pkg := do
-- Core Arrow C implementation
let schemaObj ← arrow_schema_o.fetch
let arrayObj ← arrow_array_o.fetch
let streamObj ← arrow_stream_o.fetch
let dataAccessObj ← arrow_data_access_o.fetch
let bufferObj ← arrow_buffer_o.fetch
let wrapperObj ← lean_arrow_wrapper_o.fetch
let finalizersObj ← lean_arrow_finalizers_o.fetch
-- Pure C Parquet implementation
let parquetWrapperObj ← lean_parquet_wrapper_o.fetch
let parquetReaderWriterObj ← parquet_reader_writer_o.fetch
let parquetWriterImplObj ← parquet_writer_impl_o.fetch
let parquetReaderImplObj ← parquet_reader_impl_o.fetch
-- IPC serialization (pure C)
let ipcObj ← arrow_ipc_o.fetch
let ipcWrapperObj ← lean_arrow_ipc_o.fetch
-- Typed builders for direct Arrow array construction (pure C)
let buildersObj ← arrow_builders_o.fetch
let builderWrapperObj ← lean_builder_wrapper_o.fetch
-- Nested type builders (List, Struct, Decimal128, Dictionary, Map)
let nestedBuildersObj ← arrow_nested_builders_o.fetch
-- Arrow compute functions (arithmetic, comparisons, aggregations)
let computeObj ← arrow_compute_o.fetch
let computeWrapperObj ← lean_arrow_compute_o.fetch
-- ChunkedArray and Table
let chunkedObj ← arrow_chunked_o.fetch
let chunkedWrapperObj ← lean_arrow_chunked_o.fetch
-- CSV/Parquet stub (no C++ dependencies)
let csvParquetStubObj ← csv_parquet_stub_o.fetch
buildStaticLib (pkg.staticLibDir / nameToStaticLib "arrow_wrapper")
#[schemaObj, arrayObj, streamObj, dataAccessObj, bufferObj, wrapperObj, finalizersObj,
parquetWrapperObj, parquetReaderWriterObj, parquetWriterImplObj, parquetReaderImplObj,
ipcObj, ipcWrapperObj, buildersObj, builderWrapperObj, nestedBuildersObj, computeObj, computeWrapperObj,
chunkedObj, chunkedWrapperObj, csvParquetStubObj]
require Cli from git
"https://github.com/leanprover/lean4-cli.git" @ "v4.27.0"
require zlogLean from git
"git@github.com:marcellop71/zlog-lean.git" @ "main"
lean_exe examples where
root := `Examples.Main