Skip to content

Commit a98ef55

Browse files
committed
Fix the treatment of the -sysroot flag in j2objcc.
Change on 2017/06/06 by kstanger <[email protected]> ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=158179424
1 parent a7a4685 commit a98ef55

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

scripts/j2objcc.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
# j2objcc <clang options> <files>
2323
#
2424

25+
declare RAW_ARGS="$@"
26+
2527
if [ -L "$0" ]; then
2628
readonly DIR=$(dirname $(readlink "$0"))
2729
else
@@ -44,7 +46,7 @@ fi
4446

4547
declare CC_FLAGS="-Werror -Wno-parentheses -fno-strict-overflow -Wno-compare-distinct-pointer-types"
4648
CC_FLAGS="${CC_FLAGS} -Wno-nullability-completeness"
47-
declare OBJC="-std=c11"
49+
declare STD_FLAG="c11"
4850
declare OTHER_LIBS="-l iconv -l z -l j2objc_main -l c++"
4951
declare SYSROOT_PATH="none"
5052
declare EMUL_LIB="-ljre_emul"
@@ -54,24 +56,25 @@ declare USE_ARC="no"
5456
declare CORE_LIB_WARNING="warning: linking the core runtime to reduce binary \
5557
size. Use -ljre_emul to link the full Java runtime."
5658

57-
for arg; do
58-
case $arg in
59+
while [ $# -gt 0 ]; do
60+
case $1 in
5961
# Check whether linking is disabled by a -c, -S, or -E option.
6062
-[cSE]) DO_LINK="no" ;;
6163
-fobjc-arc) USE_ARC="yes" ;;
6264
# Check whether we need to build for C++ instead of C.
63-
objective-c\+\+) CC_FLAGS="${CC_FLAGS} -std=c++98" OBJC= ;;
65+
-x) if [ "$2" == "objective-c++" ]; then STD_FLAG="c++98"; fi; shift ;;
6466
# Save sysroot path for later inspection.
65-
-isysroot) SYSROOT_PATH="${i#*=}" ;;
67+
-isysroot) SYSROOT_PATH="$2"; shift ;;
6668
-ObjC) EMUL_LIB="-ljre_core" ;;
6769
esac
70+
shift
6871
done
6972

7073
if [[ "$USE_ARC" == "yes" ]]; then
7174
CC_FLAGS="$CC_FLAGS -fobjc-arc-exceptions"
7275
fi
7376

74-
if [[ $@ =~ .*-l(\ )*jre_emul\ .* ]]; then
77+
if [[ $RAW_ARGS =~ .*-l(\ )*jre_emul\ .* ]]; then
7578
EMUL_LIB=""
7679
fi
7780

@@ -87,4 +90,4 @@ if [[ "$DO_LINK" == "yes" ]]; then
8790
LINK_FLAGS="${EMUL_LIB} ${OTHER_LIBS} ${FRAMEWORKS} -L ${LIB_PATH}"
8891
fi
8992

90-
xcrun clang "$@" -I ${INCLUDE_PATH} ${CC_FLAGS} ${OBJC} ${LINK_FLAGS}
93+
xcrun clang ${RAW_ARGS} -I ${INCLUDE_PATH} ${CC_FLAGS} -std=${STD_FLAG} ${LINK_FLAGS}

0 commit comments

Comments
 (0)