Skip to content

Commit

Permalink
Enable build
Browse files Browse the repository at this point in the history
  • Loading branch information
joehendrix committed Oct 23, 2023
1 parent bb238a1 commit f7a5882
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on: [push, pull_request]

name: ci

jobs:
build:
name: Build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ubuntu-latest
steps:
- name: install elan
run: |
set -o pipefail
curl -sSfL https://github.com/leanprover/elan/releases/download/v1.4.2/elan-x86_64-unknown-linux-gnu.tar.gz | tar xz
./elan-init -y --default-toolchain none
echo "$HOME/.elan/bin" >> $GITHUB_PATH
- uses: actions/checkout@v4
- name: Install libuv (ubuntu)
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libuv1-dev clang
sudo update-alternatives --set cc /usr/bin/clang
if: matrix.os == 'ubuntu-latest'
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
if: matrix.os == 'macos-latest'
- name: Install libuv (osx)
run: brew install libuv pkg-config
if: matrix.os == 'macos-latest'
- name: Lake build
run: |
which cc
ls -l $(which cc)
lake build --verbose
File renamed without changes.
File renamed without changes.
30 changes: 22 additions & 8 deletions lakefile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,28 @@ package LibUV where

module_data alloy.c.o : BuildJob FilePath

def flushError (msg : String) : IO Unit := do
let stderr ← IO.getStdout
stderr.putStr msg
stderr.flush


def fatalError (msg : String) (u : UInt8) : IO α := do
flushError msg
IO.Process.exit u

def runPkgConfig (args : Array String) : IO (Array String) := do
let out ← IO.Process.output { cmd := "pkg-config", args }
if out.exitCode ≠ 0 then
let stderr ← IO.getStderr
stderr.putStr s!"Cannot run pkg-config"
stderr.flush
IO.Process.exit 1
return out.stdout.splitOn.toArray.map String.trimRight
let mout ← (Option.some <$> (IO.Process.output { cmd := "pkg-config", args })).tryCatch (fun _ => pure none)
match mout with
| Option.none =>
flushError "Cannot run pkg-config"
pure #[]
| Option.some out =>
if out.exitCode = 0 then
return out.stdout.splitOn.toArray.map String.trimRight
else
flushError "pkg-config failed"
pure #[]

def pkgConfigCFlags (lib : String) : IO (Array String) := runPkgConfig #["--cflags", lib]
def pkgConfigLibs (lib : String) : IO (Array String) := runPkgConfig #["--libs", lib]
Expand All @@ -24,5 +38,5 @@ def pkgConfigLibs (lib : String) : IO (Array String) := runPkgConfig #["--libs",
lean_lib LibUV where
precompileModules := true
nativeFacets := #[Module.oFacet, `alloy.c.o]
moreLeancArgs := run_io (pkgConfigCFlags "libuv")
moreLeancArgs := #["-fPIC"] ++ run_io (pkgConfigCFlags "libuv")
moreLinkArgs := run_io (pkgConfigLibs "libuv")

0 comments on commit f7a5882

Please sign in to comment.