diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2026-03-02 18:31:39 +0100 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2026-03-02 18:31:39 +0100 |
| commit | 651c32bad4f336eee9cf423eec5f7b1057a58adf (patch) | |
| tree | 7d265138d8048027044fdc45fedc52a298e79049 /lakefile.lean | |
| parent | 44796b1b1493a67dcdfec8f9846dce14e7ecf4a4 (diff) | |
build: link against libwayland
Diffstat (limited to 'lakefile.lean')
| -rw-r--r-- | lakefile.lean | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lakefile.lean b/lakefile.lean index ef12dad..ecee22d 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -2,17 +2,24 @@ import Lean import Lake open Lake DSL +def evalPkgConfig (args : Array String) : IO (Array String) := do + let res ← IO.Process.output { cmd := "pkg-config", args := args } + if res.exitCode != 0 then + throw <| IO.userError s!"pkg-config failed: {res.stderr}" + return res.stdout.split Char.isWhitespace + |>.map (String.Slice.toString) + |>.filter (· != "") + |>.toArray + package «CWayland» { - moreLinkArgs := #["-L.lake/build/lib", "-lLibCWayland"] + moreLinkArgs := #["-L.lake/build/lib", "-lLibCWayland"] ++ (run_io evalPkgConfig #["--libs", "wayland-client"]).filter (· != "-lm") extraDepTargets := #[Lean.Name.mkStr1 "LibCWayland"] } target «LibCWayland.o» pkg : System.FilePath := do let objectFile := pkg.buildDir / "LibCWayland.o" let srcJob ← inputFile (text := .true) <| pkg.dir / "lib" / "CWayland" / "CWayland.c" - -- let cFlags ← captureProc { cmd := "pkg-config", args := #["--cflags", "libwayland-client"] } - -- let cFlags := cFlags.splitOn " " - let cFlags := #[] + let cFlags ← evalPkgConfig #["--cflags", "wayland-client"] buildFileAfterDep objectFile srcJob (fun srcFile ↦ do let cFlags := cFlags ++ #["-I", (← getLeanIncludeDir).toString, "-I", (← IO.getEnv "C_INCLUDE_PATH").getD "", "-fPIC"] compileO objectFile srcFile cFlags) |
