Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions buildscripts/kokoro/unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ ARCH="$ARCH" buildscripts/make_dependencies.sh
# Set properties via flags, do not pollute gradle.properties
GRADLE_FLAGS="${GRADLE_FLAGS:-}"
GRADLE_FLAGS+=" -PtargetArch=$ARCH"

# For universal binaries on macOS, signal Gradle to use universal flags.
if [[ "$(uname -s)" == "Darwin" ]]; then
GRADLE_FLAGS+=" -PbuildUniversal=true"
fi
GRADLE_FLAGS+=" -Pcheckstyle.ignoreFailures=false"
GRADLE_FLAGS+=" -PfailOnWarnings=true"
GRADLE_FLAGS+=" -PerrorProne=true"
Expand Down
2 changes: 0 additions & 2 deletions buildscripts/kokoro/upload_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ LOCAL_OTHER_ARTIFACTS="$KOKORO_GFILE_DIR"/github/grpc-java/artifacts/

# from macos job:
[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-osx-x86_64.exe' | wc -l)" != '0' ]]
# copy all x86 artifacts to aarch until native artifacts are built
find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-osx-x86_64.exe*' -exec bash -c 'cp "${0}" "${0/x86/aarch}"' {} \;
Comment thread
shivaspeaks marked this conversation as resolved.

# from windows job:
[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-windows-x86_64.exe' | wc -l)" != '0' ]]
Expand Down
8 changes: 7 additions & 1 deletion buildscripts/make_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ else
mkdir "$DOWNLOAD_DIR/protobuf-${PROTOBUF_VERSION}/build"
pushd "$DOWNLOAD_DIR/protobuf-${PROTOBUF_VERSION}/build"
# install here so we don't need sudo
if [[ "$ARCH" == x86* ]]; then
if [[ "$(uname -s)" == "Darwin" ]]; then
cmake .. \
-DCMAKE_CXX_STANDARD=14 -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DABSL_INTERNAL_AT_LEAST_CXX17=0 \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-B. || exit 1
elif [[ "$ARCH" == x86* ]]; then
CFLAGS=-m${ARCH#*_} CXXFLAGS=-m${ARCH#*_} cmake .. \
-DCMAKE_CXX_STANDARD=14 -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF \
Comment thread
ejona86 marked this conversation as resolved.
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DABSL_INTERNAL_AT_LEAST_CXX17=0 \
Expand Down
4 changes: 4 additions & 0 deletions compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ model {
cppCompiler.args "--std=c++14"
addEnvArgs("CXXFLAGS", cppCompiler.args)
addEnvArgs("CPPFLAGS", cppCompiler.args)
if (project.getProperty('buildUniversal') == 'true' && osdetector.os == "osx") {
Comment thread
shivaspeaks marked this conversation as resolved.
Outdated
cppCompiler.args "-arch", "arm64", "-arch", "x86_64"
linker.args "-arch", "arm64", "-arch", "x86_64"
}
if (osdetector.os == "osx") {
cppCompiler.args "-mmacosx-version-min=10.7", "-stdlib=libc++"
linker.args "-framework", "CoreFoundation"
Expand Down
20 changes: 10 additions & 10 deletions compiler/check-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ checkArch ()
fi
fi
elif [[ "$OS" == osx ]]; then
format="$(file -b "$1" | grep -o "[^ ]*$")"
echo Format=$format
if [[ "$ARCH" == x86_32 ]]; then
assertEq "$format" "i386" $LINENO
elif [[ "$ARCH" == x86_64 ]]; then
assertEq "$format" "x86_64" $LINENO
elif [[ "$ARCH" == aarch_64 ]]; then
assertEq "$format" "arm64" $LINENO
else
fail "Unsupported arch: $ARCH"
# For macOS, we now build a universal binary. We check that both
# required architectures are present.
format="$(lipo -archs "$1")"
echo "Architectures found: $format"
if ! echo "$format" | grep -q "x86_64"; then
fail "Universal binary is missing x86_64 architecture."
fi
if ! echo "$format" | grep -q "arm64"; then
fail "Universal binary is missing arm64 architecture."
fi
echo "Universal binary check successful."
else
fail "Unsupported system: $OS"
fi
Expand Down
Loading