From 5358d195bb36014024f68557d59df388b4fa3dd8 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 12 Apr 2021 16:12:36 -0400 Subject: [PATCH] CI: Add MSVC test job --- .github/workflows/test.yml | 58 ++++++++++++++++++++++++++++++++++++-- atdna/CMakeLists.txt | 20 +++++++------ 2 files changed, 68 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e800ee2..106a42e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -89,6 +89,7 @@ jobs: - name: Install dependencies run: | + brew update brew install ninja ccache # universal clang+llvm from macports curl -LSfs https://axiodl.com/files/clang-11-11.1.0_1.mpkg -o /tmp/clang-11-11.1.0_1.mpkg @@ -100,11 +101,14 @@ jobs: key: macos-10.15-appleclang max-size: 1G - - name: Build + - name: Configure CMake run: | cmake -B build -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \ -DClang_DIR=/opt/local/libexec/llvm-11/lib/cmake/clang \ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache . + + - name: Build + run: | cmake --build build dsymutil build/atdna/atdna @@ -118,4 +122,54 @@ jobs: name: atdna-macos-x86_64 path: | build/atdna/atdna - build/atdna/atdna.dSYM \ No newline at end of file + build/atdna/atdna.dSYM + + test-windows-msvc: + name: Build Windows (MSVC x86_64) + runs-on: windows-2019 + env: + LLVM_VERSION: 10.0.1 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + submodules: recursive + + - name: Install LLVM + run: | + $TempDir = "$env:RUNNER_WORKSPACE\temp" + $Filename = "LLVM-$env:LLVM_VERSION-win64.exe" + New-Item -Path "$TempDir" -ItemType Directory -ea 0 + (New-Object Net.WebClient).DownloadFile("https://axiodl.com/files/$Filename", "$TempDir\$Filename") + Start-Process "$TempDir\$Filename" -ArgumentList "/S /D=$env:RUNNER_WORKSPACE\LLVM" -Wait + + - name: Install dependencies + run: choco install ninja + + - name: Enable Visual Studio environment + uses: ilammy/msvc-dev-cmd@v1 + + - name: Create build directory + run: cmake -E make_directory ${{github.workspace}}/build + + - name: Configure CMake + run: | + $workspace = $env:RUNNER_WORKSPACE -replace '\\', '/' + cmake -B build -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo ` + -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ` + -DLLVM_ROOT_DIR="$workspace/LLVM" . + + - name: Build + run: cmake --build build + + - name: Test + working-directory: build + run: ./atdna-test.exe + + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: atdna-macos-x86_64 + path: | + build/atdna/atdna.exe + build/atdna/atdna.pdb \ No newline at end of file diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index f231803..a8f8885 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -9,14 +9,18 @@ list(REMOVE_ITEM ATDNA_DEFINES _GLIBCXX_DEBUG=1) set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${ATDNA_DEFINES}") # Find dependencies -if(APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) - set(LLVM_HOMEBREW_PATH /usr/local/opt/llvm) -elseif(APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL arm64) - set(LLVM_HOMEBREW_PATH /opt/homebrew/opt/llvm) -else() - set(LLVM_HOMEBREW_PATH "") -endif() -find_package(Clang REQUIRED PATHS ${LLVM_HOMEBREW_PATH}) +if (NOT "${LLVM_ROOT_DIR}" STREQUAL "") + # use existing LLVM_ROOT_DIR +elseif (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64) + set(LLVM_ROOT_DIR /usr/local/opt/llvm) +elseif (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL arm64) + set(LLVM_ROOT_DIR /opt/homebrew/opt/llvm) +elseif (WIN32) + get_filename_component(LLVM_ROOT_DIR [HKEY_LOCAL_MACHINE\\Software\\LLVM\\LLVM] ABSOLUTE) +else () + set(LLVM_ROOT_DIR "") +endif () +find_package(Clang REQUIRED PATHS ${LLVM_ROOT_DIR}) find_package(LLVM REQUIRED PATHS ${CLANG_INSTALL_PREFIX}) if(LLVM_FOUND)