From 7687ec1fa320d89b37a8c1143b2a22ac325f2da6 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Fri, 16 Apr 2021 14:43:34 +0000 Subject: [PATCH] Kokoro: Test that the _other.cc files also build Change-Id: I908b9250de839435c3b355fb89b0bb72ab821a54 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48043 Auto-Submit: Ben Clayton Kokoro: Kokoro Reviewed-by: Antonio Maiorano Commit-Queue: Antonio Maiorano --- CMakeLists.txt | 12 ++++++++++++ kokoro/linux/docker.sh | 5 +++++ src/CMakeLists.txt | 13 ++----------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 506755a3b8..f172afc32b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,7 @@ option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ON) option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON) option(TINT_BUILD_FUZZERS "Build fuzzers" OFF) option(TINT_BUILD_TESTS "Build tests" ${TINT_BUILD_TESTS_DEFAULT}) +option(TINT_BUILD_AS_OTHER_OS "Override OS detection to force building of *_other.cc files" OFF) option(TINT_ENABLE_MSAN "Enable memory sanitizer" OFF) option(TINT_ENABLE_ASAN "Enable address sanitizer" OFF) @@ -108,6 +109,17 @@ if (MSVC AND NOT COMPILER_IS_CLANG_CL) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") endif() +set(TINT_OS_CC_SUFFIX "other") +if (NOT TINT_BUILD_AS_OTHER_OS) + if(UNIX OR APPLE) + set(TINT_OS_CC_SUFFIX "posix") + set(TINT_OS_CC_SUFFIX "posix") + elseif(WIN32) + set(TINT_OS_CC_SUFFIX "windows") + set(TINT_OS_CC_SUFFIX "windows") + endif() +endif() + if(${TINT_BUILD_DOCS}) find_package(Doxygen) if(DOXYGEN_FOUND) diff --git a/kokoro/linux/docker.sh b/kokoro/linux/docker.sh index 48c842f340..3796c9ba5d 100755 --- a/kokoro/linux/docker.sh +++ b/kokoro/linux/docker.sh @@ -95,6 +95,11 @@ if [ "$BUILD_SYSTEM" == "cmake" ]; then ${SRC_DIR}/test/test-all.sh "${BUILD_DIR}/tint" hide_cmds + status "Checking _other.cc files also build" + show_cmds + cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS} -DTINT_BUILD_AS_OTHER_OS=1 + make --jobs=$(nproc) + hide_cmds else status "Unsupported build system: $BUILD_SYSTEM" exit 1 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3625fdba75..bc028a1778 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -519,11 +519,13 @@ if(${TINT_BUILD_TESTS}) type/type_manager_test.cc type/u32_type_test.cc type/vector_type_test.cc + utils/command_${TINT_OS_CC_SUFFIX}.cc utils/command_test.cc utils/command.h utils/get_or_create_test.cc utils/hash_test.cc utils/math_test.cc + utils/tmpfile_${TINT_OS_CC_SUFFIX}.cc utils/tmpfile_test.cc utils/tmpfile.h utils/unique_vector_test.cc @@ -531,17 +533,6 @@ if(${TINT_BUILD_TESTS}) writer/float_to_string_test.cc ) - if(UNIX OR APPLE) - list(APPEND TINT_TEST_SRCS utils/tmpfile_posix.cc) - list(APPEND TINT_TEST_SRCS utils/command_posix.cc) - elseif(WIN32) - list(APPEND TINT_TEST_SRCS utils/command_windows.cc) - list(APPEND TINT_TEST_SRCS utils/tmpfile_windows.cc) - else() - list(APPEND TINT_TEST_SRCS utils/command_other.cc) - list(APPEND TINT_TEST_SRCS utils/tmpfile_other.cc) - endif() - if(${TINT_BUILD_SPV_READER}) list(APPEND TINT_TEST_SRCS reader/spirv/enum_converter_test.cc