Skip to content

Commit 3b526dc

Browse files
authored
Update cross compile pipeline (#140)
Update cross-compile Github action - build on Dockcross Building on Dockcross containers allows to reliably target specific architectures, most importantly linux/arm6 used by many devices, including some Raspberry Pis, such as model Zero. Fixes issue #139.
1 parent d7801d8 commit 3b526dc

File tree

3 files changed

+74
-47
lines changed

3 files changed

+74
-47
lines changed

.github/workflows/cross-compile.yml

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
create-branch:
1111
runs-on: ubuntu-20.04
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
- run: echo "precompiled_branch=$(git branch --show-current)-precompiled-natives" >> $GITHUB_ENV
1515
- name: Create branch for precompiled natives
1616
run: git checkout -b ${{ env.precompiled_branch }}
@@ -37,48 +37,56 @@ jobs:
3737
matrix:
3838
include:
3939
- target: linux_32
40-
profile: x86
41-
image: ubuntu:14.04
42-
packages: cmake3 g++-multilib
40+
os_target_name: linux
41+
os_target_arch: x86_32
42+
os_target_bitness: 32
43+
image: docker.io/dockcross/linux-x86
4344

4445
- target: linux_64
45-
profile: x86_64
46-
image: ubuntu:14.04
47-
packages: cmake3 g++
46+
os_target_name: linux
47+
os_target_arch: x86_64
48+
os_target_bitness: 64
49+
image: docker.io/dockcross/linux-x64
4850

4951
- target: linux_arm
50-
profile: armhf
51-
image: ubuntu:14.04
52-
packages: cmake3 g++-arm-linux-gnueabihf
52+
os_target_name: linux
53+
os_target_arch: arm_32
54+
os_target_bitness: 32
55+
image: docker.io/dockcross/linux-armv6-lts
5356

5457
- target: linux_arm64
55-
profile: aarch64
56-
image: ubuntu:14.04
57-
packages: cmake3 g++-aarch64-linux-gnu
58+
os_target_name: linux
59+
os_target_arch: aarch_64
60+
os_target_bitness: 64
61+
image: docker.io/dockcross/linux-arm64-lts
5862

5963
- target: linux_ppc
60-
profile: ppc64
61-
image: ubuntu:14.04
62-
packages: cmake3 g++-powerpc64le-linux-gnu
64+
os_target_name: linux
65+
os_target_arch: ppc_64
66+
os_target_bitness: 64
67+
image: docker.io/dockcross/linux-ppc64le
6368

6469
- target: windows_32
65-
profile: mingw32
66-
image: ubuntu:20.04
67-
packages: file cmake mingw-w64 binutils-mingw-w64-i686
70+
os_target_name: windows
71+
os_target_arch: x86_32
72+
os_target_bitness: 32
73+
image: docker.io/dockcross/windows-static-x86
6874

6975
- target: windows_64
70-
profile: mingw64
71-
image: ubuntu:20.04
72-
packages: file cmake mingw-w64
76+
os_target_name: windows
77+
os_target_arch: x86_64
78+
os_target_bitness: 64
79+
image: docker.io/dockcross/windows-static-x64
7380

7481
- target: windows_arm64
75-
profile: mingwaarch64
76-
image: ubuntu:20.04
77-
packages: file cmake clang
82+
os_target_name: windows
83+
os_target_arch: aarch_64
84+
os_target_bitness: 64
85+
image: docker.io/dockcross/windows-arm64
7886

7987
steps:
8088
- name: Checkout
81-
uses: actions/checkout@v2
89+
uses: actions/checkout@v3
8290

8391
- name: Pull docker images
8492
run: docker pull ${{ matrix.image }}
@@ -91,18 +99,18 @@ jobs:
9199

92100
- name: Build for ${{ matrix.target }} in ${{ matrix.image }}
93101
run: |
94-
export HOST_JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
95-
export HOST_MAVEN_HOME=$(dirname $(dirname $(readlink -f $(which mvn))))
96-
docker run --rm --workdir=/jssc \
97-
--volume $PWD:/jssc \
98-
--volume $HOST_JAVA_HOME:/jdk \
99-
--volume $HOST_MAVEN_HOME:/mvn \
100-
--env JAVA_HOME=/jdk \
102+
docker run --rm --workdir=/work \
103+
--volume $PWD:/work \
104+
--volume $HOME/.m2:/root/.m2 \
101105
--env MAVEN_OPTS=${MAVEN_OPTS} \
102106
${{ matrix.image }} \
103107
bash -c \
104-
' apt-get update && apt-get install --yes ${{ matrix.packages }} && \
105-
/mvn/bin/mvn -B clean install -P ${{ matrix.profile }} '
108+
'apt-get update && apt-get install --yes cmake maven openjdk-11-jdk-headless && \
109+
mvn -B clean install -P dockcross \
110+
-Dos.target.name=${{ matrix.os_target_name }} \
111+
-Dos.target.arch=${{ matrix.os_target_arch }} \
112+
-Dos.target.bitness=${{ matrix.os_target_bitness }} \
113+
'
106114
107115
- name: Push recompiled binaries
108116
run: |
@@ -114,7 +122,7 @@ jobs:
114122
while git pull --rebase && ! git push; do sleep 5; done
115123
116124
macos:
117-
runs-on: macos-10.15
125+
runs-on: macos-11
118126
needs: create-branch
119127
strategy:
120128
matrix:
@@ -128,12 +136,10 @@ jobs:
128136
profile: 'aarch64'
129137
macos-deployment-target: 11.0
130138
sdk-version: MacOSX11.0.sdk
131-
env:
132-
DEVELOPER_DIR: /Applications/Xcode_12.2.app/Contents/Developer
133139

134140
steps:
135141
- name: Checkout
136-
uses: actions/checkout@v2
142+
uses: actions/checkout@v3
137143

138144
- name: Set up JDK 11
139145
uses: actions/setup-java@v2
@@ -145,12 +151,13 @@ jobs:
145151
if: ${{ matrix.sdk-version == 'MacOSX10.9.sdk' }}
146152
run: |
147153
wget -qO- https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.9.sdk.tar.xz \
148-
| tar -xjv -C /Applications/Xcode_12.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
154+
| tar -xjv -C $XCODE_12_DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs
149155
150156
- name: Set SDK version
151157
run: |
152158
export MACOSX_DEPLOYMENT_TARGET=${{ matrix.macos-deployment-target }}
153-
export SDKROOT=${{ env.DEVELOPER_DIR }}/Platforms/MacOSX.platform/Developer/SDKs/${{ matrix.sdk-version }}
159+
export SDKROOT=$XCODE_12_DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/${{ matrix.sdk-version }}
160+
export CMAKE_OSX_SYSROOT=$SDKROOT
154161
- name: Build with Maven
155162
run: mvn -B clean install -P ${{ matrix.profile }}
156163

@@ -164,22 +171,23 @@ jobs:
164171
while git pull --rebase && ! git push; do sleep 5; done
165172
166173
solaris:
167-
runs-on: macos-latest
174+
runs-on: macos-12
168175
needs: create-branch
169176
steps:
170177
- name: Checkout
171-
uses: actions/checkout@v2
178+
uses: actions/checkout@v3
172179

173180
- name: Build on solaris
174-
uses: vmactions/solaris-vm@v0.0.3
181+
uses: vmactions/solaris-vm@v0
175182
with:
176183
envs: 'MAVEN_OPTS GITHUB_BOT_EMAIL GITHUB_BOT_NAME'
177184
run: |
178185
wget -qO- https://download.bell-sw.com/java/11.0.12+7/bellsoft-jdk11.0.12+7-solaris-x64-lite.tar.gz | tar xvf -
179-
wget -qO- https://downloads.apache.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz | tar xvfz -
186+
wget -qO- https://archive.apache.org/dist/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz | tar xvfz -
187+
180188
pkg install gcc git cmake
181-
JAVA_HOME=./jdk-11.0.12-lite ./apache-maven-3.8.1/bin/mvn -B clean install -P x86 -DskipTests
182-
JAVA_HOME=./jdk-11.0.12-lite ./apache-maven-3.8.1/bin/mvn -B clean install -P x86_64 -DskipTests
189+
JAVA_HOME=./jdk-11.0.12-lite ./apache-maven-3.8.8/bin/mvn -B clean install -P x86 -DskipTests
190+
JAVA_HOME=./jdk-11.0.12-lite ./apache-maven-3.8.8/bin/mvn -B clean install -P x86_64 -DskipTests
183191
git config --global user.email "${GITHUB_BOT_EMAIL}"
184192
git config --global user.name "${GITHUB_BOT_NAME}"
185193
git fetch && git checkout -t origin/${{ needs.create-branch.outputs.precompiled_branch }}

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,14 @@
481481
</properties>
482482
</profile>
483483

484+
<!-- Cross compile for default target in Dockcross container -->
485+
<profile>
486+
<id>dockcross</id>
487+
<properties>
488+
<os.target.toolchain>Dockcross</os.target.toolchain>
489+
</properties>
490+
</profile>
491+
484492
<!-- Cross compile for aarch64 -->
485493
<profile>
486494
<id>aarch64</id>

toolchain/Dockcross.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include($ENV{CMAKE_TOOLCHAIN_FILE})
2+
3+
if($ENV{DEFAULT_DOCKCROSS_IMAGE} MATCHES "dockcross/windows-.*")
4+
set(CMAKE_SYSTEM_NAME Windows)
5+
else()
6+
set(CMAKE_SYSTEM_NAME Linux)
7+
endif()
8+
9+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
10+
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
11+
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)

0 commit comments

Comments
 (0)