From 37ef3457204cb4acbefd3f6249e37f7309302400 Mon Sep 17 00:00:00 2001 From: Julien Lamy Date: Sun, 14 Apr 2024 17:47:41 +0200 Subject: [PATCH] Add Windows CI --- .ci/build/build.py | 10 ++++++++-- .ci/build/conda.py | 3 ++- .ci/build/post_build.py | 31 +++++++++++++++++-------------- .github/workflows/build.yml | 3 ++- src/CMakeLists.txt | 1 - src/odil/asio.cpp | 10 ---------- tests/CMakeLists.txt | 1 - tests/data/dcmqrscp.config | 6 +++--- wrappers/python/CMakeLists.txt | 4 ++++ 9 files changed, 36 insertions(+), 33 deletions(-) delete mode 100644 src/odil/asio.cpp diff --git a/.ci/build/build.py b/.ci/build/build.py index 04ea53ca..3ad72674 100644 --- a/.ci/build/build.py +++ b/.ci/build/build.py @@ -15,11 +15,17 @@ subprocess.check_call( [ "cmake", - "-G", "Ninja", + # NOTE: if Ninja is used as a builder, compiler chain defaults to gcc on + # Windows + *(["-G", "Ninja"] if os.name != "nt" else []), "-DPython_EXECUTABLE={}".format(sys.executable), "-DCMAKE_INSTALL_PREFIX={}".format(install_dir), *([os.environ["CMAKE_OPTIONS"]] if "CMAKE_OPTIONS" in os.environ else []), workspace], cwd=build_dir) -subprocess.check_call(["ninja", "install"], cwd=build_dir) +subprocess.check_call( + [ + "cmake", "--build", ".", "--target", "install", "--config", "Release", + "--parallel"], + cwd=build_dir) diff --git a/.ci/build/conda.py b/.ci/build/conda.py index 6bf5d62f..a8548fa7 100644 --- a/.ci/build/conda.py +++ b/.ci/build/conda.py @@ -1,7 +1,8 @@ +import os import subprocess import sys -conda = sys.argv[1] if len(sys.argv) >= 2 else "conda" +conda = sys.argv[1] if len(sys.argv) >= 2 else os.environ.get("MAMBA_EXE", "conda") subprocess.check_call([ conda, "install", "--yes", "-c", "conda-forge", diff --git a/.ci/build/post_build.py b/.ci/build/post_build.py index e81bde75..d821d490 100644 --- a/.ci/build/post_build.py +++ b/.ci/build/post_build.py @@ -18,29 +18,32 @@ python_tests_dir = os.path.join(workspace, "tests", "wrappers") subprocess.check_call( - ["dcmqridx", "./", "dataset.dcm"], - cwd=os.path.join(workspace, "tests/data")) + ["dcmqridx", ".", "dataset.dcm"], + cwd=os.path.join(workspace, "tests", "data")) server = subprocess.Popen( - ["dcmqrscp", "-ll", "fatal", "-c", "dcmqrscp.config", "11112"], - cwd=os.path.join(workspace, "tests/data")) + ["dcmqrscp", "-ll", "warning", "-c", "dcmqrscp.config", "11112"], + cwd=os.path.join(workspace, "tests", "data")) time.sleep(1) # Set-up environment: test-related variables +def prepend_env_path(item, paths): + return f"{item}{os.pathsep}{paths}" if paths else item environment = os.environ.copy() environment["ODIL_OWN_AET"] = "LOCAL" environment["ODIL_PEER_HOST_NAME"] = "127.0.0.1" environment["ODIL_PEER_PORT"] = "11112" environment["ODIL_PEER_AET"] = "REMOTE" -environment["PATH"] = os.pathsep.join([ - *environment["PATH"].split(os.pathsep), - os.path.join(workspace, "tests/tools")]) +environment["PATH"] = prepend_env_path( + os.path.join(workspace, "tests", "tools"), environment.get("PATH")) # Run C++ and Python tests even if the former fails, return non-zero if any # failed. return_code = 0 -# No extra environment needed for C++ part +# No extra environment needed for C++ part except for Windows +if os.name == "nt": + environment["PATH"] = prepend_env_path(bin_dir, environment.get("PATH")) return_code = max( return_code, subprocess.call( @@ -49,10 +52,9 @@ # Python tests require lib configuration for name in ["DYLD_LIBRARY_PATH", "LD_LIBRARY_PATH"]: - environment[name] = os.pathsep.join([ - *environment.get(name, "").split(os.pathsep), lib_dir]) -environment["PYTHONPATH"] = os.pathsep.join([ - *environment.get("PYTHONPATH", "").split(os.pathsep), python_lib_dir]) + environment[name] = prepend_env_path(lib_dir, environment.get(name)) +environment["PYTHONPATH"] = prepend_env_path( + python_lib_dir, environment.get("PYTHONPATH")) return_code = max( return_code, @@ -61,8 +63,9 @@ cwd=build_dir, stderr=subprocess.STDOUT, env=environment)) server.terminate() -os.remove(os.path.join(workspace, "tests/data", "index.dat")) -for path in glob.glob(os.path.join(workspace, "tests/data/RAW_*.dcm")): +os.remove(os.path.join(workspace, "tests", "data", "index.dat")) +for path in glob.glob(os.path.join(workspace, "tests", "data", "RAW_*.dcm")): os.remove(path) +os.remove(os.path.join(workspace, "tests", "data", "dcmqrscp.config")) sys.exit(return_code) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6735d62e..c35525e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,7 @@ jobs: - { os: "ubuntu-latest", container: "ubuntu:jammy", packaging: "apt", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python3" } - { os: "ubuntu-latest", packaging: "conda", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python" } - { os: "macos-latest", packaging: "conda", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python" } + - { os: "windows-latest", packaging: "conda", cmake_options: "-DCMAKE_CXX_STANDARD=17", python: "python" } env: WORKSPACE: "${{ github.workspace }}" CMAKE_OPTIONS: "${{ matrix.cmake_options }}" @@ -35,7 +36,7 @@ jobs: uses: mamba-org/setup-micromamba@v1 with: init-shell: bash powershell - environment-name: dicomifier + environment-name: odil create-args: python=3.11 if: ${{ contains(matrix.packaging, 'conda') }} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0e005403..c783279d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,7 +25,6 @@ add_library(libodil ${Source_Files} ${Header_Files} ${templates}) target_compile_definitions( libodil PUBLIC - BOOST_ASIO_SEPARATE_COMPILATION ODIL_VERSION_MAJOR=${Odil_VERSION_MAJOR} $<$:BOOST_ALL_DYN_LINK> $<$:BOOST_UUID_FORCE_AUTO_LINK> diff --git a/src/odil/asio.cpp b/src/odil/asio.cpp deleted file mode 100644 index 33401af0..00000000 --- a/src/odil/asio.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/************************************************************************* - * odil - Copyright (C) Universite de Strasbourg - * Distributed under the terms of the CeCILL-B license, as published by - * the CEA-CNRS-INRIA. Refer to the LICENSE file or to - * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - * for details. - ************************************************************************/ - -// Build Boost.asio in Odil -#include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9500896b..6b8be529 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -37,7 +37,6 @@ foreach(test_file ${tests}) target_compile_definitions( test_${test} PRIVATE - BOOST_ASIO_SEPARATE_COMPILATION ODIL_VERSION_MAJOR=${Odil_VERSION_MAJOR} $<$:BOOST_ALL_DYN_LINK>) diff --git a/tests/data/dcmqrscp.config b/tests/data/dcmqrscp.config index edad4b70..541bcf54 100644 --- a/tests/data/dcmqrscp.config +++ b/tests/data/dcmqrscp.config @@ -1,8 +1,8 @@ HostTable BEGIN -remote = (REMOTE, localhost, 11112) -local = (LOCAL, localhost, 11113) +remote = (REMOTE, 127.0.0.1, 11112) +local = (LOCAL, 127.0.0.1, 11113) HostTable END AETable BEGIN -REMOTE . RW (10, 1024mb) local +REMOTE . RW (500, 1024mb) ANY AETable END diff --git a/wrappers/python/CMakeLists.txt b/wrappers/python/CMakeLists.txt index d8ae8964..1d56c8c6 100644 --- a/wrappers/python/CMakeLists.txt +++ b/wrappers/python/CMakeLists.txt @@ -38,3 +38,7 @@ execute_process( install(TARGETS pyodil DESTINATION "${PYTHON_SITE_PACKAGES}/odil") install(FILES ${Python_Files} DESTINATION "${PYTHON_SITE_PACKAGES}/odil") + +if(WIN32) + install(TARGETS libodil RUNTIME DESTINATION "${PYTHON_SITE_PACKAGES}/odil") +endif()