From dbd2f88700542e0d8df6ed76273e78ef0802b678 Mon Sep 17 00:00:00 2001 From: Quentin Sabah Date: Mon, 27 Mar 2023 16:52:44 +0200 Subject: [PATCH] fix windows CI (#2410) --- .github/workflows/VS-CI-Tests.yml | 13 ++++++------ choco-packages.config | 5 +++-- cmake/SouffleTests.cmake | 25 ++++++++++++++++++++---- cmake/redirect.py | 1 - src/CMakeLists.txt | 17 +++++++++++----- src/MainDriver.cpp | 4 ++-- src/include/souffle/utility/SubProcess.h | 12 ++++++------ vcpkg.json | 16 +++++++++++++++ 8 files changed, 66 insertions(+), 27 deletions(-) create mode 100644 vcpkg.json diff --git a/.github/workflows/VS-CI-Tests.yml b/.github/workflows/VS-CI-Tests.yml index 67f367e1ee5..f392e830445 100644 --- a/.github/workflows/VS-CI-Tests.yml +++ b/.github/workflows/VS-CI-Tests.yml @@ -29,19 +29,18 @@ jobs: - name: Binary Dependencies (Chocolatey) run: | choco config set cacheLocation ${{ env.CHOCO_CACHE_DIR }} - choco install choco-packages.config --no-progress --installargs 'ADD_CMAKE_TO_PATH=""System""' + choco install choco-packages.config --no-progress --installargs 'ADD_CMAKE_TO_PATH=System' # Use vcpkg to install devel library dependencies. - name: Library Dependencies (vcpkg) - uses: lukka/run-vcpkg@v7 + uses: lukka/run-vcpkg@v10 with: - vcpkgGitCommitId: '94ce0dab56f4d8ba6bd631ba59ed682b02d45c46' - vcpkgTriplet: x64-windows - vcpkgArguments: 'sqlite3 zlib libffi' + vcpkgGitCommitId: 'a7b6122f6b6504d16d96117336a0562693579933' - name: Create Build Directory working-directory: ${{github.workspace}} - run: mkdir build + run: | + mkdir build - name: Configure Build working-directory: ${{github.workspace}} @@ -49,7 +48,7 @@ jobs: $env:ChocolateyInstall = Convert-Path "$((Get-Command choco).Path)\..\.." Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1" refreshenv - cmake -S . -B build -G "Visual Studio 16 2019" -A x64 "-DCMAKE_TOOLCHAIN_FILE=${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=/bigobj -DSOUFFLE_DOMAIN_64BIT=ON -DCMAKE_FIND_LIBRARY_PREFIXES=";lib" -DCMAKE_FIND_LIBRARY_SUFFIXES=".lib;.dll" -DSOUFFLE_USE_CURSES=OFF -DSOUFFLE_USE_ZLIB=ON -DCMAKE_FIND_DEBUG_MODE=FALSE -DSOUFFLE_BASH_COMPLETION=OFF + cmake -S . -B build -G "Visual Studio 16 2019" -A x64 "-DCMAKE_TOOLCHAIN_FILE=${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=/bigobj -DSOUFFLE_DOMAIN_64BIT=ON -DCMAKE_FIND_LIBRARY_PREFIXES=";lib" -DCMAKE_FIND_LIBRARY_SUFFIXES=".lib;.dll" -DSOUFFLE_USE_CURSES=OFF -DSOUFFLE_USE_ZLIB=ON -DSOUFFLE_USE_SQLITE=ON -DCMAKE_FIND_DEBUG_MODE=FALSE -DSOUFFLE_BASH_COMPLETION=OFF - name: Build working-directory: ${{github.workspace}} diff --git a/choco-packages.config b/choco-packages.config index aebe6bf4350..9c8d432243f 100644 --- a/choco-packages.config +++ b/choco-packages.config @@ -1,6 +1,7 @@ - - + + + diff --git a/cmake/SouffleTests.cmake b/cmake/SouffleTests.cmake index 2782ed2c6ce..2162f9b7fbe 100644 --- a/cmake/SouffleTests.cmake +++ b/cmake/SouffleTests.cmake @@ -63,6 +63,14 @@ function(SOUFFLE_RUN_INTEGRATION_TEST) FIXTURES_SETUP ${PARAM_FIXTURE_NAME}_run_souffle FIXTURES_REQUIRED ${PARAM_FIXTURE_NAME}_setup) + if (WIN32) + string(REPLACE ";" "\\;" escaped_path "$ENV{PATH}") + cmake_path(GET CMAKE_CXX_COMPILER PARENT_PATH CL_DIR) + set_tests_properties(${PARAM_QUALIFIED_TEST_NAME}_run_souffle PROPERTIES + ENVIRONMENT "PATH=${CL_DIR}\\;$>\\;${escaped_path}" + ) + endif() + if (PARAM_NEGATIVE) #Mark the souffle run as "will fail" for negative tests set_tests_properties(${PARAM_QUALIFIED_TEST_NAME}_run_souffle PROPERTIES WILL_FAIL TRUE) @@ -83,12 +91,21 @@ function(SOUFFLE_COMPARE_STD_OUTPUTS) COMMAND ${Python3_EXECUTABLE} "${PROJECT_SOURCE_DIR}/cmake/check_std_outputs.py" "${PARAM_TEST_NAME}" - "${PARAM_EXTRA_DATA}") + "${PARAM_EXTRA_DATA}" + ) set_tests_properties(${PARAM_QUALIFIED_TEST_NAME}_compare_std_outputs PROPERTIES - WORKING_DIRECTORY "${PARAM_OUTPUT_DIR}" - LABELS "${PARAM_TEST_LABELS}" - FIXTURES_REQUIRED ${PARAM_RUN_AFTER_FIXTURE}) + WORKING_DIRECTORY "${PARAM_OUTPUT_DIR}" + LABELS "${PARAM_TEST_LABELS}" + FIXTURES_REQUIRED ${PARAM_RUN_AFTER_FIXTURE} + ) + + if (WIN32) + string(REPLACE ";" "\\;" escaped_path "$ENV{PATH}") + set_tests_properties(${PARAM_QUALIFIED_TEST_NAME}_compare_std_outputs PROPERTIES + ENVIRONMENT "$>\\;${escaped_path}" + ) + endif() endfunction() function(SOUFFLE_COMPARE_CSV) diff --git a/cmake/redirect.py b/cmake/redirect.py index 7f833ddabf0..6e83a1dc76b 100644 --- a/cmake/redirect.py +++ b/cmake/redirect.py @@ -45,5 +45,4 @@ with open(args.err_file, "r") as f: os.sys.stderr.write(f.read()) - os.sys.exit(status.returncode) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 15761d4a67a..4576d1bb699 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -334,16 +334,23 @@ endif() # be immediately found by the operating system. if (SOUFFLE_USE_SQLITE) -add_custom_command(TARGET souffle POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${SQLite3_LIBRARY} ${ZLIB_LIBRARY_RELEASE} - $) + add_custom_command(TARGET souffle POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${SQLite3_LIBRARY} + $) + if (WIN32) + cmake_path(GET SQLite3_LIBRARY PARENT_PATH SQLite3_LIBRARY_DIR) + add_custom_command(TARGET souffle POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${SQLite3_LIBRARY_DIR}/../bin/sqlite3.dll + $) + endif () endif () if (SOUFFLE_USE_ZLIB) add_custom_command(TARGET souffle POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${SQLite3_LIBRARY} ${ZLIB_LIBRARY_RELEASE} + ${ZLIB_LIBRARY_RELEASE} $) endif () diff --git a/src/MainDriver.cpp b/src/MainDriver.cpp index bb8a1e51ba2..a01ef571553 100644 --- a/src/MainDriver.cpp +++ b/src/MainDriver.cpp @@ -219,7 +219,7 @@ void compileToBinary( #endif auto exit = execute(interpreter, argv); if (!exit) throw std::invalid_argument(tfm::format("unable to execute tool ", command)); - if (exit != 0) throw std::invalid_argument("failed to compile C++ sources"); + if (*exit != 0) throw std::invalid_argument("failed to compile C++ sources"); } class InputProvider { @@ -356,7 +356,7 @@ class PreprocInput : public InputProvider { std::cerr << "Failed to close pre-processor pipe\n"; return false; } else if (Status != 0) { - std::cerr << "Pre-processors command failed with code " << Status << ": '" << Cmd.str() << "'\n"; + std::cerr << "Pre-processor command failed with code " << Status << ": '" << Cmd.str() << "'\n"; return false; } return true; diff --git a/src/include/souffle/utility/SubProcess.h b/src/include/souffle/utility/SubProcess.h index c455cd8abad..93b4eb76190 100644 --- a/src/include/souffle/utility/SubProcess.h +++ b/src/include/souffle/utility/SubProcess.h @@ -70,7 +70,7 @@ std::optional execute( auto pid = ::fork(); switch (pid) { - case -1: return {}; // unable to fork. likely hit a resource limit of some kind. + case -1: return std::nullopt; // unable to fork. likely hit a resource limit of some kind. case 0: { // child // thankfully we're a fork. we can trash this proc's `::environ` w/o reprocussions @@ -102,8 +102,8 @@ std::optional execute( switch (WEXITSTATUS(status)) { default: return WEXITSTATUS(status); - case EC::cannot_execute: // FALL THRU: command_not_found - case EC::command_not_found: return {}; // fork couldn't execute the program + case EC::cannot_execute: // FALL THRU: command_not_found + case EC::command_not_found: return std::nullopt; // fork couldn't execute the program } } // what should be returned on signal? Treat as error @@ -128,7 +128,7 @@ std::optional execute( int64_t Found = (int64_t)FindExecutableW(program_w.c_str(), nullptr, FoundPath); if (Found <= 32) { std::cerr << "Cannot find executable '" << program << "'.\n"; - return {}; + return std::nullopt; } std::wstringstream args_w; @@ -152,13 +152,13 @@ std::optional execute( if (!CreateProcessW(FoundPath, args_w.str().data(), NULL, NULL, FALSE, 0, /*envir.data()*/ nullptr, NULL, &si, &pi)) { - return {}; + return std::nullopt; } WaitForSingleObject(pi.hProcess, INFINITE); if (!GetExitCodeProcess(pi.hProcess, &exit_code)) { - return {}; + return std::nullopt; } CloseHandle(pi.hProcess); diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 00000000000..eeb53f816c3 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json", + "name": "souffle", + "dependencies": [ + "zlib", + "libffi", + "sqlite3" + ], + "overrides": [ + { + "name": "sqlite3", + "version": "3.40.1" + } + ], + "builtin-baseline": "a7b6122f6b6504d16d96117336a0562693579933" +}