diff --git a/.gitignore b/.gitignore index 07bcf1cc834..da133ae06dc 100644 --- a/.gitignore +++ b/.gitignore @@ -96,7 +96,6 @@ tags *.dylib Makefile pal/src/config.h -DbgController.js.h lib/wabt/built/config.h # Generated by other tools diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b9376613bc..8e9a67637b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,15 @@ project (CHAKRACORE) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g") +# Disable exepected CMake workflow +option(CHAKRACORE_BUILD_SH "Use build.sh") + +if(NOT CHAKRACORE_BUILD_SH) + option(INTL_ICU "Enable Intl" ON) + option(EMBED_ICU "Build ICU within ChakraCore build" OFF) + set(ICU_INCLUDE_PATH "" CACHE STRING "libicu iclude path") +endif(NOT CHAKRACORE_BUILD_SH) + # Keep CMake from caching static/shared library # option. Otherwise, CMake fails to update cached # references @@ -27,7 +36,7 @@ if(LIBS_ONLY_BUILD_SH) set(CC_LIBS_ONLY_BUILD 1) endif() -if(CC_USES_SYSTEM_ARCH_SH) +if(CC_USES_SYSTEM_ARCH_SH OR NOT CHAKRACORE_BUILD_SH) if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") set(CC_TARGETS_AMD64_SH 1) elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l") @@ -46,7 +55,7 @@ elseif(CC_TARGETS_X86_SH) set(CC_TARGETS_X86 1) set(CMAKE_SYSTEM_PROCESSOR "i386") else() - message(FATAL_ERROR "Couldn't detect target processor, try `--arch` argument with build.sh") + message(FATAL_ERROR "Unsupported target processor: ${CMAKE_SYSTEM_PROCESSOR}") endif() unset(CC_TARGETS_ARM_SH CACHE) @@ -128,13 +137,15 @@ if(SYSTEM_ICU_SH) unset(SYSTEM_ICU_SH CACHE) endif() -if(INTL_ICU_SH) - unset(INTL_ICU_SH CACHE) - set(INTL_ICU 1) -else() - unset(INTL_ICU_SH CACHE) - set(INTL_ICU 0) -endif() +if(CHAKRACORE_BUILD_SH) + if(INTL_ICU_SH) + unset(INTL_ICU_SH CACHE) + set(INTL_ICU 1) + else() + unset(INTL_ICU_SH CACHE) + set(INTL_ICU 0) + endif() +endif(CHAKRACORE_BUILD_SH) if(EMBED_ICU_SH) set(EMBED_ICU 1) @@ -296,7 +307,7 @@ elseif(CC_TARGET_OS_OSX) endif() endif() else() - message(FATAL_ERROR "This OS is not supported") + message(FATAL_ERROR "Unsupported OS: ${CMAKE_SYSTEM_NAME}") endif() if (CMAKE_CXX_COMPILER_ID STREQUAL AppleClang @@ -562,3 +573,5 @@ endif() add_subdirectory (lib) add_subdirectory (bin) + +add_subdirectory(test) diff --git a/bin/ch/CMakeLists.txt b/bin/ch/CMakeLists.txt index a8ca77953d5..86b0b6af13d 100644 --- a/bin/ch/CMakeLists.txt +++ b/bin/ch/CMakeLists.txt @@ -1,3 +1,9 @@ +add_custom_target(dbg_controller_h + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/jstoc.py ${CMAKE_CURRENT_SOURCE_DIR}/DbgController.js controllerScript + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/jstoc.py ${CMAKE_CURRENT_SOURCE_DIR}/DbgController.js + ) + set(ch_source_files ch.cpp ChakraRtInterface.cpp @@ -17,6 +23,8 @@ endif() add_executable (ch ${ch_source_files}) +add_dependencies(ch dbg_controller_h) + set_target_properties(ch PROPERTIES POSITION_INDEPENDENT_CODE True @@ -30,6 +38,7 @@ endif() target_include_directories (ch PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ../ChakraCore ../../lib/Common ../../lib/Jsrt diff --git a/bin/ch/jstoc.py b/bin/ch/jstoc.py index e0be592fb18..a9618054bc9 100755 --- a/bin/ch/jstoc.py +++ b/bin/ch/jstoc.py @@ -23,7 +23,7 @@ def convert(): if os.path.isfile(js_file_name) == False: print_usage() - h_file_name = js_file_name + '.h' + h_file_name = os.path.basename(js_file_name) + '.h' js_file_time = os.path.getmtime(js_file_name) h_file_time = 0 diff --git a/build.sh b/build.sh index efefa7de35b..c9b2686a384 100755 --- a/build.sh +++ b/build.sh @@ -608,13 +608,6 @@ if [[ $WB_CHECK || $WB_ANALYZE ]]; then fi fi -# prepare DbgController.js.h -CH_DIR="${CHAKRACORE_DIR}/bin/ch" -"${CH_DIR}/jstoc.py" "${CH_DIR}/DbgController.js" controllerScript -if [[ $? != 0 ]]; then - exit 1 -fi - if [ ! -d "$BUILD_DIRECTORY" ]; then SAFE_RUN `mkdir -p $BUILD_DIRECTORY` fi @@ -634,12 +627,13 @@ else echo "Compile Target : System Default" fi -echo Generating $BUILD_TYPE makefiles +echo Generating $BUILD_TYPE build echo $EXTRA_DEFINES -cmake $CMAKE_GEN $CC_PREFIX $CMAKE_ICU $LTO $LTTNG $STATIC_LIBRARY $ARCH $TARGET_OS \ - $ENABLE_CC_XPLAT_TRACE $EXTRA_DEFINES -DCMAKE_BUILD_TYPE=$BUILD_TYPE $SANITIZE $NO_JIT $CMAKE_INTL \ - $WITHOUT_FEATURES $WB_FLAG $WB_ARGS $CMAKE_EXPORT_COMPILE_COMMANDS $LIBS_ONLY_BUILD\ - $VALGRIND $BUILD_RELATIVE_DIRECTORY $CCACHE_NAME +cmake $CMAKE_GEN -DCHAKRACORE_BUILD_SH=ON $CC_PREFIX $CMAKE_ICU $LTO $LTTNG \ + $STATIC_LIBRARY $ARCH $TARGET_OS \ $ENABLE_CC_XPLAT_TRACE $EXTRA_DEFINES \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE $SANITIZE $NO_JIT $CMAKE_INTL \ + $WITHOUT_FEATURES $WB_FLAG $WB_ARGS $CMAKE_EXPORT_COMPILE_COMMANDS \ + $LIBS_ONLY_BUILD $VALGRIND $BUILD_RELATIVE_DIRECTORY $CCACHE_NAME _RET=$? if [[ $? == 0 ]]; then diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000000..e634e3914d3 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,13 @@ +if (CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) + set(TEST_BUILD_TYPE --test) +elseif (CMAKE_BUILD_TYPE STREQUAL Debug) + set(TEST_BUILD_TYPE --debug) +endif () + +add_custom_target(check + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/runtests.py ${TEST_BUILD_TYPE} --binary ${CMAKE_BINARY_DIR}/ch --logfile ${CMAKE_BINARY_DIR}/check.log + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + USES_TERMINAL + DEPENDS ch + ) +