Skip to content

Commit

Permalink
disable FFI use
Browse files Browse the repository at this point in the history
  • Loading branch information
joneugster committed Jun 20, 2024
1 parent e493a4f commit a761839
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
24 changes: 14 additions & 10 deletions lakefile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ lean_lib Time where
srcDir := "." / "time"
precompileModules := true

target time.o pkg : FilePath := do
let oFile := pkg.buildDir / "c" / "time.o"
let srcJob ← inputFile <| pkg.dir / "time" / "c" / "time.cpp"
let weakArgs := #["-I", (← getLeanIncludeDir).toString]
buildO oFile srcJob weakArgs #["-fPIC"] "c++" getLeanTrace

extern_lib libLeanTime pkg := do
let name := nameToStaticLib "leanTime"
let timeO ← fetch <| pkg.target ``time.o
buildStaticLib (pkg.nativeLibDir / name) #[timeO]
/-
TODO: If the user does not have `c++` available this makes the package
and all dependencies unusable. Reactivate if there is a better solution
-/
-- target time.o pkg : FilePath := do
-- let oFile := pkg.buildDir / "c" / "time.o"
-- let srcJob ← inputFile <| pkg.dir / "time" / "c" / "time.cpp"
-- let weakArgs := #["-I", (← getLeanIncludeDir).toString]
-- buildO oFile srcJob weakArgs #["-fPIC"] "c++" getLeanTrace

-- extern_lib libLeanTime pkg := do
-- let name := nameToStaticLib "leanTime"
-- let timeO ← fetch <| pkg.target ``time.o
-- buildStaticLib (pkg.nativeLibDir / name) #[timeO]
13 changes: 13 additions & 0 deletions test/Test.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import I18n

-- set_language de

def hello := t!"hello world"

def hello2 := t!"Test \n"

#eval hello
#eval hello2


#export_i18n
11 changes: 8 additions & 3 deletions time/Time/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import Lean

namespace Time

/-- Returns the local date/time as a string. -/
@[extern "formatLocalTime"]
opaque getLocalTime : IO String
/-
TODO: see comment in lakefile about `c++`.
-/
-- /-- Returns the local date/time as a string. -/
-- @[extern "formatLocalTime"]
-- opaque getLocalTime : IO String

/-- Dummy implementation because FFI does not work for everybody. TODO: fix me. -/
def getLocalTime : IO String := do return ""

0 comments on commit a761839

Please sign in to comment.