|
| 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 | + |
| 108 | + echo "::endgroup::" |
| 109 | +
|
| 110 | + echo "::group::Finding Arch Name" |
| 111 | + echo "$OSXCROSS_FOLDER/target/bin" >> $GITHUB_PATH |
| 112 | + ARCH_TARGET="$(ls $OSXCROSS_FOLDER/target | grep apple)" |
| 113 | + echo "::endgroup::" |
| 114 | +
|
| 115 | + echo "::group::Write meson cross file" |
| 116 | + cat << EOF > $OSXCROSS_FOLDER/meson_osxcross.txt |
| 117 | + [constants] |
| 118 | + arch = '${ARCH_TARGET}' |
| 119 | + [binaries] |
| 120 | + c = ['ccache', arch + '-gcc'] |
| 121 | + cpp = ['ccache', arch + '-g++'] |
| 122 | + strip = arch + '-strip' |
| 123 | + pkg-config = arch + '-pkg-config' |
| 124 | + ranlib = arch + '-gcc-ranlib' |
| 125 | + ar = arch + '-gcc-ar' |
| 126 | + |
| 127 | + [host_machine] |
| 128 | + system = 'darwin' |
| 129 | + cpu_family = 'x86_64' |
| 130 | + cpu = 'x86_64' |
| 131 | + endian = 'little' |
| 132 | + EOF |
| 133 | + echo "::endgroup::" |
| 134 | +
|
| 135 | + echo "meson-osxcross=${OSXCROSS_FOLDER}/meson_osxcross.txt" >> $GITHUB_OUTPUT |
| 136 | +
|
| 137 | + - shell: bash |
| 138 | + run: | |
| 139 | + patch -i ${GITHUB_ACTION_PATH}/macports.patch ${OSXCROSS_FOLDER}/target/bin/osxcross-macports |
0 commit comments