Skip to content

Commit 022161f

Browse files
committed
add debug/release option
1 parent 1fc0b99 commit 022161f

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

build/ios/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ do
210210
fi
211211

212212
echo "build $arch for $lib"
213-
$top_dir/contrib/$build_script_name $is_simulator -a $arch -l $library_name
213+
$top_dir/contrib/$build_script_name $is_simulator -a $arch -l $library_name -m $build_mode
214214

215215
cp $top_dir/contrib/$install_library_path/$arch/lib/lib$archive_name.a $archive_name/prebuilt/lib$archive_name-$arch.a
216216
# FIXME: some archive names have some postfix in it.
@@ -246,8 +246,8 @@ do
246246
# TODO: add more header files decides here
247247

248248
echo "cleaning up"
249-
# rm -rf $top_dir/contrib/$install_library_path
250-
# rm -rf $top_dir/contrib/$build_library_path-$arch
249+
rm -rf $top_dir/contrib/$install_library_path
250+
rm -rf $top_dir/contrib/$build_library_path-$arch
251251
done
252252

253253
create_fat_library $archive_name

contrib/build_ios.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ SDK_VERSION=$(xcodebuild -showsdks | grep iphoneos | sort | tail -n 1 | awk '{pr
88
# FIXME: why min deploy target can't use 5.1.1
99
SDK_MIN=6.0
1010
ARCH=armv7
11+
BUILD_MODE=release
1112

1213
# TODO: configure to compile speficy 3rd party libraries
1314
OPTIONS=""
@@ -16,13 +17,14 @@ OPTIONS=""
1617
usage()
1718
{
1819
cat << EOF
19-
usage: $0 [-s] [-k sdk] [-a arch] [-l libname]
20+
usage: $0 [-s] [-k sdk] [-a arch] [-l libname] [-m biuld mode]
2021
2122
OPTIONS
2223
-k <sdk version> Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK_VERSION})
2324
-s Build for simulator
2425
-a <arch> Specify which arch to use (current: ${ARCH})
2526
-l <libname> Specify which static library to build
27+
-m <build mode> Specify release or debug mode(current: ${BUILD_MODE})
2628
EOF
2729
}
2830

@@ -44,7 +46,7 @@ info()
4446
}
4547

4648

47-
while getopts "hvsk:a:l:" OPTION
49+
while getopts "hvsk:a:l:m:" OPTION
4850
do
4951
case $OPTION in
5052
h)
@@ -66,6 +68,8 @@ do
6668
l)
6769
OPTIONS=--enable-$OPTARG
6870
;;
71+
m) BUILD_MODE=$OPTARG
72+
;;
6973
?)
7074
usage
7175
exit 1
@@ -98,10 +102,16 @@ info "Building cocos2d-x third party libraries for iOS"
98102

99103
if [ "$PLATFORM" = "Simulator" ]; then
100104
TARGET="${ARCH}-apple-darwin"
101-
OPTIM="-O3 -g"
102105
else
103106
TARGET="arm-apple-darwin"
104-
OPTIM="-O3 -g"
107+
fi
108+
109+
if [ $BUILD_MODE = "release" ]; then
110+
OPTIM="-O3 -DNDEBUG"
111+
fi
112+
113+
if [ $BUILD_MODE = "debug" ]; then
114+
OPTIM="-O0 -g -DDEBUG"
105115
fi
106116

107117
info "Using ${ARCH} with SDK version ${SDK_VERSION}"

contrib/build_ios_without_export.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ SDK_VERSION=$(xcodebuild -showsdks | grep iphoneos | sort | tail -n 1 | awk '{pr
88
# FIXME: why min deploy target can't use 5.1.1
99
SDK_MIN=6.0
1010
ARCH=armv7
11+
BUILD_MODe=release
1112

1213
# TODO: configure to compile speficy 3rd party libraries
1314
OPTIONS=""
@@ -16,13 +17,14 @@ OPTIONS=""
1617
usage()
1718
{
1819
cat << EOF
19-
usage: $0 [-s] [-k sdk] [-a arch] [-l libname]
20+
usage: $0 [-s] [-k sdk] [-a arch] [-l libname] [-m build mode]
2021
2122
OPTIONS
2223
-k <sdk version> Specify which sdk to use ('xcodebuild -showsdks', current: ${SDK_VERSION})
2324
-s Build for simulator
2425
-a <arch> Specify which arch to use (current: ${ARCH})
2526
-l <libname> Specify which static library to build
27+
-m <build mode> Specify release or debug mode(current: ${BUILD_MODE})
2628
EOF
2729
}
2830

@@ -44,7 +46,7 @@ info()
4446
}
4547

