Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support linux build #10

Merged
merged 5 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
- main

jobs:
build:
build-macos:
runs-on: macos-latest
steps:
- uses: extractions/setup-just@v2
Expand Down Expand Up @@ -42,3 +42,36 @@ jobs:
name: macos-aarch64-binary
path: raylean_macos-aarch64.tar.gz
if-no-files-found: error

build-linux:
runs-on: ubuntu-latest
steps:
- uses: extractions/setup-just@v2

- name: Setup Rust
run: rustup toolchain install stable --profile minimal

- name: Install raylib deps
run: sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev libwayland-dev libxkbcommon-dev

- name: install elan
run: |
set -o pipefail
curl -sSfL https://github.com/leanprover/elan/releases/download/v3.1.1/elan-x86_64-unknown-linux-gnu.tar.gz | tar xz
./elan-init -y --no-modify-path --default-toolchain none
echo "$HOME/.elan/bin" >> $GITHUB_PATH

- uses: actions/checkout@v4

- name: build project
run: just build

- name: create release tarball
run: |
tar zcf raylean_linux-x86_64.tar.gz -C .lake/build/bin raylean

- uses: actions/upload-artifact@v4
with:
name: linux_x86_64-binary
path: raylean_linux-x86_64.tar.gz
if-no-files-found: error
38 changes: 25 additions & 13 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,31 @@ disableBundle := ''
# Flags used to configure the lake build
lake_config_opts := if disableBundle == "" { "-K bundle=on" } else { "" }

# Raylib CUSTOM_FLAGS tailed for the current os
#
# The macos differ from the raylib release workflow.
# We require `-fno-objc-msgsend-selector-stubs` to be set.
#
# If this is not set then the clang 15 linker bundled with lean gives the
# following error:
#
# ld64.lld: error: undefined symbol: _objc_msgSend$update
#
# See https://stackoverflow.com/a/74054943
#
raylib_os_custom_cflags := if os() == "macos" { "-target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION -fno-objc-msgsend-selector-stubs" } else { "" }

# Enable extra raylib configuration flags
raylib_config_flags := ""

# Raylib CUSTOM_CFLAGS make parameter
raylib_custom_cflags := raylib_config_flags + " " + raylib_os_custom_cflags

# Raylib CC make paramter
raylib_cc_parameter := if os() == "macos" { "/usr/bin/clang" } else { "gcc" }

static_lib_path := join(justfile_directory(), "lib")
raylib_src_path := join(justfile_directory(), "raylib-5.0", "src")
extra_raylib_config_flags := ""
resource_dir := join(justfile_directory(), "resources")
bundle_h_path := join(justfile_directory(), "c", "include", "bundle.h")
makebundle_src_path := join(justfile_directory(), "scripts", "makeBundle.lean")
Expand Down Expand Up @@ -44,22 +66,12 @@ build_raylib:
set -euo pipefail
if [ ! -f "{{static_lib_path}}/libraylib.a" ]; then
mkdir -p {{static_lib_path}}
# This build differs from the raylib release workflow.
# We require `-fno-objc-msgsend-selector-stubs` to be set.
#
# If this is not set then the clang 15 linker bundled with lean gives the
# following error:
#
# ld64.lld: error: undefined symbol: _objc_msgSend$update
#
# See https://stackoverflow.com/a/74054943
#
make -C {{raylib_src_path}} \
CC=/usr/bin/clang \
CC={{raylib_cc_parameter}} \
PLATFORM=PLATFORM_DESKTOP \
RAYLIB_LIBTYPE=STATIC \
RAYLIB_RELEASE_PATH={{static_lib_path}} \
CUSTOM_CFLAGS="{{extra_raylib_config_flags}} -target arm64-apple-macos11 -DGL_SILENCE_DEPRECATION -fno-objc-msgsend-selector-stubs"
CUSTOM_CFLAGS="{{raylib_custom_cflags}}"
fi

# build both the raylib library and the Lake project
Expand Down
18 changes: 10 additions & 8 deletions lakefile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ lean_lib «Lens»
@[default_target]
lean_exe «raylean» where
root := `Main
moreLinkArgs :=
#[ "lib/libraylib.a"
, "lib/libresvg.a"
, "-isysroot", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
, "-framework", "IOKit"
, "-framework", "Cocoa"
, "-framework", "OpenGL"
]
moreLinkArgs := Id.run do
let mut args := #[ "lib/libraylib.a" , "lib/libresvg.a"]
if (← System.Platform.isOSX) then
args := args ++
#[ "-isysroot", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
, "-framework", "IOKit"
, "-framework", "Cocoa"
, "-framework", "OpenGL"
]
args

target raylib_bindings.o pkg : FilePath := do
let oFile := pkg.buildDir / "c" / "raylib_bindings.o"
Expand Down