From dcf1e12556c73cea9cff1219feebf88ee25f6a85 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Wed, 8 Sep 2021 21:45:40 +0200 Subject: [PATCH] Add support for mac m1 (#11666) Motivation: As more and more people switch to a mac m1 we should support it Modifications: - Add profiles for cross-compile for mac m1 - Adjust script to finish release Result: Mac m1 is supported --- all/pom.xml | 30 +++++++- bom/pom.xml | 19 ++++- resolver-dns-native-macos/pom.xml | 105 +++++++++++++++++++++++++++ scripts/finish_release.sh | 1 + transport-native-kqueue/pom.xml | 105 +++++++++++++++++++++++++++ transport-native-unix-common/pom.xml | 69 ++++++++++++++++++ 6 files changed, 327 insertions(+), 2 deletions(-) diff --git a/all/pom.xml b/all/pom.xml index 0afc0ab297..89e6082c39 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -82,6 +82,13 @@ compile true + + ${project.groupId} + netty-transport-native-kqueue + osx-aarch_64 + compile + true + ${project.groupId} netty-resolver-dns-native-macos @@ -89,6 +96,13 @@ compile true + + ${project.groupId} + netty-resolver-dns-native-macos + osx-aarch_64 + compile + true + @@ -118,6 +132,13 @@ compile true + + ${project.groupId} + netty-transport-native-kqueue + osx-aarch_64 + compile + true + ${project.groupId} netty-resolver-dns-native-macos @@ -125,10 +146,17 @@ compile true + + ${project.groupId} + netty-resolver-dns-native-macos + osx-aarch_64 + compile + true + - diff --git a/bom/pom.xml b/bom/pom.xml index e22b1c7ba5..778d85e3d8 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -192,6 +192,12 @@ 5.0.0.Final-SNAPSHOT osx-x86_64 + + io.netty + netty-resolver-dns-native-macos + 4.1.68.Final-SNAPSHOT + osx-aarch_64 + io.netty netty-transport-native-unix-common @@ -215,6 +221,12 @@ 5.0.0.Final-SNAPSHOT osx-x86_64 + + io.netty + netty-transport-native-unix-common + 4.1.68.Final-SNAPSHOT + osx-aarch_64 + io.netty netty-transport-native-epoll @@ -243,7 +255,12 @@ 5.0.0.Final-SNAPSHOT osx-x86_64 - + + io.netty + netty-transport-native-kqueue + 4.1.68.Final-SNAPSHOT + osx-aarch_64 + io.netty diff --git a/resolver-dns-native-macos/pom.xml b/resolver-dns-native-macos/pom.xml index f2f6cd6adb..380a07b1ea 100644 --- a/resolver-dns-native-macos/pom.xml +++ b/resolver-dns-native-macos/pom.xml @@ -132,6 +132,111 @@ + + mac-m1-cross-compile + + LDFLAGS=-arch arm64 -Wl,-weak_library,${unix.common.lib.unpacked.dir}/lib${unix.common.lib.name}.a + CFLAGS=-target arm64-apple-macos11 -O3 -Werror -fno-omit-frame-pointer -Wunused-variable -fvisibility=hidden -I${unix.common.include.unpacked.dir} + + + ${os.detected.name}-aarch_64 + true + + + + + maven-dependency-plugin + + + + unpack + generate-sources + + unpack-dependencies + + + ${project.groupId} + netty-transport-native-unix-common + ${jni.classifier} + ${unix.common.lib.dir} + META-INF/native/** + false + true + + + + + + + org.fusesource.hawtjni + maven-hawtjni-plugin + + + build-native-lib + + netty_resolver_dns_native_macos_aarch_64 + ${project.basedir}/src/main/c + ${project.build.outputDirectory} + + . + + ${jni.compiler.args.ldflags} + ${jni.compiler.args.cflags} + --host=aarch64-apple-darwin + + + + generate + build + + + + + + + maven-jar-plugin + + + + native-jar + + jar + + + + + true + + + META-INF/native/libnetty_resolver_dns_native_macos_aarch_64.jnilib; osname=MacOSX; processor=aarch_64 + ${javaModuleName} + + true + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + ${jni.classifier} + + + + + + + + + io.netty + netty-transport-native-unix-common + ${project.version} + ${jni.classifier} + + true + + + diff --git a/scripts/finish_release.sh b/scripts/finish_release.sh index 22f1b67f57..193904cae2 100755 --- a/scripts/finish_release.sh +++ b/scripts/finish_release.sh @@ -41,6 +41,7 @@ git checkout "$2" export JAVA_HOME="$JAVA8_HOME" ./mvnw -Psonatype-oss-release -am -pl resolver-dns-native-macos,transport-native-unix-common,transport-native-kqueue clean package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DstagingRepositoryId="$1" -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DskipTests=true +./mvnw -Psonatype-oss-release,mac-m1-cross-compile -am -pl resolver-dns-native-macos,transport-native-unix-common,transport-native-kqueue clean package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DstagingRepositoryId="$1" -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DskipTests=true ./mvnw -Psonatype-oss-release,full,uber-staging -pl all clean package gpg:sign org.sonatype.plugins:nexus-staging-maven-plugin:deploy -DstagingRepositoryId="$1" -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DskipTests=true diff --git a/transport-native-kqueue/pom.xml b/transport-native-kqueue/pom.xml index c9fd3968c6..da016fcb86 100644 --- a/transport-native-kqueue/pom.xml +++ b/transport-native-kqueue/pom.xml @@ -137,6 +137,111 @@ + + mac-m1-cross-compile + + + ${os.detected.name}-aarch_64 + CFLAGS=-target arm64-apple-macos11 -O3 -Werror -fno-omit-frame-pointer -Wunused-variable -fvisibility=hidden -I${unix.common.include.unpacked.dir} + LDFLAGS=-arch arm64 -Wl,-weak_library,${unix.common.lib.unpacked.dir}/lib${unix.common.lib.name}.a + true + + + + + maven-dependency-plugin + + + + unpack + generate-sources + + unpack-dependencies + + + ${project.groupId} + netty-transport-native-unix-common + ${jni.classifier} + ${unix.common.lib.dir} + META-INF/native/** + false + true + + + + + + + org.fusesource.hawtjni + maven-hawtjni-plugin + + + build-native-lib + + netty_transport_native_kqueue_aarch_64 + ${nativeSourceDirectory} + ${project.build.outputDirectory} + + . + + ${jni.compiler.args.ldflags} + ${jni.compiler.args.cflags} + --host=aarch64-apple-darwin + --libdir=${project.build.directory}/native-build/target/lib + + + + generate + build + + + + + + + maven-jar-plugin + + + + native-jar + + jar + + + + + true + + + META-INF/native/libnetty_transport_native_kqueue_aarch_64.jnilib; osname=MacOSX; processor=aarch_64 + ${javaModuleName} + + true + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + ${jni.classifier} + + + + + + + + + io.netty + netty-transport-native-unix-common + ${project.version} + ${jni.classifier} + + true + + + openbsd diff --git a/transport-native-unix-common/pom.xml b/transport-native-unix-common/pom.xml index 41fcf3d8c9..ed7ccd3a3a 100644 --- a/transport-native-unix-common/pom.xml +++ b/transport-native-unix-common/pom.xml @@ -169,6 +169,75 @@ + + mac-m1-cross-compile + + clang + darwin + + ${os.detected.name}-aarch_64 + + + + + maven-antrun-plugin + + + + native-jar + package + + run + + + + + + + + + + + + + + + + + + + + + + + + + + build-native-lib + generate-sources + + run + + + + + + + + + + + + + + + + + + + + + linux