4648

47-
while getopts "hvsk:a:l:" OPTION
49+
while getopts "hvsk:a:l:m:" OPTION
4850
do
4951
case $OPTION in
5052
h)
@@ -66,6 +68,8 @@ do
6668
l)
6769
OPTIONS=--enable-$OPTARG
6870
;;
71+
m) BUILD_MODE=$OPTARG
72+
;;
6973
?)
7074
usage
7175
exit 1
@@ -98,10 +102,16 @@ info "Building cocos2d-x third party libraries for iOS"
98102

99103
if [ "$PLATFORM" = "Simulator" ]; then
100104
TARGET="${ARCH}-apple-darwin"
101-
OPTIM="-O3 -g"
102105
else
103106
TARGET="arm-apple-darwin"
104-
OPTIM="-O3 -g"
107+
fi
108+
109+
if [ $BUILD_MODE = "release" ]; then
110+
OPTIM="-O3"
111+
fi
112+
113+
if [ $BUILD_MODE = "debug" ]; then
114+
OPTIM="-O0 -g"
105115
fi
106116

107117
info "Using ${ARCH} with SDK version ${SDK_VERSION}"

contrib/src/main.mak

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ RANLIB=xcrun ranlib
109109
# EXTRA_CFLAGS += -isysroot $(MACOSX_SDK) -mmacosx-version-min=$(MIN_OSX_VERSION) -DMACOSX_DEPLOYMENT_TARGET=$(MIN_OSX_VERSION)
110110
# EXTRA_LDFLAGS += -Wl,-syslibroot,$(MACOSX_SDK) -mmacosx-version-min=$(MIN_OSX_VERSION) -isysroot $(MACOSX_SDK) -DMACOSX_DEPLOYMENT_TARGET=$(MIN_OSX_VERSION)
111111
ifeq ($(ARCH),x86_64)
112-
EXTRA_CFLAGS += -m64 -O3 -DNDEBUG
113-
EXTRA_LDFLAGS += -m64 -O3 -DNDEBUG
112+
EXTRA_CFLAGS += -m64
113+
EXTRA_LDFLAGS += -m64
114114
else
115-
EXTRA_CFLAGS += -m32 -O3 -DNDEBUG
116-
EXTRA_LDFLAGS += -m32 -O3 -DNDEBUG
115+
EXTRA_CFLAGS += -m32
116+
EXTRA_LDFLAGS += -m32
117117
endif
118118

119119
XCODE_FLAGS = -sdk macosx$(OSX_VERSION)
@@ -165,8 +165,8 @@ cppcheck = $(shell $(CC) $(CFLAGS) -E -dM - < /dev/null | grep -E $(1))
165165

166166
EXTRA_CFLAGS += -I$(PREFIX)/include
167167
CPPFLAGS := $(CPPFLAGS) $(EXTRA_CFLAGS)
168-
CFLAGS := $(CFLAGS) $(EXTRA_CFLAGS) -g
169-
CXXFLAGS := $(CXXFLAGS) $(EXTRA_CFLAGS) -g
168+
CFLAGS := $(CFLAGS) $(EXTRA_CFLAGS)
169+
CXXFLAGS := $(CXXFLAGS) $(EXTRA_CFLAGS)
170170
EXTRA_LDFLAGS += -L$(PREFIX)/lib
171171
LDFLAGS := $(LDFLAGS) $(EXTRA_LDFLAGS)
172172
# Do not export those! Use HOSTVARS.

0 commit comments

Comments
 (0)