Skip to content

Commit

Permalink
Move logic for static cross-compile for linux-aarch64 to pom file.
Browse files Browse the repository at this point in the history
Motivation:

Let's try to keep logic together to make it easier to keep track of changes

Modifications:

Move logic for cross compile to pom file.

Result:

Easier to maintain
  • Loading branch information
normanmaurer committed Mar 7, 2024
1 parent 35e51e0 commit 225dbf0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
7 changes: 4 additions & 3 deletions boringssl-static/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -634,11 +634,12 @@
</profile>

<profile>
<id>linux-aarch64</id>
<id>linux-aarch64-cross-compile</id>

<properties>
<boringsslSourceDir>${project.build.directory}/boringssl-${boringsslBranch}</boringsslSourceDir>
<boringsslHome>${boringsslSourceDir}/build</boringsslHome>
<crossCompile>osx</crossCompile>
<linkStatic>true</linkStatic>
<msvcSslIncludeDirs>${boringsslSourceDir}/include</msvcSslIncludeDirs>
<msvcSslLibDirs>${boringsslHome}/ssl;${boringsslHome}/crypto</msvcSslLibDirs>
Expand Down Expand Up @@ -1145,7 +1146,7 @@

<properties>
<linkStatic>true</linkStatic>
<osxCrossCompile>true</osxCrossCompile>
<crossCompile>osx</crossCompile>
<target>arm64-apple-macos11</target>
<macOsxDeploymentTarget>OSX_DEPLOYMENT_TARGET=11.0</macOsxDeploymentTarget>
<cmakeOsxDeploymentTarget>-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0</cmakeOsxDeploymentTarget>
Expand Down Expand Up @@ -1392,7 +1393,7 @@

<properties>
<linkStatic>true</linkStatic>
<osxCrossCompile>true</osxCrossCompile>
<crossCompile>osx</crossCompile>
<target>x86_64-apple-macos10.12</target>
<macOsxDeploymentTarget>OSX_DEPLOYMENT_TARGET=10.12</macOsxDeploymentTarget>
<cmakeOsxDeploymentTarget>-DCMAKE_OSX_DEPLOYMENT_TARGET=10.12</cmakeOsxDeploymentTarget>
Expand Down
8 changes: 4 additions & 4 deletions docker/docker-compose.centos-7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ services:

cross-compile-aarch64-build:
<<: *cross-compile-aarch64-common
command: /bin/bash -cl "./mvnw clean package -Plinux-aarch64 -am -pl openssl-dynamic -DaprArmHome=/opt/apr-$$APR_VERSION-share -DopensslArmHome=/opt/openssl-$$OPENSSL_VERSION-share -DskipTests && ./mvnw clean package -Plinux-aarch64 -am -pl boringssl-static -DaprArmHome=/opt/apr-$$APR_VERSION-static -DboringsslSourceDir=/root/workspace/boringssl-source -DboringsslHome=/root/workspace/boringssl -DskipTests"
command: /bin/bash -cl "./mvnw clean package -Plinux-aarch64-cross-compile -am -pl openssl-dynamic -DaprArmHome=/opt/apr-$$APR_VERSION-share -DopensslArmHome=/opt/openssl-$$OPENSSL_VERSION-share -DskipTests && ./mvnw clean package -Plinux-aarch64-cross-compile -am -pl boringssl-static -DskipTests"

cross-compile-aarch64-deploy:
<<: *cross-compile-aarch64-common
Expand All @@ -50,7 +50,7 @@ services:
- ~/.m2/repository:/root/.m2/repository
- ~/.m2/settings.xml:/root/.m2/settings.xml
- ..:/code
command: /bin/bash -cl "./mvnw clean deploy -Plinux-aarch64 -am -pl openssl-dynamic -DaprArmHome=/opt/apr-$$APR_VERSION-share -DopensslArmHome=/opt/openssl-$$OPENSSL_VERSION-share -DskipTests && ./mvnw clean deploy -Plinux-aarch64 -am -pl boringssl-static -DaprArmHome=/opt/apr-$$APR_VERSION-static -DboringsslSourceDir=/root/workspace/boringssl-source -DboringsslHome=/root/workspace/boringssl -DskipTests"
command: /bin/bash -cl "./mvnw clean deploy -Plinux-aarch64-cross-compile -am -pl openssl-dynamic -DaprArmHome=/opt/apr-$$APR_VERSION-share -DopensslArmHome=/opt/openssl-$$OPENSSL_VERSION-share -DskipTests && ./mvnw clean deploy -Plinux-aarch64-cross-compile -am -pl boringssl-static -DskipTests"

cross-compile-aarch64-stage-snapshot:
<<: *cross-compile-aarch64-common
Expand All @@ -60,7 +60,7 @@ services:
- ~/.m2/repository:/root/.m2/repository
- ~/local-staging:/root/local-staging
- ..:/code
command: /bin/bash -cl "./mvnw -Plinux-aarch64 -am -pl openssl-dynamic -DaprArmHome=/opt/apr-$$APR_VERSION-share -DopensslArmHome=/opt/openssl-$$OPENSSL_VERSION-share clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DaltStagingDirectory=/root/local-staging -DskipRemoteStaging=true -DskipTests=true && ./mvnw -Plinux-aarch64 -am -pl boringssl-static -DaprArmHome=/opt/apr-$$APR_VERSION-static -DboringsslSourceDir=/root/workspace/boringssl-source -DboringsslHome=/root/workspace/boringssl clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DaltStagingDirectory=/root/local-staging -DskipRemoteStaging=true -DskipTests=true"
command: /bin/bash -cl "./mvnw -Plinux-aarch64-cross-compile -am -pl openssl-dynamic -DaprArmHome=/opt/apr-$$APR_VERSION-share -DopensslArmHome=/opt/openssl-$$OPENSSL_VERSION-share clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DaltStagingDirectory=/root/local-staging -DskipRemoteStaging=true -DskipTests=true && ./mvnw -Plinux-aarch64-cross-compile -am -pl boringssl-static clean package org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DaltStagingDirectory=/root/local-staging -DskipRemoteStaging=true -DskipTests=true"

