1+ name : " Setup osxcross"
2+ author : mbround18
3+ description : Setup osxcross for rust/other compilation projects.
4+ branding :
5+ icon : ' aperture'
6+ color : ' green'
7+
8+
9+ inputs :
10+ osx-version :
11+ description : " Version of osx to use."
12+ required : true
13+
14+ outputs :
15+ legacy-ssl :
16+ value : ${{steps.gen_configs.outputs.legacy-ssl}}
17+ meson-osxcross :
18+ value : ${{steps.gen_configs.outputs.meson-osxcross}}
19+
20+ runs :
21+ using : " composite"
22+ steps :
23+ - shell : bash
24+ run : |
25+ mkdir -p $GITHUB_ACTION_PATH/osxcross
26+ echo "OSXCROSS_FOLDER=$(echo "$GITHUB_ACTION_PATH/osxcross" | sed 's/\.\/*//g')" >> $GITHUB_ENV
27+
28+
29+ - uses : actions/checkout@v4
30+ with :
31+ repository : tpoechtrager/osxcross
32+ path : ${{env.OSXCROSS_FOLDER}}
33+
34+ - shell : bash
35+ id : target
36+ run : |
37+ repeat(){
38+ for i in {1..90}; do echo -n "$1"; done
39+ }
40+
41+ echo "::group::Disclaimer Click Here for Info"
42+ echo ""
43+ repeat "-"
44+ echo ""
45+ echo "The first time you run this it will take upwards of 9 minutes to compile. Subsequent builds are cached."
46+ echo ""
47+ repeat "-"
48+ echo ""
49+ echo "::endgroup::"
50+
51+
52+ echo "::group::Installing Deps"
53+
54+ sudo apt-get update
55+ sudo apt-get install --no-install-recommends -y -qq clang gcc g++ zlib1g-dev libmpc-dev libmpfr-dev libgmp-dev cmake libxml2-dev libssl-dev xz-utils
56+ echo "::endgroup::"
57+
58+ # Check setup for osx version
59+ echo "::group::Fetching macosx SDK"
60+ FILE_NAME="MacOSX${{ inputs.osx-version }}.sdk.tar.xz"
61+
62+ # Check joseluisq/macosx-sdks for release
63+ wget -nc "https://github.com/joseluisq/macosx-sdks/releases/download/${{ inputs.osx-version }}/${FILE_NAME}" -O "$OSXCROSS_FOLDER/tarballs/${FILE_NAME}"
64+ echo "::endgroup::"
65+
66+ echo "OSXCROSS_TARGET=${OSXCROSS_FOLDER}/target" >> $GITHUB_ENV
67+
68+ - uses : actions/cache@v4
69+ id : cache
70+ with :
71+ key : ${{ runner.os }}-osxcross-${{ inputs.osx-version }}
72+ path : |
73+ ${{ env.OSXCROSS_TARGET }}
74+
75+
76+ - shell : bash
77+ if : steps.cache.outputs.cache-hit != 'true'
78+ env :
79+ SDK_VERSION : " ${{ inputs.osx-version }}"
80+ UNATTENDED : " yes"
81+ run : |
82+ cd ${OSXCROSS_FOLDER}
83+ echo "::group::Build osxcross"
84+ ./build.sh
85+ echo "::endgroup::"
86+ echo "::group::Build GCC"
87+ ./build_gcc.sh
88+ echo "::endgroup::"
89+
90+ - shell : bash
91+ id : gen_configs
92+ run : |
93+ echo "::group::Setting up Bin files"
94+ OSXCROSS_FOLDER="$(echo "${GITHUB_ACTION_PATH}/osxcross" | sed 's/\.\/*//g')"
95+ echo "OSXCROSS Folder = ${OSXCROSS_FOLDER}"
96+
97+ if [ ! -d "$OSXCROSS_FOLDER/target/bin" ]; then
98+ echo "Error! Failed to find ${OSXCROSS_FOLDER}/target/bin folder!"
99+ exit 1
100+ else
101+ if hash sudo 2>/dev/null; then
102+ sudo chmod +x $OSXCROSS_FOLDER/target/bin/*
103+ else
104+ chmod +x $OSXCROSS_FOLDER/target/bin/*
105+ fi
106+ fi
107+ echo "::endgroup::"
108+
109+ echo "::group::Finding Arch Name"
110+ echo "$OSXCROSS_FOLDER/target/bin" >> $GITHUB_PATH
111+ ARCH_TARGET="$(ls $OSXCROSS_FOLDER/target | grep apple)"
112+ echo "::endgroup::"
113+
114+ ln -sf ${ARCH_TARGET}-otool ${OSXCROSS_TARGET}/bin/otool
115+ ln -sf ${ARCH_TARGET}-install_name_tool ${OSXCROSS_TARGET}/bin/install_name_tool
116+
117+ echo "::group::Write meson cross file"
118+ cat << EOF > $OSXCROSS_FOLDER/meson_osxcross.txt
119+ [constants]
120+ arch = '${ARCH_TARGET}'
121+ [binaries]
122+ c = ['ccache', arch + '-gcc']
123+ cpp = ['ccache', arch + '-g++']
124+ strip = arch + '-strip'
125+ pkg-config = arch + '-pkg-config'
126+ ranlib = arch + '-gcc-ranlib'
127+ ar = arch + '-gcc-ar'
128+
129+ [host_machine]
130+ system = 'darwin'
131+ cpu_family = 'x86_64'
132+ cpu = 'x86_64'
133+ endian = 'little'
134+ EOF
135+ echo "::endgroup::"
136+
137+ echo "meson-osxcross=${OSXCROSS_FOLDER}/meson_osxcross.txt" >> $GITHUB_OUTPUT
138+
139+ - shell : bash
140+ run : |
141+ OUT=$(patch -N -i ${GITHUB_ACTION_PATH}/macports.patch ${OSXCROSS_FOLDER}/target/bin/osxcross-macports) || echo "${OUT}" | grep "Skipping patch" -q || (echo "$OUT" && false);
142+
143+ - uses : actions/checkout@v4
144+ with :
145+ repository : auriamg/macdylibbundler
146+ path : ${{env.OSXCROSS_FOLDER}}/dylibbundler
147+
148+ - shell : bash
149+ run : |
150+ echo "::group::Install dylibbundler"
151+ cd ${OSXCROSS_FOLDER}/dylibbundler
152+ make
153+ echo "${OSXCROSS_FOLDER}/dylibbundler" >> $GITHUB_PATH
154+ echo "::endgroup::"
0 commit comments