diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2019-12-10 11:30:27 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2019-12-10 16:44:54 +0300 |
commit | cf15b237108360ee92f35898e35fa5a52cfc889a (patch) | |
tree | 9c95f527c25b9c14d14018e156a9fad6b286ded3 | |
parent | README: update (diff) | |
download | math-server-cf15b237108360ee92f35898e35fa5a52cfc889a.tar.gz math-server-cf15b237108360ee92f35898e35fa5a52cfc889a.zip |
AppVeyor/Travis: switch to cmake/build
Diffstat (limited to '')
-rw-r--r-- | .appveyor/.gitattributes | 1 | ||||
-rw-r--r-- | .appveyor/build.ps1 | 119 | ||||
-rw-r--r-- | .travis.yml | 17 | ||||
-rw-r--r-- | .travis/.gitattributes | 1 | ||||
-rwxr-xr-x | .travis/build.sh | 26 | ||||
-rwxr-xr-x | .travis/build_boost.sh | 49 | ||||
-rw-r--r-- | appveyor.yml | 9 | ||||
-rw-r--r-- | client/Dockerfile | 26 | ||||
m--------- | cmake | 0 | ||||
-rw-r--r-- | server/Dockerfile | 26 |
10 files changed, 44 insertions, 230 deletions
diff --git a/.appveyor/.gitattributes b/.appveyor/.gitattributes deleted file mode 100644 index b086bda..0000000 --- a/.appveyor/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.ps1 text eol=crlf diff --git a/.appveyor/build.ps1 b/.appveyor/build.ps1 deleted file mode 100644 index 43ed2e8..0000000 --- a/.appveyor/build.ps1 +++ /dev/null @@ -1,119 +0,0 @@ -param( - [string] $BuildDir = $null, - [string] $InstallDir = $null, - [string] $ProjectDir = $null, - [string] $Platform = $null, - [string] $Generator = $null, - [string] $Configuration = $null, - [string] $BoostDir = $null, - [string] $BoostLibraryDir = $null -) - -$ErrorActionPreference = "Stop"; -Set-PSDebug -Strict - -function Invoke-Exe { - param( - [ScriptBlock] $Cmd, - [int[]] $AllowedExitCodes = @(0) - ) - - $backupErrorActionPreference = $script:ErrorActionPreference - $script:ErrorActionPreference = 'Continue' - - try { - & $Cmd - if ($AllowedExitCodes -notcontains $LastExitCode) { - throw "External command failed with exit code ${LastExitCode}: $Cmd" - } - } finally { - $script:ErrorActionPreference = $backupErrorActionPreference - } -} - -function Test-AppVeyor { - return Test-Path env:APPVEYOR -} - -function Set-AppVeyorDefaults { - $script:ProjectDir = $env:APPVEYOR_BUILD_FOLDER - $script:BuildDir = 'C:\Projects\build' - $script:InstallDir = 'C:\Projects\install' - $script:Generator = switch ($env:APPVEYOR_BUILD_WORKER_IMAGE) { - 'Visual Studio 2017' { 'Visual Studio 15 2017' } - 'Visual Studio 2019' { 'Visual Studio 16 2019' } - default { throw "Unsupported AppVeyor image: $env:APPVEYOR_BUILD_WORKER_IMAGE" } - } - $script:Platform = $env:PLATFORM - $script:Configuration = $env:CONFIGURATION - $script:BoostDir = $env:appveyor_boost_root - $script:BoostLibraryDir = $env:appveyor_boost_librarydir -} - -function Build-Project { - param( - [Parameter(Mandatory=$true)] - [string] $ProjectDir, - [Parameter(Mandatory=$true)] - [string] $BuildDir, - [Parameter(Mandatory=$true)] - [string] $InstallDir, - [Parameter(Mandatory=$true)] - [string] $Generator, - [Parameter(Mandatory=$true)] - [string] $Platform, - [Parameter(Mandatory=$true)] - [string] $Configuration, - [Parameter(Mandatory=$true)] - [string] $BoostDir, - [string] $BoostLibraryDir = $null - ) - - if (-not $BoostLibraryDir) { - $BoostLibraryDir = "$BoostDir\stage\lib" - } - - mkdir $BuildDir - cd $BuildDir - - Invoke-Exe { cmake.exe ` - -G $Generator -A $Platform ` - -D "CMAKE_INSTALL_PREFIX=$InstallDir" ` - -D "BOOST_ROOT=$BoostDir" ` - -D "BOOST_LIBRARYDIR=$BoostLibraryDir" ` - -D ENABLE_TESTS=ON ` - $ProjectDir - } - - Invoke-Exe { cmake.exe --build . --config $Configuration --target install -- /m } - - cd $InstallDir - - Invoke-Exe { .\bin\unit_tests.exe --log_level=all } -} - -function Build-ProjectAppVeyor { - if (Test-AppVeyor) { - Set-AppVeyorDefaults - $appveyor_cwd = pwd - } - - try { - Build-Project ` - -ProjectDir $script:ProjectDir ` - -BuildDir $script:BuildDir ` - -InstallDir $script:InstallDir ` - -Generator $script:Generator ` - -Platform $script:Platform ` - -Configuration $script:Configuration ` - -BoostDir $script:BoostDir ` - -BoostLibraryDir $script:BoostLibraryDir - } finally { - if (Test-AppVeyor) { - cd $appveyor_cwd - Set-PSDebug -Off - } - } -} - -Build-ProjectAppVeyor diff --git a/.travis.yml b/.travis.yml index 66ba91c..9ce761a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,20 @@ dist: bionic env: global: - - boost_version=1.71.0 + - travis_boost_version=1.71.0 matrix: - - build_type=debug arch=x64 - - build_type=release arch=x64 + - configuration=Debug platform=x64 + - configuration=Release platform=x64 before_script: - - ./.travis/build_boost.sh + - ./cmake/build/boost/build_travis.sh --with-filesystem --with-program_options --with-test script: - - ./.travis/build.sh + - |- + ./cmake/build/build_travis.py \ + --configuration "$configuration" \ + --install "$HOME/install" \ + --boost "$HOME/boost_1_71_0" \ + --boost-librarydir "$HOME/boost_1_71_0/stage/$platform/${configuration,,}/lib" \ + -- -DENABLE_TESTS=ON + - "$HOME/install/bin/unit_tests" diff --git a/.travis/.gitattributes b/.travis/.gitattributes deleted file mode 100644 index dfdb8b7..0000000 --- a/.travis/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.sh text eol=lf diff --git a/.travis/build.sh b/.travis/build.sh deleted file mode 100755 index eeeec17..0000000 --- a/.travis/build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o nounset -o pipefail -o xtrace - -readonly boost_fs="boost_${boost_version//\./_}" -readonly boost_dir="$HOME/$boost_fs" -readonly boost_librarydir="$boost_dir/stage/$arch/$build_type/lib" - -readonly build_dir="$HOME/build" -readonly install_dir="$HOME/install" - -main() { - mkdir -p -- "$build_dir" - cd -- "$build_dir" - cmake \ - -D "CMAKE_BUILD_TYPE=$build_type" \ - -D "CMAKE_INSTALL_PREFIX=$install_dir" \ - -D "BOOST_ROOT=$boost_dir" \ - -D "BOOST_LIBRARYDIR=$boost_librarydir" \ - -D ENABLE_TESTS=ON \ - "$TRAVIS_BUILD_DIR" - cmake --build . --config "$build_type" --target install -- -j - "$install_dir/bin/unit_tests" --log_level=all -} - -main diff --git a/.travis/build_boost.sh b/.travis/build_boost.sh deleted file mode 100755 index 94869ef..0000000 --- a/.travis/build_boost.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o nounset -o pipefail -o xtrace - -readonly boost_fs="boost_${boost_version//\./_}" -readonly boost_url="https://dl.bintray.com/boostorg/release/$boost_version/source/$boost_fs.tar.gz" -readonly boost_dir="$HOME/$boost_fs" - -address_model=32 -[ "$arch" = x64 ] && address_model=64 -readonly address_model - -clean() { - cd -- "$HOME/" -} - -download() { - trap clean RETURN - wget -- "$boost_url" - tar xzvf "$boost_fs.tar.gz" > /dev/null -} - -bootstrap() { - trap clean RETURN - cd -- "$boost_dir" - ./bootstrap.sh -} - -build() { - trap clean RETURN - cd -- "$boost_dir" - ./b2 \ - "address-model=$address_model" \ - link=static \ - variant="$build_type" \ - "--stagedir=stage/$arch/$build_type" \ - --with-filesystem \ - --with-program_options \ - --with-test -} - -main() { - clean - download - bootstrap - build -} - -main diff --git a/appveyor.yml b/appveyor.yml index 40e3912..515d8ca 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,6 +4,10 @@ image: - Visual Studio 2017 - Visual Studio 2019 +environment: + python_exe: C:\Python36-x64\python.exe + install_dir: C:\Projects\install + platform: - Win32 - x64 @@ -16,7 +20,10 @@ install: - git submodule update --init --recursive build_script: - - ps: .\.appveyor\build.ps1 + - '"%python_exe%" cmake\build\build_appveyor.py --install "%install_dir%" --boost "%appveyor_boost_root%" --boost-librarydir "%appveyor_boost_librarydir%" -- -DENABLE_TESTS=ON' + +test_script: + - '"%install_dir%\bin\unit_tests.exe"' for: # Only build Release builds for master to speed things up: diff --git a/client/Dockerfile b/client/Dockerfile index d5dd309..9b2ab51 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -8,28 +8,26 @@ LABEL maintainer="Egor Tensin <Egor.Tensin@gmail.com>" # Don't prompt: ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update -yq && \ - apt-get install -yq --no-install-recommends \ +RUN apt-get update -yq \ + && apt-get install -yq --no-install-recommends \ build-essential \ cmake \ libboost-filesystem-dev \ libboost-program-options-dev \ - libboost-test-dev + libboost-test-dev \ + python3 -ENV src_dir=/tmp/src \ - build_dir=/tmp/build +ENV src_dir=/usr/src/app COPY [".", "$src_dir"] -WORKDIR $build_dir - -RUN cmake -G "Unix Makefiles" \ - -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_INSTALL_PREFIX=/usr/local \ - -D ENABLE_TESTS=ON \ - "$src_dir" && \ - cmake --build . --config Release --target install && \ - /usr/local/bin/unit_tests --log_level=all +RUN "$src_dir/cmake/build/build.py" \ + --src "$src_dir" \ + --install /usr/local \ + --clean \ + --configuration Release \ + -- -DENABLE_TESTS=ON \ + && /usr/local/bin/unit_tests --log_level=all ENTRYPOINT ["/usr/local/bin/client"] CMD ["-c", "2 * 2"] diff --git a/cmake b/cmake -Subproject 012cbc62444137c516c4e4cab7e17d21aef265f +Subproject 77571d71ce48a68cbd6d3a931b89d07e298f3f3 diff --git a/server/Dockerfile b/server/Dockerfile index 8234da8..96bb51c 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -8,27 +8,25 @@ LABEL maintainer="Egor Tensin <Egor.Tensin@gmail.com>" # Don't prompt: ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update -yq && \ - apt-get install -yq --no-install-recommends \ +RUN apt-get update -yq \ + && apt-get install -yq --no-install-recommends \ build-essential \ cmake \ libboost-filesystem-dev \ libboost-program-options-dev \ - libboost-test-dev + libboost-test-dev \ + python3 -ENV src_dir=/tmp/src \ - build_dir=/tmp/build +ENV src_dir=/usr/src/app COPY [".", "$src_dir"] -WORKDIR $build_dir - -RUN cmake -G "Unix Makefiles" \ - -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_INSTALL_PREFIX=/usr/local \ - -D ENABLE_TESTS=ON \ - "$src_dir" && \ - cmake --build . --config Release --target install && \ - /usr/local/bin/unit_tests --log_level=all +RUN "$src_dir/cmake/build/build.py" \ + --src "$src_dir" \ + --install /usr/local \ + --clean \ + --configuration Release \ + -- -DENABLE_TESTS=ON \ + && /usr/local/bin/unit_tests --log_level=all CMD ["/usr/local/bin/server"] |