Skip to content

Commit

Permalink
Add macOS universal library build support
Browse files Browse the repository at this point in the history
  • Loading branch information
RyeMutt committed Nov 19, 2024
1 parent 8415a33 commit 6696494
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
build:
strategy:
matrix:
os: [windows-2022, macos-12, ubuntu-22.04]
os: [windows-2022, macos-15, ubuntu-22.04]
addrsize: ["64"]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -22,7 +22,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get -y install ninja-build
- uses: secondlife/action-autobuild@v4
- uses: secondlife/action-autobuild@v5
with:
addrsize: ${{ matrix.addrsize }}
release:
Expand Down
2 changes: 1 addition & 1 deletion autobuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</map>
<key>manifest</key>
<array>
<string>lib</string>
<string>lib/release/*.a</string>
</array>
<key>name</key>
<string>darwin</string>
Expand Down
83 changes: 52 additions & 31 deletions build-cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,37 +87,58 @@ pushd "$top/luau"
darwin*)
export MACOSX_DEPLOYMENT_TARGET="$LL_BUILD_DARWIN_DEPLOY_TARGET"

cmake -G Ninja -DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX:STRING="${stage}" \
-DCMAKE_CXX_FLAGS="$LL_BUILD_RELEASE" \
-DCMAKE_C_FLAGS="$(remove_cxxstd $LL_BUILD_RELEASE)" \
-DCMAKE_OSX_ARCHITECTURES="x86_64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
../luau
cmake --build . --config Release

# conditionally run unit tests
if [ "${DISABLE_UNIT_TESTS:-0}" = "0" ]; then
./Luau.UnitTest
./Luau.Conformance
./Luau.UnitTest --fflags=true
./Luau.Conformance --fflags=true
./Luau.Conformance -O2
./Luau.Conformance -O2 --fflags=true
./Luau.Conformance --codegen
./Luau.Conformance --codegen --fflags=true
./Luau.Conformance --codegen -O2
./Luau.Conformance --codegen -O2 --fflags=true
./luau ../luau/tests/conformance/assert.lua
./luau-analyze ../luau/tests/conformance/assert.lua
./luau-compile ../luau/tests/conformance/assert.lua
fi

cp -v "libLuau.Ast.a" "$stage/lib/release"
cp -v "libLuau.CodeGen.a" "$stage/lib/release"
cp -v "libLuau.Compiler.a" "$stage/lib/release"
cp -v "libLuau.Config.a" "$stage/lib/release"
cp -v "libLuau.VM.a" "$stage/lib/release"
for arch in x86_64 arm64 ; do
ARCH_ARGS="-arch $arch"
opts="${TARGET_OPTS:-$ARCH_ARGS $LL_BUILD_RELEASE}"
cc_opts="$(remove_cxxstd $opts)"
ld_opts="$ARCH_ARGS"

mkdir -p "build_$arch"
pushd "build_$arch"
CFLAGS="$cc_opts" \
CXXFLAGS="$opts" \
LDFLAGS="$ld_opts" \
cmake -G Ninja -DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX:STRING="${stage}" \
-DCMAKE_CXX_FLAGS="$opts" \
-DCMAKE_C_FLAGS="$cc_opts" \
-DCMAKE_OSX_ARCHITECTURES="$arch" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
../../luau
cmake --build . --config Release

# conditionally run unit tests
if [ "${DISABLE_UNIT_TESTS:-0}" = "0" ]; then
./Luau.UnitTest
./Luau.Conformance
./Luau.UnitTest --fflags=true
./Luau.Conformance --fflags=true
./Luau.Conformance -O2
./Luau.Conformance -O2 --fflags=true
./Luau.Conformance --codegen
./Luau.Conformance --codegen --fflags=true
./Luau.Conformance --codegen -O2
./Luau.Conformance --codegen -O2 --fflags=true
./luau ../../luau/tests/conformance/assert.lua
./luau-analyze ../../luau/tests/conformance/assert.lua
./luau-compile ../../luau/tests/conformance/assert.lua
fi

mkdir -p "$stage/lib/release/$arch"
cp -v "libLuau.Ast.a" "$stage/lib/release/$arch"
cp -v "libLuau.CodeGen.a" "$stage/lib/release/$arch"
cp -v "libLuau.Compiler.a" "$stage/lib/release/$arch"
cp -v "libLuau.Config.a" "$stage/lib/release/$arch"
cp -v "libLuau.VM.a" "$stage/lib/release/$arch"
popd
done

# Create universal libraries
lipo -create -output ${stage}/lib/release/libLuau.Ast.a ${stage}/lib/release/x86_64/libLuau.Ast.a ${stage}/lib/release/arm64/libLuau.Ast.a
lipo -create -output ${stage}/lib/release/libLuau.CodeGen.a ${stage}/lib/release/x86_64/libLuau.CodeGen.a ${stage}/lib/release/arm64/libLuau.CodeGen.a
lipo -create -output ${stage}/lib/release/libLuau.Compiler.a ${stage}/lib/release/x86_64/libLuau.Compiler.a ${stage}/lib/release/arm64/libLuau.Compiler.a
lipo -create -output ${stage}/lib/release/libLuau.Config.a ${stage}/lib/release/x86_64/libLuau.Config.a ${stage}/lib/release/arm64/libLuau.Config.a
lipo -create -output ${stage}/lib/release/libLuau.VM.a ${stage}/lib/release/x86_64/libLuau.VM.a ${stage}/lib/release/arm64/libLuau.VM.a
;;
linux64*)
cmake -G Ninja -DCMAKE_BUILD_TYPE="Release" \
Expand Down

0 comments on commit 6696494

Please sign in to comment.