diff --git a/.gitignore b/.gitignore index e097bab3..a965a99b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ compile_commands.json /external/spirv-headers /external/effcee /external/re2 +/external/protobuf /out /TAGS /third_party/llvm-build/ diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index d1251c24..3190f4b0 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -102,3 +102,15 @@ if (NOT ${SPIRV_SKIP_TESTS}) endif() endif() endif() + +if(SPIRV_BUILD_FUZZER) + set(PROTOBUF_DIR ${CMAKE_CURRENT_SOURCE_DIR}/protobuf/cmake) + set(protobuf_BUILD_TESTS OFF CACHE BOOL "Disable protobuf tests") + set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Do not build protobuf static runtime") + if (IS_DIRECTORY ${PROTOBUF_DIR}) + add_subdirectory(${PROTOBUF_DIR} EXCLUDE_FROM_ALL) + else() + message(FATAL_ERROR + "protobuf not found - please checkout a copy under external/.") + endif() +endif(SPIRV_BUILD_FUZZER) diff --git a/kokoro/scripts/linux/build.sh b/kokoro/scripts/linux/build.sh index e89d2eae..f7b0fe14 100644 --- a/kokoro/scripts/linux/build.sh +++ b/kokoro/scripts/linux/build.sh @@ -71,13 +71,18 @@ git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv git clone --depth=1 https://github.com/google/googletest external/googletest git clone --depth=1 https://github.com/google/effcee external/effcee git clone --depth=1 https://github.com/google/re2 external/re2 +git clone --depth=1 https://github.com/protocolbuffers/protobuf external/protobuf +pushd external/protobuf +git fetch --all --tags --prune +git checkout v3.7.1 +popd mkdir build && cd $SRC/build # Invoke the build. BUILD_SHA=${KOKORO_GITHUB_COMMIT:-$KOKORO_GITHUB_PULL_REQUEST_COMMIT} echo $(date): Starting build... -cmake -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -GNinja -DCMAKE_INSTALL_PREFIX=$KOKORO_ARTIFACTS_DIR/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DRE2_BUILD_TESTING=OFF $ADDITIONAL_CMAKE_FLAGS $CMAKE_C_CXX_COMPILER .. +cmake -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 -GNinja -DCMAKE_INSTALL_PREFIX=$KOKORO_ARTIFACTS_DIR/install -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DRE2_BUILD_TESTING=OFF -DSPIRV_BUILD_FUZZER=ON $ADDITIONAL_CMAKE_FLAGS $CMAKE_C_CXX_COMPILER .. echo $(date): Build everything... ninja diff --git a/kokoro/scripts/macos/build.sh b/kokoro/scripts/macos/build.sh index 98e63668..5a3af43b 100644 --- a/kokoro/scripts/macos/build.sh +++ b/kokoro/scripts/macos/build.sh @@ -35,6 +35,11 @@ git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv git clone --depth=1 https://github.com/google/googletest external/googletest git clone --depth=1 https://github.com/google/effcee external/effcee git clone --depth=1 https://github.com/google/re2 external/re2 +git clone --depth=1 https://github.com/protocolbuffers/protobuf external/protobuf +pushd external/protobuf +git fetch --all --tags --prune +git checkout v3.7.1 +popd mkdir build && cd $SRC/build @@ -49,6 +54,7 @@ cmake \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ + -DSPIRV_BUILD_FUZZER=ON \ .. echo $(date): Build everything... diff --git a/kokoro/scripts/windows/build.bat b/kokoro/scripts/windows/build.bat index 0532118f..ef2470d8 100644 --- a/kokoro/scripts/windows/build.bat +++ b/kokoro/scripts/windows/build.bat @@ -29,6 +29,11 @@ git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv git clone --depth=1 https://github.com/google/googletest external/googletest git clone --depth=1 https://github.com/google/effcee external/effcee git clone --depth=1 https://github.com/google/re2 external/re2 +git clone --depth=1 https://github.com/protocolbuffers/protobuf external/protobuf +pushd external\protobuf +git fetch --all --tags --prune +git checkout v3.7.1 +popd :: ######################################### :: set up msvc build env @@ -65,6 +70,11 @@ if %VS_VERSION% == 2013 ( set CMAKE_FLAGS=%CMAKE_FLAGS% -DSPIRV_SKIP_TESTS=ON ) +:: Skip building spirv-fuzz for VS2013; it relies on protobufs which VS2013 cannot handle. +if %VS_VERSION% NEQ 2013 ( + set CMAKE_FLAGS=%CMAKE_FLAGS% -DSPIRV_BUILD_FUZZER=ON +) + cmake %CMAKE_FLAGS% .. if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%