diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f2eb4b5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,183 @@ +on: [pull_request] +name: draco-ci +jobs: + + # Main build and test job. + draco-tests: + strategy: + matrix: + include: + - test_name: macos-make-release-shared + os: macos-latest + cmake_configure_command: |- + cmake .. -G "Unix Makefiles" \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DDRACO_TESTS=ON + cmake_build_command: cmake --build . -- -j2 + draco_test_command: ./draco_tests + + - test_name: macos-make-release-static + os: macos-latest + cmake_configure_command: |- + cmake .. -G "Unix Makefiles" \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DDRACO_TESTS=ON + cmake_build_command: cmake --build . -- -j2 + draco_test_command: ./draco_tests + + - test_name: macos-xcode-release-shared + os: macos-latest + cmake_configure_command: |- + cmake .. -G Xcode \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_CONFIGURATION_TYPES=Release \ + -DDRACO_TESTS=ON + cmake_build_command: cmake --build . --config Release + draco_test_command: Release/draco_tests + + - test_name: macos-xcode-release-static + os: macos-latest + cmake_configure_command: |- + cmake .. -G Xcode \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_CONFIGURATION_TYPES=Release \ + -DDRACO_TESTS=ON + cmake_build_command: cmake --build . --config Release + draco_test_command: Release/draco_tests + + - test_name: ubuntu-make-release-shared + os: ubuntu-latest + cmake_configure_command: |- + cmake .. -G "Unix Makefiles" \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=gcc-10 \ + -DCMAKE_CXX_COMPILER=g++-10 \ + -DDRACO_TESTS=ON + cmake_build_command: cmake --build . -- -j2 + draco_test_command: ./draco_tests + + - test_name: ubuntu-make-release-static + os: ubuntu-latest + cmake_configure_command: |- + cmake .. -G "Unix Makefiles" \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=gcc-10 \ + -DCMAKE_CXX_COMPILER=g++-10 \ + -DDRACO_TESTS=ON + cmake_build_command: cmake --build . -- -j2 + draco_test_command: ./draco_tests + + - test_name: windows-msvc-release-shared + os: windows-latest + cmake_configure_command: |- + cmake .. -G "Visual Studio 16 2019" \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_CONFIGURATION_TYPES=Release \ + -DDRACO_TESTS=ON + cmake_build_command: cmake --build . --config Release -- -m:2 + draco_test_command: Release/draco_tests + + - test_name: windows-msvc-release-static + os: windows-latest + cmake_configure_command: |- + cmake .. -G "Visual Studio 16 2019" \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_CONFIGURATION_TYPES=Release \ + -DDRACO_TESTS=ON + cmake_build_command: cmake --build . --config Release -- -m:2 + draco_test_command: Release/draco_tests + + - test_name: windows-make-release-shared + os: windows-latest + cmake_configure_command: |- + cmake .. -G "MinGW Makefiles" \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \ + -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \ + -DDRACO_TESTS=ON + cmake_build_command: cmake --build . -- -j2 + draco_test_command: ./draco_tests + + - test_name: windows-make-release-static + os: windows-latest + cmake_configure_command: |- + cmake .. -G "MinGW Makefiles" \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \ + -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \ + -DDRACO_TESTS=ON + cmake_build_command: cmake --build . -- -j2 + draco_test_command: ./draco_tests + + name: test-${{ matrix.test_name }} + runs-on: ${{ matrix.os }} + + steps: + - name: Clone Draco with Submodules. + uses: actions/checkout@v2 + with: + submodules: true + + - name: Create build directory + shell: bash + run: mkdir _gh_build + + - name: Configure CMake build + shell: bash + run: ${{ matrix.cmake_configure_command }} + working-directory: ./_gh_build + + - name: Build with CMake + shell: bash + run: ${{ matrix.cmake_build_command }} + working-directory: ./_gh_build + + - name: Run tests + shell: bash + run: ${{ matrix.draco_test_command }} + working-directory: ./_gh_build + + # Runs src/draco/tools/install_test. + draco-install-tests: + strategy: + matrix: + include: + - test_name: ubuntu-make + os: ubuntu-latest + test_command: python3 test.py -v -G "Unix Makefiles" + + - test_name: macos-make + os: macos-latest + test_command: python3 test.py -v -G "Unix Makefiles" + + - test_name: macos-xcode + os: macos-latest + test_command: python3 test.py -v -G Xcode + + - test_name: windows-make + os: windows-latest + test_command: python3 test.py -v -G "MinGW Makefiles" + + - test_name: windows-msvc + os: windows-latest + test_command: python3 test.py -v -G "Visual Studio 16 2019" + + name: install-test-${{ matrix.test_name }} + runs-on: ${{ matrix.os }} + + steps: + - name: Clone Draco with Submodules + uses: actions/checkout@v2 + with: + submodules: true + + - name: Run src/draco/tools/install_test/test.py + shell: bash + run: ${{ matrix.test_command }} + working-directory: ./src/draco/tools/install_test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 2ab1196..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,39 +0,0 @@ -on: [pull_request] -name: Build -jobs: - test: - strategy: - matrix: - include: - - os: ubuntu-latest - cc: gcc-10 - cxx: g++-10 - generator: Unix Makefiles - - os: ubuntu-latest - cc: clang - cxx: clang++ - generator: Unix Makefiles - - os: macos-latest - cc: gcc-10 - cxx: g++-10 - generator: Unix Makefiles - - os: windows-latest - cc: x86_64-w64-mingw32-gcc - cxx: x86_64-w64-mingw32-g++ - generator: MinGW Makefiles - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - run: git clone https://github.com/google/googletest.git ../googletest - - run: mkdir _gh_build - - run: cmake -G "${{ matrix.generator }}" -DENABLE_TESTS=ON .. - working-directory: ./_gh_build - env: - CC: ${{ matrix.cc }} - CXX: ${{ matrix.cxx }} - - run: make -j10 - working-directory: ./_gh_build - - run: ./draco_tests - working-directory: ./_gh_build diff --git a/README.md b/README.md index 136fc7c..3c591c6 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@

