Skip to content

Commit a96f4b7

Browse files
Fixing tests.sh to work on mac
1 parent 8fff6f8 commit a96f4b7

File tree

8 files changed

+46
-91
lines changed

8 files changed

+46
-91
lines changed

BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ java_lite_proto_library(
481481

482482
objc_proto_library(
483483
name = "test_messages_proto2_objc_proto",
484-
srcs = ["test_messages_proto2.proto"],
484+
srcs = [":test_messages_proto2_proto_srcs"],
485485
includes = ["src/google/protobuf"],
486486
testonly = 1,
487487
visibility = [
@@ -492,7 +492,7 @@ objc_proto_library(
492492

493493
objc_proto_library(
494494
name = "test_messages_proto3_objc_proto",
495-
srcs = ["test_messages_proto3.proto"],
495+
srcs = [":test_messages_proto3_proto_srcs"],
496496
proto_deps = [":well_known_protos"],
497497
includes = ["src/google/protobuf", "src"],
498498
testonly = 1,

generate_descriptor_proto.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# generate.
88
#
99
# HINT: Flags passed to generate_descriptor_proto.sh will be passed directly
10-
# to make when building protoc. This is particularly useful for passing
10+
# to bazel when building protoc. This is particularly useful for passing
1111
# -j4 to run 4 jobs simultaneously.
1212

1313
if test ! -e src/google/protobuf/stubs/common.h; then
@@ -62,12 +62,12 @@ do
6262
PROTOC=$BOOTSTRAP_PROTOC
6363
BOOTSTRAP_PROTOC=""
6464
else
65-
make -j$(nproc) $@ protoc
65+
bazel build -j$(nproc) $@ //:protoc
6666
if test $? -ne 0; then
6767
echo "Failed to build protoc."
6868
exit 1
6969
fi
70-
PROTOC="./protoc"
70+
PROTOC="../bazel-bin/protoc"
7171
fi
7272

7373
$PROTOC --cpp_out=dllexport_decl=PROTOBUF_EXPORT:$TMP ${RUNTIME_PROTO_FILES[@]} && \

objectivec/DevTools/full_mac_build.sh

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ OPTIONS:
2424
Show this message
2525
-c, --clean
2626
Issue a clean before the normal build.
27-
-a, --autogen
28-
Start by rerunning autogen & configure.
2927
-r, --regenerate-descriptors
3028
Run generate_descriptor_proto.sh to regenerate all the checked in
3129
proto sources.
@@ -60,25 +58,7 @@ header() {
6058
echo "========================================================================"
6159
}
6260

63-
# Thanks to libtool, builds can fail in odd ways and since it eats some output
64-
# it can be hard to spot, so force error output if make exits with a non zero.
65-
wrapped_make() {
66-
set +e # Don't stop if the command fails.
67-
make $*
68-
MAKE_EXIT_STATUS=$?
69-
if [ ${MAKE_EXIT_STATUS} -ne 0 ]; then
70-
echo "Error: 'make $*' exited with status ${MAKE_EXIT_STATUS}"
71-
exit ${MAKE_EXIT_STATUS}
72-
fi
73-
set -e
74-
}
75-
76-
NUM_MAKE_JOBS=$(/usr/sbin/sysctl -n hw.ncpu)
77-
if [[ "${NUM_MAKE_JOBS}" -lt 2 ]] ; then
78-
NUM_MAKE_JOBS=2
79-
fi
80-
81-
DO_AUTOGEN=no
61+
NUM_JOBS=auto
8262
DO_CLEAN=no
8363
REGEN_DESCRIPTORS=no
8464
CORE_ONLY=no
@@ -98,15 +78,12 @@ while [[ $# != 0 ]]; do
9878
-c | --clean )
9979
DO_CLEAN=yes
10080
;;
101-
-a | --autogen )
102-
DO_AUTOGEN=yes
103-
;;
10481
-r | --regenerate-descriptors )
10582
REGEN_DESCRIPTORS=yes
10683
;;
10784
-j | --jobs )
10885
shift
109-
NUM_MAKE_JOBS="${1}"
86+
NUM_JOBS="${1}"
11087
;;
11188
--core-only )
11289
CORE_ONLY=yes
@@ -154,21 +131,9 @@ done
154131
# Into the proto dir.
155132
cd "${ProtoRootDir}"
156133

157-
# if no Makefile, force the autogen.
158-
if [[ ! -f Makefile ]] ; then
159-
DO_AUTOGEN=yes
160-
fi
161-
162-
if [[ "${DO_AUTOGEN}" == "yes" ]] ; then
163-
header "Running autogen & configure"
164-
./autogen.sh
165-
./configure \
166-
CPPFLAGS="-mmacosx-version-min=10.9 -Wunused-const-variable -Wunused-function"
167-
fi
168-
169134
if [[ "${DO_CLEAN}" == "yes" ]] ; then
170135
header "Cleaning"
171-
wrapped_make clean
136+
bazel clean
172137
if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
173138
XCODEBUILD_CLEAN_BASE_IOS=(
174139
xcodebuild
@@ -212,24 +177,23 @@ fi
212177

213178
if [[ "${REGEN_DESCRIPTORS}" == "yes" ]] ; then
214179
header "Regenerating the descriptor sources."
215-
./generate_descriptor_proto.sh -j "${NUM_MAKE_JOBS}"
180+
./generate_descriptor_proto.sh -j "${NUM_JOBS}"
216181
fi
217182

218183
if [[ "${CORE_ONLY}" == "yes" ]] ; then
219184
header "Building core Only"
220-
wrapped_make -j "${NUM_MAKE_JOBS}"
185+
bazel build //:protoc //:protobuf //:protobuf_lite -j "${NUM_JOBS}"
221186
else
222187
header "Building"
223188
# Can't issue these together, when fully parallel, something sometimes chokes
224189
# at random.
225-
wrapped_make -j "${NUM_MAKE_JOBS}" all
226-
wrapped_make -j "${NUM_MAKE_JOBS}" check
190+
bazel test //src/...
227191
# Fire off the conformance tests also.
228192
bazel test //conformance:objc
229193
fi
230194

231195
# Ensure the WKT sources checked in are current.
232-
objectivec/generate_well_known_types.sh --check-only -j "${NUM_MAKE_JOBS}"
196+
objectivec/generate_well_known_types.sh --check-only -j "${NUM_JOBS}"
233197

234198
header "Checking on the ObjC Runtime Code"
235199
# Some of the kokoro machines don't have python3 yet, so fall back to python if need be.
@@ -293,7 +257,7 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
293257
-disable-concurrent-destination-testing
294258
)
295259
;;
296-
11.* | 12.* | 13.*)
260+
11.* | 12.* | 13.* | 14.*)
297261
# Dropped 32bit as Apple doesn't seem support the simulators either.
298262
XCODEBUILD_TEST_BASE_IOS+=(
299263
-destination "platform=iOS Simulator,name=iPhone 8,OS=latest" # 64bit

objectivec/generate_well_known_types.sh

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# the protocol compiler changes.
55

66
# HINT: Flags passed to generate_well_known_types.sh will be passed directly
7-
# to make when building protoc. This is particularly useful for passing
7+
# to bazel when building protoc. This is particularly useful for passing
88
# -j4 to run 4 jobs simultaneously.
99

1010
set -eu
@@ -30,18 +30,10 @@ __EOF__
3030
exit 1
3131
fi
3232

33-
if [[ ! -e src/Makefile ]]; then
34-
cat >&2 << __EOF__
35-
Could not find src/Makefile. You must run ./configure (and perhaps
36-
./autogen.sh) first.
37-
__EOF__
38-
exit 1
39-
fi
40-
4133
# Make sure the compiler is current.
42-
cd src
43-
make $@ protoc
34+
bazel build $@ //:protoc
4435

36+
cd src
4537
declare -a RUNTIME_PROTO_FILES=( \
4638
google/protobuf/any.proto \
4739
google/protobuf/api.proto \
@@ -59,7 +51,7 @@ declare -a OBJC_EXTENSIONS=( .pbobjc.h .pbobjc.m )
5951
# Generate to a temp directory to see if they match.
6052
TMP_DIR=$(mktemp -d)
6153
trap "rm -rf ${TMP_DIR}" EXIT
62-
./protoc --objc_out="${TMP_DIR}" ${RUNTIME_PROTO_FILES[@]}
54+
${ProtoRootDir}/bazel-bin/protoc --objc_out="${TMP_DIR}" ${RUNTIME_PROTO_FILES[@]}
6355

6456
DID_COPY=0
6557
for PROTO_FILE in "${RUNTIME_PROTO_FILES[@]}"; do

php/generate_descriptor_protos.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@ __EOF__
1313
exit 1
1414
fi
1515

16-
pushd src
17-
./protoc --php_out=internal:../php/src google/protobuf/descriptor.proto
18-
./protoc --php_out=internal_generate_c_wkt:../php/src \
19-
google/protobuf/any.proto \
20-
google/protobuf/api.proto \
21-
google/protobuf/duration.proto \
22-
google/protobuf/empty.proto \
23-
google/protobuf/field_mask.proto \
24-
google/protobuf/source_context.proto \
25-
google/protobuf/struct.proto \
26-
google/protobuf/type.proto \
27-
google/protobuf/timestamp.proto \
28-
google/protobuf/wrappers.proto
16+
bazel-bin/protoc --php_out=internal:php/src google/protobuf/descriptor.proto
17+
bazel-bin/protoc --php_out=internal_generate_c_wkt:php/src \
18+
src/google/protobuf/any.proto \
19+
src/google/protobuf/api.proto \
20+
src/google/protobuf/duration.proto \
21+
src/google/protobuf/empty.proto \
22+
src/google/protobuf/field_mask.proto \
23+
src/google/protobuf/source_context.proto \
24+
src/google/protobuf/struct.proto \
25+
src/google/protobuf/type.proto \
26+
src/google/protobuf/timestamp.proto \
27+
src/google/protobuf/wrappers.proto
2928
popd

php/generate_test_protos.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,12 @@
22

33
set -ex
44

5-
cd `dirname $0`
6-
7-
if ../src/protoc --help > /dev/null; then
8-
PROTOC=src/protoc
9-
else
10-
# Bazel seems to be creating a problematic symlink in
11-
# _build/out/external/com_google_protobuf, so we remove the _build directory
12-
# before building protoc.
13-
(cd .. && bazel build -c opt :protoc)
14-
PROTOC=bazel-bin/protoc
15-
fi
5+
cd `dirname $0`/..
6+
7+
bazel build -c opt //:protoc
8+
PROTOC=bazel-bin/protoc
169

17-
if [[ -d tmp && -z $(find tests/proto ../$PROTOC -newer tmp) ]]; then
10+
if [[ -d php/tmp && -z $(find php/tests/proto $PROTOC -newer php/tmp) ]]; then
1811
# Generated protos are already present and up to date, so we can skip protoc.
1912
#
2013
# Protoc is very fast, but sometimes it is not available (like if we haven't
@@ -23,10 +16,9 @@ if [[ -d tmp && -z $(find tests/proto ../$PROTOC -newer tmp) ]]; then
2316
exit 0
2417
fi
2518

26-
rm -rf tmp
27-
mkdir -p tmp
19+
rm -rf php/tmp
20+
mkdir -p php/tmp
2821

29-
cd ..
3022
find php/tests/proto -type f -name "*.proto"| xargs $PROTOC --php_out=php/tmp -Isrc -Iphp/tests
3123

3224
if [ "$1" = "--aggregate_metadata" ]; then

python/setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def HasLibraryDirsOpt():
290290
library_dirs = None
291291
if not HasStaticLibprotobufOpt():
292292
extra_objects = ['../bazel-bin/src/google/protobuf/libprotobuf.a',
293-
'../bazel-bin/src/google/protobuf/libprotobuf-lite.a']
293+
'../bazel-bin/src/google/protobuf/libprotobuf_lite.a']
294294
else:
295295
libraries = ['protobuf']
296296
if HasLibraryDirsOpt():
@@ -361,6 +361,11 @@ def HasLibraryDirsOpt():
361361
sys.argv.remove(warnings_as_errors)
362362

363363
# C++ implementation extension
364+
print(libraries)
365+
print(extra_objects)
366+
print(message_extra_link_args)
367+
print(library_dirs)
368+
print(extra_compile_args)
364369
ext_module_list.extend([
365370
Extension(
366371
'google.protobuf.pyext._message',

third_party/utf8_range/BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ cc_library(
1414

1515
filegroup(
1616
name = "all_files",
17-
srcs = glob(["*"]),
17+
srcs = glob([
18+
"*.h",
19+
"*.c",
20+
]),
1821
visibility = [
1922
"//cmake:__pkg__",
2023
"//php:__pkg__",

0 commit comments

Comments
 (0)