22
22
# j2objcc <clang options> <files>
23
23
#
24
24
25
+ declare RAW_ARGS=" $@ "
26
+
25
27
if [ -L " $0 " ]; then
26
28
readonly DIR=$( dirname $( readlink " $0 " ) )
27
29
else
44
46
45
47
declare CC_FLAGS=" -Werror -Wno-parentheses -fno-strict-overflow -Wno-compare-distinct-pointer-types"
46
48
CC_FLAGS=" ${CC_FLAGS} -Wno-nullability-completeness"
47
- declare OBJC= " -std= c11"
49
+ declare STD_FLAG= " c11"
48
50
declare OTHER_LIBS=" -l iconv -l z -l j2objc_main -l c++"
49
51
declare SYSROOT_PATH=" none"
50
52
declare EMUL_LIB=" -ljre_emul"
@@ -54,24 +56,25 @@ declare USE_ARC="no"
54
56
declare CORE_LIB_WARNING=" warning: linking the core runtime to reduce binary \
55
57
size. Use -ljre_emul to link the full Java runtime."
56
58
57
- for arg ; do
58
- case $arg in
59
+ while [ $# -gt 0 ] ; do
60
+ case $1 in
59
61
# Check whether linking is disabled by a -c, -S, or -E option.
60
62
-[cSE]) DO_LINK=" no" ;;
61
63
-fobjc-arc) USE_ARC=" yes" ;;
62
64
# 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 ;;
64
66
# Save sysroot path for later inspection.
65
- -isysroot) SYSROOT_PATH=" ${i #* =} " ;;
67
+ -isysroot) SYSROOT_PATH=" $2 " ; shift ;;
66
68
-ObjC) EMUL_LIB=" -ljre_core" ;;
67
69
esac
70
+ shift
68
71
done
69
72
70
73
if [[ " $USE_ARC " == " yes" ]]; then
71
74
CC_FLAGS=" $CC_FLAGS -fobjc-arc-exceptions"
72
75
fi
73
76
74
- if [[ $@ =~ .* -l(\ )* jre_emul\ .* ]]; then
77
+ if [[ $RAW_ARGS =~ .* -l(\ )* jre_emul\ .* ]]; then
75
78
EMUL_LIB=" "
76
79
fi
77
80
@@ -87,4 +90,4 @@ if [[ "$DO_LINK" == "yes" ]]; then
87
90
LINK_FLAGS=" ${EMUL_LIB} ${OTHER_LIBS} ${FRAMEWORKS} -L ${LIB_PATH} "
88
91
fi
89
92
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