Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
10 changes: 9 additions & 1 deletion buildscripts/kokoro/unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ ARCH="$ARCH" buildscripts/make_dependencies.sh

# Set properties via flags, do not pollute gradle.properties
GRADLE_FLAGS="${GRADLE_FLAGS:-}"
GRADLE_FLAGS+=" -PtargetArch=$ARCH"

# Configure OS-specific build flags.
if [[ "$(uname -s)" == "Darwin" ]]; then
# For universal binaries on macOS, signal Gradle to use universal flags.
GRADLE_FLAGS+=" -PbuildUniversal=true"
else
# For Linux, build for a single, specific architecture.
GRADLE_FLAGS+=" -PtargetArch=$ARCH"
Comment thread
ejona86 marked this conversation as resolved.
Outdated
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
7 changes: 6 additions & 1 deletion buildscripts/make_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ 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 .. \
Comment thread
ejona86 marked this conversation as resolved.
Outdated
-DCMAKE_CXX_STANDARD=14 -Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" -DABSL_INTERNAL_AT_LEAST_CXX17=0 \
-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.hasProperty('buildUniversal') && osdetector.os == "osx") {
Comment thread
ejona86 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