Skip to content

Commit cd63b95

Browse files
ppenzinrhuanjl
authored andcommitted
[CMake] default build type and test targets
Set default CMake build type to "debug" for standalone builds (in line with VS, but in contrast to build.sh's "release"). Drive-by: Make DISABLE_JIT official CMake option. Split testing into multiple targets. Add test subtargets, one per test "kind", and declare them as dependencies for top level test target. This has the advantage of running individual checks in isolation and better error reporting (only the failing command will be returned). Convert add CMake warning about native tests in addition to build-time message. If ICU is not installed, warn that native tests are going to be disabled during CMake run.
1 parent d882562 commit cd63b95

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g")
77
option(CHAKRACORE_BUILD_SH "Use build.sh")
88

99
if(NOT CHAKRACORE_BUILD_SH)
10+
option(DISABLE_JIT "Disable JIT compilation" OFF)
1011
option(INTL_ICU "Enable Intl" ON)
1112
option(EMBED_ICU "Build ICU within ChakraCore build" OFF)
1213
set(ICU_INCLUDE_PATH "" CACHE STRING "libicu iclude path")
14+
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
15+
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type" FORCE)
16+
endif (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
1317
else(NOT CHAKRACORE_BUILD_SH)
1418

1519
# Keep CMake from caching static/shared library

test/CMakeLists.txt

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,52 @@ else ()
1717
set(VARIANT --noJit)
1818
endif()
1919

20+
# Target to run all tests
21+
add_custom_target(check)
22+
2023
if (CMAKE_BUILD_TYPE STREQUAL Release)
21-
set(TEST_SUITE echo "Running Hello World test" && ${CMAKE_BINARY_DIR}/ch ${CMAKE_CURRENT_SOURCE_DIR}/Basics/hello.js)
24+
add_custom_target(smoke-check
25+
COMMAND echo "Running Hello World test"
26+
COMMAND ${CMAKE_BINARY_DIR}/ch ${CMAKE_CURRENT_SOURCE_DIR}/Basics/hello.js
27+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
28+
USES_TERMINAL
29+
DEPENDS ch
30+
)
31+
add_dependencies(check smoke-check)
2232
else()
23-
set(BYTE_CODE_CHECK ${CMAKE_CURRENT_SOURCE_DIR}/../tools/regenByteCode.py ${VARIANT} --verify --binary=${CMAKE_BINARY_DIR}/ch)
24-
set(TEST_SUITE ${CMAKE_CURRENT_SOURCE_DIR}/runtests.py ${TEST_BUILD_TYPE} ${TEST_ICU} ${TEST_VARIANT} --binary=${CMAKE_BINARY_DIR}/ch)
33+
add_custom_target(bytecode-check
34+
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../tools/regenByteCode.py ${VARIANT} --verify --binary=${CMAKE_BINARY_DIR}/ch
35+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
36+
USES_TERMINAL
37+
DEPENDS ch
38+
)
39+
add_custom_target(regression-check
40+
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/runtests.py ${TEST_BUILD_TYPE} ${TEST_ICU} ${TEST_VARIANT} --binary=${CMAKE_BINARY_DIR}/ch
41+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
42+
USES_TERMINAL
43+
DEPENDS ch
44+
)
45+
add_dependencies(check bytecode-check regression-check)
2546
endif()
2647

2748
if (NOT NO_ICU AND NOT EMBED_ICU)
28-
set(NATIVE_TEST cd ${CMAKE_CURRENT_SOURCE_DIR}/native-tests && ./test_native.sh ${CMAKE_BINARY_DIR}/ch ${CMAKE_BUILD_TYPE} ${CMAKE_C_COMPILER} ${CMAKE_CXX_COMPILER} ${CMAKE_SOURCE_DIR})
49+
add_custom_target(native-check
50+
COMMAND ./test_native.sh ${CMAKE_BINARY_DIR}/ch ${CMAKE_BUILD_TYPE} ${CMAKE_C_COMPILER} ${CMAKE_CXX_COMPILER} ${CMAKE_SOURCE_DIR}
51+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/native-tests
52+
USES_TERMINAL
53+
DEPENDS ch
54+
)
55+
add_dependencies(check native-check)
2956
else()
30-
set(NATIVE_TEST echo "Native tests NOT RUN, they require ICU to be installed not embedded. NO_ICU = ${NO_ICU} EMBED_ICU = ${EMBED_ICU}")
57+
set(ICU_MESSAGE "Native tests are DISABLED, as they require ICU to be installed, and not embedded. NO_ICU = ${NO_ICU} EMBED_ICU = ${EMBED_ICU}")
58+
message(WARNING ${ICU_MESSAGE})
59+
add_custom_target(warn-icu-tests
60+
COMMAND echo "${ICU_MESSAGE}"
61+
USES_TERMINAL
62+
)
63+
add_dependencies(check warn-icu-tests)
3164
endif()
3265

33-
add_custom_target(check
34-
COMMAND ${BYTE_CODE_CHECK}
35-
COMMAND ${TEST_SUITE}
36-
COMMAND ${NATIVE_TEST}
37-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
38-
USES_TERMINAL
39-
DEPENDS ch
40-
)
41-
4266
if (NOT STATIC_LIBRARY)
4367
add_dependencies(check ChakraCore)
4468
endif()

0 commit comments

Comments
 (0)