diff --git a/.gitignore b/.gitignore index 6ee7af9f4..f7a687c89 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ libs objs # Build outputs (TODO build to a subdir so we can exclude that instead) +/.simdjson-user-CMakeCache.txt /allparserscheckfile /allparsingcompetition /basictests @@ -124,10 +125,10 @@ objs /stringparsingcheck /submodules /ujdecode.o -/amalgamation_demo.cpp +/amalgamate_demo.cpp /simdjson.cpp /simdjson.h -/singleheader/amalgamation_demo +/singleheader/amalgamate_demo /singleheader/demo /tests/allparserscheckfile /tests/basictests diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b5826f22..f8c9d070f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ set(PROJECT_VERSION_MINOR 3) set(PROJECT_VERSION_PATCH 1) set(SIMDJSON_LIB_VERSION "0.3.1" CACHE STRING "simdjson library version") set(SIMDJSON_LIB_SOVERSION "1" CACHE STRING "simdjson library soversion") +set(SIMDJSON_GITHUB_REPOSITORY https://github.com/simdjson/simdjson) if(MSVC) option(SIMDJSON_BUILD_STATIC "Build a static library" ON) # turning it on disables the production of a dynamic library @@ -120,6 +121,23 @@ endfunction() export_private_library(simdjson-flags) +# +# ${SIMDJSON_USER_CMAKECACHE} contains the *user-specified* simdjson options so you can call cmake on +# another branch or repository with the same options. +# +# Not supported on Windows at present, because the only thing that uses it is checkperf, which we +# don't run on Windows. +# +if (NOT MSVC) + set(SIMDJSON_USER_CMAKECACHE ${CMAKE_CURRENT_BINARY_DIR}/.simdjson-user-CMakeCache.txt) + add_custom_command( + OUTPUT ${SIMDJSON_USER_CMAKECACHE} + COMMAND bash -c "grep SIMDJSON_ ${PROJECT_BINARY_DIR}/CMakeCache.txt | grep -v SIMDJSON_LIB_ > ${SIMDJSON_USER_CMAKECACHE}" + VERBATIM # Makes it not do weird escaping with the command + ) + add_custom_target(simdjson-user-cmakecache ALL DEPENDS ${SIMDJSON_USER_CMAKECACHE}) +endif() + # # Create the top level simdjson library (must be done at this level to use both src/ and include/ # directories) and tools diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 543a56520..647eb4a3e 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -41,6 +41,7 @@ if (NOT MSVC) CHECKPERF_REPOSITORY=https://github.com/simdjson/simdjson CHECKPERF_BRANCH=master CHECKPERF_DIR=${CMAKE_CURRENT_BINARY_DIR}/simdjson-master + CHECKPERF_CMAKECACHE=${SIMDJSON_USER_CMAKECACHE} bash ${CMAKE_CURRENT_SOURCE_DIR}/checkperf.sh ${PROJECT_SOURCE_DIR}/jsonexamples/twitter.json) - set_property(TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff) -endif() \ No newline at end of file + set_property(TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff ${SIMDJSON_USER_CMAKECACHE}) +endif() diff --git a/benchmark/checkperf.sh b/benchmark/checkperf.sh index f133c063e..0099d82bb 100644 --- a/benchmark/checkperf.sh +++ b/benchmark/checkperf.sh @@ -2,6 +2,8 @@ set -ex +set | grep CHECKPERF + if [ -z "$CHECKPERF_REPOSITORY" ]; then CHECKPERF_REPOSITORY=.; fi # Arguments: perfdiff.sh @@ -29,10 +31,18 @@ else fi echo "Building $CHECKPERF_DIR/parse ..." -make parse +if [ -n "$CHECKPERF_CMAKECACHE" ]; then + cp $CHECKPERF_CMAKECACHE $CHECKPERF_DIR/CMakeCache.txt + cmake -DSIMDJSON_GOOGLE_BENCHMARKS=OFF -DSIMDJSON_COMPETITION=OFF . + make parse + REFERENCE_PARSE=$CHECKPERF_DIR/benchmark/parse +else + make parse + REFERENCE_PARSE=$CHECKPERF_DIR/parse +fi popd # Run them and diff performance echo "Running perfdiff:" -echo ./perfdiff \"./parse -t $CHECKPERF_ARGS\" \"$CHECKPERF_DIR/parse -t $CHECKPERF_ARGS\" -./perfdiff "./parse -t $CHECKPERF_ARGS" "$CHECKPERF_DIR/parse -t $CHECKPERF_ARGS" +echo ./perfdiff \"./parse -t $CHECKPERF_ARGS\" \"$REFERENCE_PARSE -t $CHECKPERF_ARGS\" +./perfdiff "./parse -t $CHECKPERF_ARGS" "$REFERENCE_PARSE -t $CHECKPERF_ARGS"