Skip to content

Commit

Permalink
gha: pack linux libs into macos universal package
Browse files Browse the repository at this point in the history
And add corresponding config sections.

This enables prebuilt OS X compiler to be useful for local agent build.
  • Loading branch information
yanok committed Jan 20, 2025
1 parent ccc5706 commit 1a4f0b0
Showing 1 changed file with 45 additions and 9 deletions.
54 changes: 45 additions & 9 deletions .github/actions/merge-macos/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,47 @@ name: Merge x86_64 & arm64 packages to universal one
runs:
using: composite
steps:

- name: Download x86_64 artifact
- name: Download OSX x86_64 artifact
uses: actions/download-artifact@v4
with:
name: osx-x86_64
path: artifacts/
- name: Download arm64 artifact
- name: Download OSX arm64 artifact
uses: actions/download-artifact@v4
with:
name: osx-arm64
path: artifacts/
- name: Download Linux x86_64 artifact
uses: actions/download-artifact@v4
with:
name: linux-x86_64
path: artifacts/

- name: Extract & merge artifacts
shell: bash
run: |
set -euxo pipefail
mkdir ldc2-{x86_64,arm64}
tar -xf artifacts/ldc2-*-x86_64.tar.xz --strip 1 -C ldc2-x86_64
tar -xf artifacts/ldc2-*-arm64.tar.xz --strip 1 -C ldc2-arm64
mkdir ldc2-osx-{x86_64,arm64}
mkdir ldc2-linux-x86_64
tar -xf artifacts/ldc2-*-osx-x86_64.tar.xz --strip 1 -C ldc2-osx-x86_64
tar -xf artifacts/ldc2-*-osx-arm64.tar.xz --strip 1 -C ldc2-osx-arm64
tar -xf artifacts/ldc2-*-linux-x86_64.tar.xz --strip 1 -C ldc2-linux-x86_64
cp -R ldc2-x86_64 ldc2-universal
cp -R ldc2-osx-x86_64 ldc2-universal
cd ldc2-universal
# rename/copy lib dirs
mv lib lib-x86_64
cp -R ../ldc2-arm64/lib lib-arm64
cp -R ../ldc2-osx-arm64/lib lib-arm64
# cp -R ../ldc2-arm64/lib-ios-arm64 ./
cp -R ../ldc2-linux-x86_64/lib lib-linux-x86_64
cp -R ../ldc2-linux-x86_64/lib-aarch64 lib-linux-arm64
# merge executables to universal ones
for exe in bin/*; do
rm $exe
lipo -create -output $exe ../ldc2-x86_64/$exe ../ldc2-arm64/$exe
lipo -create -output $exe ../ldc2-osx-x86_64/$exe ../ldc2-osx-arm64/$exe
done
# ios_triple_suffix=$(grep -o -E '\-apple-ios[0-9\.]+' etc/ldc2.conf | head -n1)
Expand Down Expand Up @@ -83,6 +91,34 @@ runs:
\"%%ldcbinarypath%%/../lib-arm64\",
];
rpath = \"%%ldcbinarypath%%/../lib-arm64\";
};
\"(aarch64\\|arm64).\\*-linux-gnu\":
{
switches = [
\"-defaultlib=phobos2-ldc,druntime-ldc\",
\"--mcpu=neoverse-n1\",
\"-mattr=+crc\",
\"-gcc=aarch64-linux-gnu-gcc\",
\"-linker=gold\",
];
lib-dirs = [
\"%%ldcbinarypath%%/../lib-linux-arm64\",
];
rpath = \"%%ldcbinarypath%%/../lib-linux-arm64\";
};
\"(x86_64\\|amd64).\\*-linux-gnu\":
{
switches = [
\"-defaultlib=phobos2-ldc,druntime-ldc\",
\"-gcc=x86_64-linux-gnu-gcc\",
\"-linker=gold\",
];
lib-dirs = [
\"%%ldcbinarypath%%/../lib-linux-x86_64\",
];
rpath = \"%%ldcbinarypath%%/../lib-linux-x86_64\";
};"
perl -0777 -pi -e "s|\\ndefault:\\n.+?\\n\\};|$sections|s" etc/ldc2.conf
Expand Down

0 comments on commit 1a4f0b0

Please sign in to comment.