-[![Build Status](https://github.com/google/draco/workflows/Build/badge.svg)](https://github.com/google/draco/actions?query=workflow%3ABuild) +![draco-ci](https://github.com/google/draco/actions/workflows/ci.yml/badge.svg) + News ======= diff --git a/cmake/draco-config.cmake.template b/cmake/draco-config.cmake.template index cc5a8f7..7ca5196 100644 --- a/cmake/draco-config.cmake.template +++ b/cmake/draco-config.cmake.template @@ -1,7 +1,11 @@ @PACKAGE_INIT@ set_and_check(DRACO_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@") set_and_check(DRACO_LIBRARY_DIR "@CMAKE_INSTALL_FULL_LIBDIR@") -set(DRACO_NAMES draco.dll libdraco.dylib libdraco.so draco.lib libdraco.a) +set(DRACO_NAMES + draco.dll libdraco.dylib libdraco.so draco.lib libdraco.dll libdraco.a) find_library(_DRACO_LIBRARY PATHS ${DRACO_LIBRARY_DIR} NAMES ${DRACO_NAMES}) set_and_check(DRACO_LIBRARY ${_DRACO_LIBRARY}) +find_file(DRACO_LIBRARY_DLL + PATHS ${DRACO_LIBRARY_DIR} + NAMES draco.dll libdraco.dll) set(DRACO_FOUND YES) diff --git a/src/draco/tools/install_test/CMakeLists.txt b/src/draco/tools/install_test/CMakeLists.txt index e98c8ce..de5ae24 100644 --- a/src/draco/tools/install_test/CMakeLists.txt +++ b/src/draco/tools/install_test/CMakeLists.txt @@ -51,6 +51,6 @@ if(BUILD_SHARED_LIBS AND WIN32) # Copy the Draco DLL into the bin dir for Windows: Windows doesn't really have # a concept of rpath, but it does look in the current directory by default # when a program tries to load a DLL. - install(FILES "${DRACO_LIBRARY_DIR}/draco.dll" + install(FILES "${DRACO_LIBRARY_DLL}" DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") endif() diff --git a/src/draco/tools/install_test/test.py b/src/draco/tools/install_test/test.py index 45f2f9d..ad66a1d 100755 --- a/src/draco/tools/install_test/test.py +++ b/src/draco/tools/install_test/test.py @@ -27,6 +27,7 @@ import pathlib import shlex import shutil import subprocess +import sys # CMake executable. CMAKE = shutil.which('cmake') @@ -113,7 +114,8 @@ def cmake_get_generator(): def run_process_and_capture_output(cmd, env=None): """Runs |cmd| as a child process. - Returns process exit code and output. + Returns process exit code and output. Streams process output to stdout when + VERBOSE is true. Args: cmd: String containing the command to execute. @@ -133,8 +135,18 @@ def run_process_and_capture_output(cmd, env=None): proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env) - stdout = proc.communicate() - return [proc.returncode, stdout[0].decode('utf-8')] + + stdout = '' + for line in iter(proc.stdout.readline, b''): + decoded_line = line.decode('utf-8') + if VERBOSE: + sys.stdout.write(decoded_line) + sys.stdout.flush() + stdout += decoded_line + + # Wait for the process to exit so that the exit code is available. + proc.wait() + return [proc.returncode, stdout] def create_output_directories(): @@ -162,7 +174,10 @@ def cmake_configure(source_path, cmake_args=None): command = f'{CMAKE} {source_path}' if CMAKE_GENERATOR: - command += f' -G {CMAKE_GENERATOR}' + if ' ' in CMAKE_GENERATOR: + command += f' -G "{CMAKE_GENERATOR}"' + else: + command += f' -G {CMAKE_GENERATOR}' if cmake_args: for arg in cmake_args: