-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathlakefile.lean
More file actions
65 lines (53 loc) · 1.9 KB
/
lakefile.lean
File metadata and controls
65 lines (53 loc) · 1.9 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
/-
Copyright © 2023-2026 François G. Dorais. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
-/
import Lake
open System Lake DSL
package UnicodeBasic where
description := "Basic Unicode support for Lean 4"
keywords := #["unicode"]
reservoir := true
precompileModules := true
target UnicodeCLib pkg : FilePath := do
let mut oFiles : Array (Job FilePath) := #[]
for file in (← (pkg.dir / "UnicodeCLib").readDir) do
if file.path.extension == some "c" then
let obj := pkg.buildDir / "UnicodeCLib" / ((file.fileName.dropSuffix ".c" |>.copy) ++ ".o")
let src ← inputTextFile file.path
let weakArgs := #["-I", (← getLeanIncludeDir).toString, "-I", (pkg.dir / "UnicodeCLib").toString, "-O", "-fPIC"]
oFiles := oFiles.push <| ← buildO obj src weakArgs
let name := nameToStaticLib "unicodeclib"
buildStaticLib (pkg.sharedLibDir / name) oFiles
-- temporary fix for Windows
meta if System.Platform.isWindows then
extern_lib libunicodeclib := UnicodeCLib.fetch
@[default_target]
lean_lib UnicodeBasic where
moreLinkObjs := #[UnicodeCLib]
lean_lib UnicodeData
lean_exe lookup
lean_exe makeTables
lean_exe makeCLib
@[test_driver]
lean_exe testTables
/-- Download datafile from the Unicode Character Database (UCD) -/
script downloadUCD (args) do
let dir : System.FilePath := "./data"
let url := "https://www.unicode.org/Public/UCD/latest/ucd/"
let mut err : ExitCode := 0
for file in args do
IO.print s!"Downloading UCD/{file} ... "
match ← download (url ++ file) (dir/file) |>.run with
| .ok _ _ => IO.println "Done."
| .error _ _ => IO.println "Failed!"; err := err + 1
return err
/-- Update data files from the Unicode Character Database (UCD) -/
script updateUCD do downloadUCD [
"ReadMe.txt",
"UnicodeData.txt",
"PropList.txt",
"PropertyAliases.txt",
"PropertyValueAliases.txt",
"Scripts.txt",
]