cross-compile-aarch64-stage-release:
<<: *cross-compile-aarch64-common
Expand All @@ -70,5 +70,5 @@ services:
- ~/.m2/settings.xml:/root/.m2/settings.xml
- ~/local-staging:/root/local-staging
- ..:/code
command: /bin/bash -cl "cat <(echo -e \"${GPG_PRIVATE_KEY}\") | gpg --batch --import && ./mvnw -Plinux-aarch64 -am -pl openssl-dynamic -DaprArmHome=/opt/apr-$$APR_VERSION-share -DopensslArmHome=/opt/openssl-$$OPENSSL_VERSION-share clean javadoc:jar package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=/root/local-staging -DskipRemoteStaging=true -DskipTests=true -Dgpg.passphrase=${GPG_PASSPHRASE} -Dgpg.keyname=${GPG_KEYNAME} && ./mvnw -Plinux-aarch64 -am -pl boringssl-static -DaprArmHome=/opt/apr-$$APR_VERSION-static -DboringsslSourceDir=/root/workspace/boringssl-source -DboringsslHome=/root/workspace/boringssl clean javadoc:jar package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=/root/local-staging -DskipRemoteStaging=true -DskipTests=true -Dgpg.passphrase=${GPG_PASSPHRASE} -Dgpg.keyname=${GPG_KEYNAME}"
command: /bin/bash -cl "cat <(echo -e \"${GPG_PRIVATE_KEY}\") | gpg --batch --import && ./mvnw -Plinux-aarch64-cross-compile -am -pl openssl-dynamic -DaprArmHome=/opt/apr-$$APR_VERSION-share -DopensslArmHome=/opt/openssl-$$OPENSSL_VERSION-share clean javadoc:jar package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=/root/local-staging -DskipRemoteStaging=true -DskipTests=true -Dgpg.passphrase=${GPG_PASSPHRASE} -Dgpg.keyname=${GPG_KEYNAME} && ./mvnw -Plinux-aarch64-cross-compile -am -pl boringssl-static clean javadoc:jar package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=/root/local-staging -DskipRemoteStaging=true -DskipTests=true -Dgpg.passphrase=${GPG_PASSPHRASE} -Dgpg.keyname=${GPG_KEYNAME}"

30 changes: 28 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<aprSourceDir>${project.build.directory}/apr-source</aprSourceDir>
<archBits>64</archBits>
<linkStatic>false</linkStatic>
<osxCrossCompile>false</osxCrossCompile>
<crossCompile>false</crossCompile>
<sslHome>${project.build.directory}/ssl</sslHome>
<msvcSslIncludeDirs>${sslHome}/include</msvcSslIncludeDirs>
<msvcSslLibDirs>${sslHome}/lib</msvcSslLibDirs>
Expand Down Expand Up @@ -667,7 +667,7 @@
<exec executable="buildconf" failonerror="true" dir="${aprSourceDir}" resolveexecutable="true" />

<if>
<equals arg1="${osxCrossCompile}" arg2="true" />
<equals arg1="${crossCompile}" arg2="osx" />
<then>
<!--
+ We need to set some extra variables as otherwise the configure of apr will fail when trying to cross-compile.
Expand All @@ -691,6 +691,32 @@
<arg line="install" />
</exec>
</then>
<elif>
<equals arg1="${crossCompile}" arg2="linux" />
<then>
<!--
+ We need to set some extra variables as otherwise the configure of apr will fail when trying to cross-compile.
+ See https://stackoverflow.com/a/1605497/1074097
+ -->
<exec executable="configure" failonerror="true" dir="${aprSourceDir}" resolveexecutable="true">
<arg line="--disable-shared --prefix=${aprHome} CFLAGS='-O3 -fno-omit-frame-pointer -fPIC -target aarch64-none-linux-gnu-gcc' --host=aarch64-none-linux-gnu ac_cv_have_decl_sys_siglist=no ac_cv_file__dev_zero=yes apr_cv_process_shared_works=yes apr_cv_mutex_robust_shared=no apr_cv_tcp_nodelay_with_cork=yes" />
</exec>
<!--
Make will fail when it tries to use the gen_test_char program.
We work around this by compile gen_test_char separate, execute and than rerun make.
See https://stackoverflow.com/a/56262330/1074097
-->
<exec executable="make" failonerror="false" dir="${aprSourceDir}" resolveexecutable="true" />
<exec executable="gcc" failonerror="true" dir="${aprSourceDir}" resolveexecutable="true">
<arg line="-Wall -O2 -DCROSS_COMPILE tools/gen_test_char.c -o tools/gen_test_char" />
</exec>
<exec executable="tools/gen_test_char" failonerror="true" dir="${aprSourceDir}" resolveexecutable="true" output="${aprSourceDir}/include/private/apr_escape_test_char.h" />
<exec executable="make" failonerror="true" dir="${aprSourceDir}" resolveexecutable="true" />
<exec executable="make" failonerror="true" dir="${aprSourceDir}" resolveexecutable="true">
<arg line="install" />
</exec>
</then>
</elif>
<else>
<exec executable="configure" failonerror="true" dir="${aprSourceDir}" resolveexecutable="true">
<!--
Expand Down

0 comments on commit 225dbf0

Please sign in to comment.