Skip to content

Commit

Permalink
fix windows CI (#2410)
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin committed Mar 27, 2023
1 parent 15b114a commit dbd2f88
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 27 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/VS-CI-Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,26 @@ 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}}
run: |
$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}}
Expand Down
5 changes: 3 additions & 2 deletions choco-packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="winflexbison3"/>
<package id="sqlite"/>
<package id="cmake" version="3.21.3"/>
<!-- must use the same version of sqlite as in vcpkg.json -->
<package id="sqlite" version="3.40.1"/>
<package id="cmake" version="3.25.1"/>
</packages>
25 changes: 21 additions & 4 deletions cmake/SouffleTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}\\;$<SHELL_PATH:$<TARGET_FILE_DIR:souffle>>\\;${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)
Expand All @@ -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 "$<SHELL_PATH:$<TARGET_FILE_DIR:souffle>>\\;${escaped_path}"
)
endif()
endfunction()

function(SOUFFLE_COMPARE_CSV)
Expand Down
1 change: 0 additions & 1 deletion cmake/redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@
with open(args.err_file, "r") as f:
os.sys.stderr.write(f.read())


os.sys.exit(status.returncode)
17 changes: 12 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
$<TARGET_FILE_DIR:souffle>)
add_custom_command(TARGET souffle POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${SQLite3_LIBRARY}
$<TARGET_FILE_DIR:souffle>)
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
$<TARGET_FILE_DIR:souffle>)
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}
$<TARGET_FILE_DIR:souffle>)
endif ()

Expand Down
4 changes: 2 additions & 2 deletions src/MainDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void compileToBinary(
#endif
auto exit = execute(interpreter, argv);
if (!exit) throw std::invalid_argument(tfm::format("unable to execute tool <python3 %s>", 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 {
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/include/souffle/utility/SubProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ std::optional<detail::LinuxWaitStatus> 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
Expand Down Expand Up @@ -102,8 +102,8 @@ std::optional<detail::LinuxWaitStatus> 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
Expand All @@ -128,7 +128,7 @@ std::optional<detail::LinuxWaitStatus> 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;
Expand All @@ -152,13 +152,13 @@ std::optional<detail::LinuxWaitStatus> 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);
Expand Down
16 changes: 16 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit dbd2f88

Please sign in to comment.