From 89b6a4a988b3b66776057992f043b8270677c4e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mika=20Isoj=C3=A4rvi?= Date: Tue, 17 Mar 2015 14:39:57 -0700 Subject: [PATCH] Add cmake build type ReleaseWithAsserts. Add new build type to cmake files that produces release build, but sets DE_DEBUG. Bug: 19732544 Change-Id: I03a2b44fdcba0a04272a63459cc29f51cb4aa3fe --- android/scripts/build.py | 4 +++- framework/delibs/cmake/Defs.cmake | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/android/scripts/build.py b/android/scripts/build.py index 93f33f5..c7342f2 100644 --- a/android/scripts/build.py +++ b/android/scripts/build.py @@ -189,9 +189,11 @@ def dumpConfig (): print " " if __name__ == "__main__": + nativeBuildTypes = ['Release', 'Debug', 'MinSizeRel', 'RelWithAsserts', 'RelWithDebInfo'] + parser = argparse.ArgumentParser() parser.add_argument('--is-release', dest='isRelease', type=bool, default=False, help="Build android project in release mode.") - parser.add_argument('--native-build-type', dest='nativeBuildType', default="Release", help="Build type passed cmake when building native code.") + parser.add_argument('--native-build-type', dest='nativeBuildType', default="RelWithAsserts", choices=nativeBuildTypes, help="Build type passed cmake when building native code.") parser.add_argument('--build-root', dest='buildRoot', default=common.ANDROID_DIR, help="Root directory for storing build results.") parser.add_argument('--dump-config', dest='dumpConfig', action='store_true', help="Print out all configurations variables") parser.add_argument('--java-api', dest='javaApi', default=common.ANDROID_JAVA_API, help="Set the API signature for the java build.") diff --git a/framework/delibs/cmake/Defs.cmake b/framework/delibs/cmake/Defs.cmake index f34bba5..04ad5d4 100644 --- a/framework/delibs/cmake/Defs.cmake +++ b/framework/delibs/cmake/Defs.cmake @@ -39,6 +39,22 @@ macro (DE_MAKE_ENV_BOOL BASE VALUE) endif () endmacro () +# Add build type release with asserts +set(CMAKE_CXX_FLAGS_RELEASEWITHASSERTS ${CMAKE_CXX_FLAGS_RELEASE}) +set(CMAKE_C_FLAGS_RELEASEWITHASSERTS ${CMAKE_C_FLAGS_RELEASE}) +set(CMAKE_EXE_LINKER_FLAGS_RELEASEWITHASSERTS ${CMAKE_EXE_LINKER_FLAGS_RELEASE}) +set(CMAKE_SHARED_LINKER_FLAGS_RELEASEWITHASSERTS ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}) + +# cmake doesn't validate build type. +if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" + AND NOT CMAKE_BUILD_TYPE STREQUAL "Release" + AND NOT CMAKE_BUILD_TYPE STREQUAL "RelWithAsserts" + AND NOT CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" + AND NOT CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") + + message(FATAL_ERROR "Unknown build type ${CMAKE_BUILD_TYPE} available build types Debug, Release, RelWithAsserts, RelWithDebInfo and MinSizeRel") +endif() + # Os detection if (NOT DEFINED DE_OS) if (WIN32) @@ -133,7 +149,7 @@ endif () # Debug definitions if (NOT DEFINED DE_DEBUG) - if (CMAKE_BUILD_TYPE STREQUAL "Debug") + if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithAsserts") set(DE_DEBUG 1) else () set(DE_DEBUG 0) -- 2.7.4