Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Apple M1 #479

Merged
merged 15 commits into from
May 23, 2022
1 change: 1 addition & 0 deletions codebuild/cd/deploy-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ phases:
- cp -rv $CODEBUILD_SRC_DIR_linux_x64/dist/* $CODEBUILD_SRC_DIR/aws-crt-java/target/cmake-build/
- cp -rv $CODEBUILD_SRC_DIR_linux_x86/dist/* $CODEBUILD_SRC_DIR/aws-crt-java/target/cmake-build/
- cp -rv $CODEBUILD_SRC_DIR_osx_x64/* $CODEBUILD_SRC_DIR/aws-crt-java/target/cmake-build/
- cp -rv $CODEBUILD_SRC_DIR_osx_arm64/* $CODEBUILD_SRC_DIR/aws-crt-java/target/cmake-build/
graebm marked this conversation as resolved.
Show resolved Hide resolved
- ls -alR $CODEBUILD_SRC_DIR/aws-crt-java/target/cmake-build/lib
# install settings.xml to ~/.m2/settings.xml
- mkdir -p $HOME/.m2
Expand Down
13 changes: 13 additions & 0 deletions codebuild/cd/osx-arm64-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

set -ex

cd `dirname $0`/../..

git submodule update --init

mvn -B compile -P mac-arm-make

# Copy artifacts to dist
mkdir -p ../dist
cp -rv target/cmake-build/lib ../dist/
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@
<cmake.cflags/>
</properties>
</profile>
<profile>
<id>mac-arm-make</id>
<activation>
<property>
<name>build_mac_m1</name>
ilevyor marked this conversation as resolved.
Show resolved Hide resolved
</property>
</activation>
graebm marked this conversation as resolved.
Show resolved Hide resolved
<properties>
<cmake.osx_arm64>-DCMAKE_OSX_ARCHITECTURES</cmake.osx_arm64>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird to have a variable where the value is set to something explicit, then the value is ignored later. You have here cmake.osx_arm64 = "-DCMAKE_OSX_ARCHITECTURES" but then later, if the variable is set at all (regardless of its value) you set cmake.architecture = "-DCMAKE_OSX_ARCHITECTURES=arm64"

Also, there's no way here to build the x86_64 binary from an M1 mac.

Suggestion 1: having an explicit <profile> for both mac-arm64 and mac-x64.

Suggestion 2: use the variable's value somehow, so that it's more flexible

maybe do like this?

<properties>
    ...
    <cmake.osx_arch>-DOSX_ARCH_DUMMY=1</xmake.osx_arch>

...
        <profile>
            <id>mac-arm64</id>
            ...
            <properties>
                <cmake.osx_arch>-DCMAKE_OSX_ARCHITECTURES=arm64</cmake.osx_arch>

...

                            <execution>
                                <id>cmake-configure</id>
                                ...
                                <configuration>
                                    <arguments>
                                        ...
                                        <argument>${cmake.osx_arch}</argument>

</properties>
</profile>
<!-- 32-bit Unix -->
<profile>
<id>unix-x86</id>
Expand Down Expand Up @@ -159,6 +170,7 @@
<argument>-DCMAKE_PREFIX_PATH=${cmake.binaries}/install</argument>
<argument>-DCMAKE_INSTALL_PREFIX=${cmake.binaries}/install</argument>
<argument>-DCMAKE_C_FLAGS=${cmake.cflags}</argument>
<argument>${cmake.architecture}</argument>
<argument>-DS2N_NO_PQ_ASM=${cmake.s2nNoPqAsm}</argument>
<argument>-DBUILD_TESTING=OFF</argument>
<argument>-Wno-unused-variables</argument>
Expand Down Expand Up @@ -354,6 +366,10 @@
<isset property="env.AWS_CMAKE_GENERATOR" />
</condition>
<echo message="Generator = ${cmake.generator}"/>
<condition property="cmake.architecture" value="-DCMAKE_OSX_ARCHITECTURES=arm64" else="-DGENERATOR_DUMMY=1">
<isset property="cmake.osx_arm64" />
</condition>
<echo message="architecture = ${cmake.architecture}"/>
</target>
</configuration>
</execution>
Expand Down