diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-01-17 13:54:57 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-01-17 13:54:57 +0300 |
commit | dd2c5b58c4fe77d7ce35f3abb6e1bb399560a2db (patch) | |
tree | 813808b873a5895d7f212f890c68ff14820dc591 /.github | |
parent | Travis/AppVeyor: pause (diff) | |
download | cmake-common-dd2c5b58c4fe77d7ce35f3abb6e1bb399560a2db.tar.gz cmake-common-dd2c5b58c4fe77d7ce35f3abb6e1bb399560a2db.zip |
GIANT CLUSTERFUCK OF A COMMIT
OK, this is epic. I was basically just trying to a) support Clang and
b) add more test coverage. _THREE MONTHS_ and a few hundred CI runs
later, this is what I came up with. I don't know how it ended up being
what it is, but here we go.
Some highlights of the changes:
1) CI builds has been moved to GitHub Actions,
2) the entire notion of a toolchain has been reworked; it now supports
Clang on all platforms.
* .github: this directory contains the GitHub Actions workflow
scripts/actions. In the process, I created like 6 external GitHub
actions, but it's still pretty massive. An upside is that it covers
much more platform/toolchain combinations _and_ check a lot of the
expected post-conditions. TODO: .ci/Makefile is obsolete now, as well
as .travis.yml and .appveyor.yml.
* common.cmake: added Clang support. In the process, a great deal has
been learned about how CMake works; in particular, static runtime
support has been reworked to be more robust.
* project: the entire notion of a "toolchain" has been reworked.
Instead of a measly --mingw parameter, there's now a separate --toolset
parameter, which allows you to choose between GCC, Clang, MSVC, etc.
Both Boost and CMake build scripts were enhanced greatly to support
Clang and other toolchains in a more robust way.
Diffstat (limited to '')
-rw-r--r-- | .github/actions/build-boost/action.yml | 53 | ||||
-rw-r--r-- | .github/actions/build-example/action.yml | 69 | ||||
-rw-r--r-- | .github/actions/check-arch/action.yml | 23 | ||||
-rw-r--r-- | .github/actions/check-boost-bootstrapped/action.yml | 44 | ||||
-rw-r--r-- | .github/actions/check-boost-libraries/action.yml | 77 | ||||
-rw-r--r-- | .github/actions/check-runtime-library/action.yml | 161 | ||||
-rw-r--r-- | .github/actions/check-symbols/action.yml | 46 | ||||
-rw-r--r-- | .github/actions/common-variables/action.yml | 85 | ||||
-rw-r--r-- | .github/actions/download-boost/action.yml | 40 | ||||
-rw-r--r-- | .github/actions/run-example-boost/action.yml | 45 | ||||
-rw-r--r-- | .github/actions/run-example/action.yml | 28 | ||||
-rw-r--r-- | .github/actions/software-environment/action.yml | 63 | ||||
-rw-r--r-- | .github/workflows/boost_clang_windows.yml | 143 | ||||
-rw-r--r-- | .github/workflows/boost_toolsets.yml | 222 | ||||
-rw-r--r-- | .github/workflows/cygwin_static_libstdc++.yml | 81 | ||||
-rw-r--r-- | .github/workflows/example_toolsets.yml | 168 |
16 files changed, 1348 insertions, 0 deletions
diff --git a/.github/actions/build-boost/action.yml b/.github/actions/build-boost/action.yml new file mode 100644 index 0000000..1f8a46c --- /dev/null +++ b/.github/actions/build-boost/action.yml @@ -0,0 +1,53 @@ +name: Build Boost +description: Build Boost +inputs: + boost-dir: + description: Boost directory + required: false + toolset: + description: Toolset to use + required: false + default: auto + libraries: + description: Libraries to build + required: false + platform: + description: Target platform + required: false + default: x64 + configuration: + description: Configuration to build + required: false + default: Debug +runs: + using: composite + steps: + - run: | + $python = 'python' + + $boost_dir = '${{ inputs.boost-dir }}' + if (-not $boost_dir) { + $boost_dir = $env:BOOST_DIR + } + + $libraries = '${{ inputs.libraries }}' + $libraries = $libraries.Split(' ') | %{ "--with-$_" } + if (-not $libraries) { + Remove-Variable libraries + } + + if ($env:CI_HOST_CYGWIN) { + $python = 'python3' + $boost_dir = cygpath.exe -ua $boost_dir + } + + & $python ` + -m project.boost.build ` + --verbose ` + --toolset '${{ inputs.toolset }}' ` + --platform '${{ inputs.platform }}' ` + --configuration '${{ inputs.configuration }}' ` + -- ` + $boost_dir ` + $libraries + shell: pwsh diff --git a/.github/actions/build-example/action.yml b/.github/actions/build-example/action.yml new file mode 100644 index 0000000..97cc627 --- /dev/null +++ b/.github/actions/build-example/action.yml @@ -0,0 +1,69 @@ +name: Build example project +description: Build example project +inputs: + src-dir: + description: Project directory + required: true + boost-dir: + description: Boost directory + required: false + toolset: + description: Toolset to use + required: false + default: auto + platform: + description: Target platform + required: false + default: x64 + configuration: + description: Configuration to build + required: false + default: Debug +outputs: + install-dir: + description: Installation directory + value: '${{ steps.install-dir.outputs.path }}' +runs: + using: composite + steps: + - id: install-dir + run: | + $src_dir = Resolve-Path '${{ inputs.src-dir }}' + $project_name = Split-Path $src_dir -Leaf + $install_dir = Join-Path (Split-Path $env:GITHUB_WORKSPACE) "install_$project_name" + echo "::set-output name=path::$install_dir" + shell: pwsh + - run: | + $python = 'python' + $src_dir = '${{ inputs.src-dir }}' + $install_dir = '${{ steps.install-dir.outputs.path }}' + $boost_dir = '${{ inputs.boost-dir }}' + + if ($env:CI_HOST_CYGWIN) { + $python = 'python3' + $src_dir = cygpath.exe -ua $src_dir + $install_dir = cygpath.exe -ua $install_dir + if ($boost_dir) { + $boost_dir = cygpath.exe -ua $boost_dir + } + } + + $args = @( + '--install', + $install_dir, + '--platform', + '${{ inputs.platform }}', + '--configuration', + '${{ inputs.configuration }}', + '--toolset', + '${{ inputs.toolset }}' + ) + + if ($boost_dir) { + $args += '--boost',$boost_dir + } + + $args += '--',$src_dir + $env:VERBOSE = 1 + & $python -m project.cmake.build $args + shell: pwsh diff --git a/.github/actions/check-arch/action.yml b/.github/actions/check-arch/action.yml new file mode 100644 index 0000000..b85be4e --- /dev/null +++ b/.github/actions/check-arch/action.yml @@ -0,0 +1,23 @@ +name: Verify architecture +description: Verify target architecture +inputs: + path: + description: Installation directory + required: true + expected: + description: Target platform + required: true +runs: + using: composite + steps: + - run: | + $script_path = if ($env:CI_TARGET_PE) { + Join-Path $env:GITHUB_WORKSPACE '.ci' 'verify_arch.ps1' + } else { + Join-Path $env:GITHUB_WORKSPACE '.ci' 'verify_arch.sh' + } + + $exe_path = (Join-Path '${{ inputs.path }}' 'bin' 'foo') + $env:CI_EXE_EXT + + & $script_path $exe_path '${{ inputs.expected }}' + shell: pwsh diff --git a/.github/actions/check-boost-bootstrapped/action.yml b/.github/actions/check-boost-bootstrapped/action.yml new file mode 100644 index 0000000..73f44a9 --- /dev/null +++ b/.github/actions/check-boost-bootstrapped/action.yml @@ -0,0 +1,44 @@ +name: Check that Boost was bootstrapped +description: Check that Boost was bootstrapped +runs: + using: composite + steps: + - run: | + echo '----------------------------------------------------------------' + echo 'bootstrap.log' + echo '----------------------------------------------------------------' + $path = Join-Path $env:BOOST_DIR 'bootstrap.log' + cat $path + shell: pwsh + - run: | + echo '' + echo '----------------------------------------------------------------' + echo 'project-config.jam' + echo '----------------------------------------------------------------' + $path = Join-Path $env:BOOST_DIR 'project-config.jam' + if (Test-Path $path -Type Leaf) { + cat $path + } + shell: pwsh + - run: | + echo '' + echo '----------------------------------------------------------------' + echo 'Checking that b2 executable was built' + echo '----------------------------------------------------------------' + $name = 'b2' + $path = Join-Path $env:BOOST_DIR $name + + $exists_plain = Test-Path $path -Type Leaf + $exists_exe = Test-Path "${path}.exe" -Type Leaf + $exists = if ($env:CI_HOST_CYGWIN) { + $exists_plain -or $exists_exe + } elseif ($env:CI_HOST_WINDOWS) { + $exists_exe + } else { + $exists_plain + } + + if (-not $exists) { + throw "b2 executable wasn't found" + } + shell: pwsh diff --git a/.github/actions/check-boost-libraries/action.yml b/.github/actions/check-boost-libraries/action.yml new file mode 100644 index 0000000..88df016 --- /dev/null +++ b/.github/actions/check-boost-libraries/action.yml @@ -0,0 +1,77 @@ +name: Check that Boost libraries were built +description: Check that Boost libraries were built +inputs: + boost-dir: + description: Boost directory + required: false + libraries: + description: Libraries to check + required: true + platform: + description: Target platform + required: false + default: x64 + configuration: + description: Configuration to check + required: false + default: Debug +runs: + using: composite + steps: + - run: | + $boost_dir = '${{ inputs.boost-dir }}' + if (-not $boost_dir) { + $boost_dir = $env:BOOST_DIR + } + + $libraries = '${{ inputs.libraries }}' + $libraries = $libraries.Split(' ') + + $stagedir = Join-Path 'stage' '${{ inputs.platform }}' '${{ inputs.configuration }}' + $librarydir = Join-Path $boost_dir $stagedir 'lib' + + function Get-FileStubs { + param( + [Parameter(Mandatory=$true)] + [string] $lib + ) + + if ($lib -eq 'test') { + "prg_exec_monitor","test_exec_monitor","unit_test_framework" + } else { + @($lib) + } + } + + $files = @() + foreach ($lib in $libraries) { + $stubs = Get-FileStubs $lib + foreach ($stub in $stubs) { + $files += "${env:CI_LIB_PREFIX}boost_$stub${env:CI_LIB_EXT}" + } + } + $files = $files | Sort-Object + + echo '----------------------------------------------------------------' + echo 'Expected files' + echo '----------------------------------------------------------------' + echo $files + + echo '' + echo '----------------------------------------------------------------' + echo 'Actual files' + echo '----------------------------------------------------------------' + echo (Get-ChildItem $librarydir | Sort-Object Name).Name + + $missing = @() + + foreach ($file in $files) { + if (!(Test-Path (Join-Path $librarydir $file) -Type Leaf)) { + $missing += $file + } + } + + if ($missing.Count -ne 0) { + throw "These libraries are missing: $($missing -join ', ')" + } + shell: pwsh diff --git a/.github/actions/check-runtime-library/action.yml b/.github/actions/check-runtime-library/action.yml new file mode 100644 index 0000000..3025334 --- /dev/null +++ b/.github/actions/check-runtime-library/action.yml @@ -0,0 +1,161 @@ +name: Verify runtime library linkage +description: Verify runtime library linkage (static or shared) +inputs: + path: + description: Installation directory + required: true +runs: + using: composite + steps: + - run: | + New-Variable path -Value '${{ inputs.path }}' -Option Constant + + function Parse-DllLine { + param( + [Parameter(Mandatory=$true)] + [string] $Line + ) + + if ($Line -match '^\s*DLL Name:\s*(?<dll>\S+)\s*$') { + $Matches.dll + } else { + throw "Line doesn't match the pattern: $Line" + } + } + + function Parse-PeHeaders { + param( + [Parameter(ValueFromPipeline)] + [string[]] $Output + ) + + process { + $Output | Select-String 'DLL Name:' -SimpleMatch -CaseSensitive | %{ + Parse-DllLine $_ + } + } + } + + function Parse-NeededLine { + param( + [Parameter(Mandatory=$true)] + [string] $Line + ) + + if ($Line -match '^\s*NEEDED\s*(?<dll>\S+)\s*$') { + $Matches.dll + } else { + throw "Line doesn't match the pattern: $Line" + } + } + + function Parse-ElfHeaders { + param( + [Parameter(ValueFromPipeline)] + [string[]] $Output + ) + + process { + $Output | Select-String 'NEEDED' -SimpleMatch -CaseSensitive | %{ + Parse-NeededLine $_ + } + } + } + + function Get-LinkedLibraries { + param( + [Parameter(Mandatory=$true)] + [string] $ExePath + ) + + $objdump = 'objdump' + if ($env:CI_HOST_WINDOWS) { + $objdump = 'C:\ProgramData\chocolatey\bin\objdump.exe' + } + + if ($env:CI_TARGET_PE) { + & $objdump -x $ExePath | Parse-PeHeaders | echo + } + if ($env:CI_TARGET_ELF) { + & $objdump -x $ExePath | Parse-ElfHeaders | echo + } + } + + function Do-ValidateLinkedLibraries { + param( + [Parameter(Mandatory=$true)] + [ValidateNotNull()] + [string[]] $Actual, + + [Parameter(Mandatory=$true)] + [ValidateNotNull()] + [string[]] $Required, + + [Parameter(Mandatory=$true)] + [ValidateNotNull()] + [string[]] $Optional + ) + + echo 'Linked libraries:' + echo $Actual + + $missing = $Required | ?{$_ -notin $Actual} + + if ($missing.Count -gt 0) { + throw "Doesn't link to the following libraries: $($missing -join ', ')" + } + + $unexpected = $Actual | ?{$_ -notin $Required -and $_ -notin $Optional} + + if ($unexpected.Count -gt 0) { + throw "Links to the following unexpected libraries: $($unexpected -join ', ')" + } + } + + function Validate-LinkedLibraries { + param( + [Parameter(Mandatory=$true)] + [ValidateNotNull()] + [string[]] $Actual + ) + + $windows_required = @('KERNEL32.dll') + if ($env:CI_MINGW) { + $windows_required += 'msvcrt.dll' + } + # Linking libstdc++ statically on Cygwin is broken, see the + # cygwin_static_libstdc++.yml workflow. + $cygwin_required = $windows_required + @('cygwin1.dll','cygstdc++-6.dll') + $linux_required = @('libc.so.6') + + $windows_optional = @('baz.dll') + if ($env:CI_MINGW) { + $windows_optional = @('libbaz.dll','USER32.dll') + } + $cygwin_optional = @('cygbaz.dll') + $linux_optional = @('libbaz.so','ld-linux.so.2','ld-linux-x86-64.so.2','libm.so.6') + + if ($env:CI_TARGET_CYGWIN) { + Do-ValidateLinkedLibraries ` + -Actual $Actual ` + -Required $cygwin_required ` + -Optional $cygwin_optional + } elseif ($env:CI_TARGET_WINDOWS) { + Do-ValidateLinkedLibraries ` + -Actual $Actual ` + -Required $windows_required ` + -Optional $windows_optional + } elseif ($env:CI_TARGET_LINUX) { + Do-ValidateLinkedLibraries ` + -Actual $Actual ` + -Required $linux_required ` + -Optional $linux_optional + } else { + throw 'Where am I?' + } + } + + $exe_path = (Join-Path $path 'bin' 'foo') + $env:CI_EXE_EXT + $libraries = Get-LinkedLibraries $exe_path + Validate-LinkedLibraries $libraries + shell: pwsh diff --git a/.github/actions/check-symbols/action.yml b/.github/actions/check-symbols/action.yml new file mode 100644 index 0000000..7428be3 --- /dev/null +++ b/.github/actions/check-symbols/action.yml @@ -0,0 +1,46 @@ +name: Check symbols +description: Check debug symbols +inputs: + path: + description: Installation directory + required: true + expected: + description: Expected symbols + required: true +runs: + using: composite + steps: + - run: | + $install_dir = '${{ inputs.path }}' + $bin_dir = Join-Path $install_dir 'bin' + $lib_dir = Join-Path $install_dir 'lib' + + $script_path = if ($env:CI_TARGET_ELF) { + Join-Path $env:GITHUB_WORKSPACE '.ci' 'verify_symbols.sh' + } else { + throw "Verifying symbols for PE executables is not implemented" + } + + ConvertFrom-Json '${{ inputs.expected }}' | %{ + $target = $_.target + $type = $_.type + + switch -Exact ($type) { + 'exe' { + $file = $target + $env:CI_EXE_EXT + $path = Join-Path $bin_dir $file + } + 'dll' { + $file = $env:CI_DLL_PREFIX + $target + $env:CI_DLL_EXT + $path = if ($env:CI_DLL_IN_BIN) { + Join-Path $bin_dir $file + } else { + Join-Path $lib_dir $file + } + } + default { throw "Unrecognized type: $type" } + } + + & $script_path $path $_.symbols + } + shell: pwsh diff --git a/.github/actions/common-variables/action.yml b/.github/actions/common-variables/action.yml new file mode 100644 index 0000000..3d40cdd --- /dev/null +++ b/.github/actions/common-variables/action.yml @@ -0,0 +1,85 @@ +name: Set common variables +description: Set common run variables +inputs: + toolset: + description: Toolset used + required: true + cygwin: + description: Targeting Cygwin + required: false + default: 0 +runs: + using: composite + steps: + - run: | + New-Variable toolset -Value '${{ inputs.toolset }}' -Option Constant + New-Variable cygwin -Value ('${{ inputs.cygwin }}' -eq '1') -Option Constant + + New-Variable os -Value '${{ runner.os }}' -Option Constant + + New-Variable host_linux -Value ($os -eq 'Linux') -Option Constant + New-Variable host_cygwin -Value $cygwin -Option Constant + New-Variable host_windows -Value ($os -eq 'Windows' -and !$host_cygwin) -Option Constant + + New-Variable mingw -Value ($toolset -eq 'mingw' -or ($host_windows -and $toolset -eq 'gcc')) -Option Constant + + New-Variable target_linux -Value ($host_linux -and !$mingw) -Option Constant + New-Variable target_cygwin -Value ($host_cygwin -and !$mingw) -Option Constant + New-Variable target_windows -Value ($mingw -or $host_windows) -Option Constant + + New-Variable target_pe -Value ($target_windows -or $target_cygwin) -Option Constant + New-Variable target_elf -Value $target_linux -Option Constant + + function Set-BoolVar { + param( + [Parameter(Mandatory=$true)] + [string] $name, + [Parameter(Mandatory=$true)] + [bool] $value + ) + + $str_value = if ($value) { '1' } else { '' } + $msg = "$name=$str_value" + echo $msg + echo $msg >> $env:GITHUB_ENV + } + + function Set-StrVar { + param( + [Parameter(Mandatory=$true)] + [string] $name, + [string] $value + ) + + $msg = "$name=$value" + echo $msg + echo $msg >> $env:GITHUB_ENV + } + + Set-BoolVar 'CI_HOST_LINUX' $host_linux + Set-BoolVar 'CI_HOST_CYGWIN' $host_cygwin + Set-BoolVar 'CI_HOST_WINDOWS' $host_windows + Set-BoolVar 'CI_MINGW' $mingw + Set-BoolVar 'CI_TARGET_LINUX' $target_linux + Set-BoolVar 'CI_TARGET_CYGWIN' $target_cygwin + Set-BoolVar 'CI_TARGET_WINDOWS' $target_windows + + Set-BoolVar 'CI_TARGET_PE' $target_pe + Set-BoolVar 'CI_TARGET_ELF' $target_elf + + $lib_prefix = 'lib' + $lib_ext = if ($target_windows -and -not $mingw) { '.lib' } else { '.a' } + + $dll_prefix = if ($target_windows -and -not $mingw) { '' } elseif ($target_cygwin) { 'cyg' } else { 'lib' } + $dll_ext = if ($target_windows -or $target_cygwin) { '.dll' } else { '.so' } + + $exe_ext = if ($target_pe) { '.exe' } else { '' } + + Set-StrVar 'CI_LIB_PREFIX' $lib_prefix + Set-StrVar 'CI_LIB_EXT' $lib_ext + Set-StrVar 'CI_DLL_PREFIX' $dll_prefix + Set-StrVar 'CI_DLL_EXT' $dll_ext + Set-StrVar 'CI_EXE_EXT' $exe_ext + + Set-BoolVar 'CI_DLL_IN_BIN' $target_pe + shell: pwsh diff --git a/.github/actions/download-boost/action.yml b/.github/actions/download-boost/action.yml new file mode 100644 index 0000000..fc0be88 --- /dev/null +++ b/.github/actions/download-boost/action.yml @@ -0,0 +1,40 @@ +name: Download Boost +description: Download & unpack Boost +inputs: + boost-version: + description: 'Boost version' + required: true +runs: + using: composite + steps: + - run: echo 'BOOST_VERSION=${{ inputs.boost-version }}' >> $env:GITHUB_ENV + shell: pwsh + - run: | + $parent_dir = Split-Path $env:GITHUB_WORKSPACE + $unpack_dir = Join-Path $parent_dir 'boost' + echo "BOOST_UNPACK_DIR=$unpack_dir" >> $env:GITHUB_ENV + shell: pwsh + - run: | + $dir_name = "boost_$($env:BOOST_VERSION.Replace('.', '_'))" + $dir = Join-Path $env:BOOST_UNPACK_DIR $dir_name + echo "BOOST_DIR=$dir" >> $env:GITHUB_ENV + shell: pwsh + - run: | + echo '' + echo '----------------------------------------------------------------' + echo "BOOST_VERSION: $env:BOOST_VERSION" + echo "BOOST_UNPACK_DIR: $env:BOOST_UNPACK_DIR" + echo "BOOST_DIR: $env:BOOST_DIR" + echo '----------------------------------------------------------------' + New-Item $env:BOOST_UNPACK_DIR -Type Directory | Out-Null + + $python = 'python' + $unpack_dir = $env:BOOST_UNPACK_DIR + + if ($env:CI_HOST_CYGWIN) { + $python = 'python3' + $unpack_dir = cygpath.exe -ua $unpack_dir + } + + & $python -m project.boost.download --unpack $unpack_dir -- $env:BOOST_VERSION + shell: pwsh diff --git a/.github/actions/run-example-boost/action.yml b/.github/actions/run-example-boost/action.yml new file mode 100644 index 0000000..0dd9f44 --- /dev/null +++ b/.github/actions/run-example-boost/action.yml @@ -0,0 +1,45 @@ +name: Run examples/boost +description: Run examples/boost +inputs: + path: + description: Installation directory + required: true +runs: + using: composite + steps: + - run: | + New-Variable path -Value '${{ inputs.path }}' -Option Constant + + if ($env:CI_HOST_LINUX -and -not $env:CI_TARGET_LINUX) { + echo 'Not going to do that on Linux/MinGW' + exit + } + + $relative_test = 'test.txt' + $absolute_test = Join-Path (Get-Location).Path 'test.txt' + + $exe_path = (Join-Path $path 'bin' 'foo') + if (-not $env:CI_TARGET_CYGWIN) { + $exe_path += $env:CI_EXE_EXT + } + + $argv0 = $exe_path + if ($env:CI_TARGET_CYGWIN) { + # Apparently, Cygwin programs convert argv[0] when executing native + # programs or being executed by them. + $argv0 = cygpath.exe -ua $argv0 + } + + $actual = & $exe_path $relative_test + + echo 'Actual output:' + echo $actual + + $expected = $argv0,$absolute_test + echo 'Expected output:' + echo $expected + + if (Compare-Object $actual $expected -CaseSensitive) { + throw 'Unexpected output' + } + shell: pwsh diff --git a/.github/actions/run-example/action.yml b/.github/actions/run-example/action.yml new file mode 100644 index 0000000..5300ab9 --- /dev/null +++ b/.github/actions/run-example/action.yml @@ -0,0 +1,28 @@ +name: Run example project +description: Run example project +inputs: + path: + description: Installation directory + required: true +runs: + using: composite + steps: + - run: | + New-Variable path -Value '${{ inputs.path }}' -Option Constant + + if ($env:CI_HOST_LINUX -and -not $env:CI_TARGET_LINUX) { + echo 'Not going to do that on Linux/MinGW' + exit + } + + if ($env:CI_TARGET_LINUX) { + $lib = Join-Path $path 'lib' + if (Test-Path $lib) { + $lib = Resolve-Path $lib + $env:LD_LIBRARY_PATH = $lib + } + } + $exe_path = (Join-Path $path 'bin' 'foo') + $env:CI_EXE_EXT + echo "Executable path: $exe_path" + & $exe_path + shell: pwsh diff --git a/.github/actions/software-environment/action.yml b/.github/actions/software-environment/action.yml new file mode 100644 index 0000000..c8a416b --- /dev/null +++ b/.github/actions/software-environment/action.yml @@ -0,0 +1,63 @@ +name: Set up software environment +description: Set up software paths and versions +inputs: + toolset: + description: Toolset to use + required: true + platform: + description: Target platform + required: false + default: x64 +runs: + using: composite + steps: + - run: | + if ($env:CI_HOST_WINDOWS) { + echo 'C:\Program Files\CMake\bin' >> $env:GITHUB_PATH + } + shell: pwsh + - run: | + echo '------------------------------------------------------------' + echo 'PATH' + echo '------------------------------------------------------------' + echo $env:PATH.Split([IO.Path]::PathSeparator) + shell: pwsh + - run: | + function Print-Info { + param( + [Parameter(Mandatory=$true)] + [string] $name, + [Parameter(Mandatory=$true)] + [string] $exe + ) + + echo '' + echo '------------------------------------------------------------' + echo $name + echo '------------------------------------------------------------' + $full_path = Get-Command $exe -ErrorAction SilentlyContinue + if ($full_path) { + $full_path = $full_path.Path + echo "Location: $full_path" + echo 'Version info:' + & $full_path --version + } else { + echo "Executable '$name' couldn't be found!" + } + } + + $python = 'python' + if ($env:CI_HOST_CYGWIN) { + $python = 'python3' + } + + Print-Info 'python' $python + Print-Info 'cmake' 'cmake' + Print-Info 'make' 'make' + Print-Info 'mingw32-make' 'mingw32-make' + Print-Info 'g++' 'g++' + Print-Info 'clang++' 'clang++' + Print-Info 'clang-cl' 'clang-cl' + Print-Info 'i686-w64-mingw32-g++' 'i686-w64-mingw32-g++' + Print-Info 'x86_64-w64-mingw32-g++' 'x86_64-w64-mingw32-g++' + shell: pwsh diff --git a/.github/workflows/boost_clang_windows.yml b/.github/workflows/boost_clang_windows.yml new file mode 100644 index 0000000..62c2cb5 --- /dev/null +++ b/.github/workflows/boost_clang_windows.yml @@ -0,0 +1,143 @@ +# This basically tests two things. +# +# * If, instead of some kind of MinGW-born ar & ranlib, you only have +# upstream LLVM distribution on Windows, you wouldn't be able to use +# toolset=clang until 1.66.0. +# * toolset=clang-win is broken until 1.69.0. + +name: Boost & Clang on Windows + +on: + push: + pull_request: + schedule: + # Weekly, at 5:30 AM on Saturday (somewhat randomly chosen). + - cron: '30 5 * * 6' + workflow_dispatch: + +jobs: + build: + runs-on: windows-2019 + + strategy: + fail-fast: false + matrix: + toolset: [clang, clang-cl] + boost-version: [1.63.0, 1.64.0, 1.65.1, 1.66.0, 1.67.0, 1.68.0, 1.69.0, 1.70.0, 1.71.0, 1.74.0] + include: + - {toolset: clang, b2_toolset: clang} + - {toolset: clang-cl, b2_toolset: clang-win} + + name: '${{ matrix.toolset }} / ${{ matrix.boost-version }}' + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Clean up PATH + uses: egor-tensin/cleanup-path@v1 + if: runner.os == 'Windows' + + - name: Set common variables + uses: ./.github/actions/common-variables + with: + toolset: '${{ matrix.toolset }}' + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Install Clang + uses: egor-tensin/setup-clang@v1 + + - name: Set up software environment + uses: ./.github/actions/software-environment + with: + toolset: ${{ matrix.toolset }} + + - name: Download Boost + uses: ./.github/actions/download-boost + with: + boost-version: ${{ matrix.boost-version }} + + - name: Bootstrap Boost + run: | + cd $env:BOOST_DIR + .\bootstrap.bat + continue-on-error: true + + - name: Check that Boost was bootstrapped + uses: ./.github/actions/check-boost-bootstrapped + + - name: Write toolset-config.jam (clang) + run: | + echo 'using ${{ matrix.b2_toolset }} : : clang++.exe : <archiver>llvm-ar <ranlib>llvm-ranlib ;' > "$env:BOOST_DIR\toolset-config.jam" + if: matrix.toolset == 'clang' + - name: Write toolset-config.jam (clang-cl) + run: | + echo 'using ${{ matrix.b2_toolset }} ;' > "$env:BOOST_DIR\toolset-config.jam" + if: matrix.toolset == 'clang-cl' + + - name: Build Boost.Filesystem + run: | + cd $env:BOOST_DIR + + $stagedir = "stage" + $librarydir = "$env:BOOST_DIR\$stagedir\lib" + echo "BOOST_LIBRARYDIR=$librarydir" >> $env:GITHUB_ENV + + .\b2.exe ` + "--stagedir=$stagedir" ` + --layout=system ` + --dump-configuration ` + address-model=64 ` + "--user-config=$env:BOOST_DIR\toolset-config.jam" ` + variant=debug ` + link=static ` + runtime-link=static ` + -d2 --dump-configuration ` + --with-filesystem ` + --with-system + continue-on-error: true + + - name: Boost.Filesystem failed to build + run: $(Test-Path "$env:BOOST_LIBRARYDIR\libboost_filesystem.lib" -Type Leaf) -and $(throw "libboost_filesystem.lib was build?!") + if: | + (matrix.toolset == 'clang' && matrix.boost-version < '1.66.0') || (matrix.toolset == 'clang-cl' && matrix.boost-version < '1.69.0') + - id: boost_filesystem_built + name: Boost.Filesystem was built + run: $(Test-Path "$env:BOOST_LIBRARYDIR\libboost_filesystem.lib" -Type Leaf) -or $(throw "libboost_filesystem.lib wasn't found") + if: | + !((matrix.toolset == 'clang' && matrix.boost-version < '1.66.0') || (matrix.toolset == 'clang-cl' && matrix.boost-version < '1.69.0')) + + # Check that we can link to the built libraries. + - name: Build foo.exe using clang + run: | + clang++.exe ` + "-I$env:BOOST_DIR" ` + -D BOOST_ALL_NO_LIB=1 ` + "-L$env:BOOST_LIBRARYDIR" ` + -llibboost_filesystem ` + -llibboost_system ` + -o foo.exe ` + examples/boost/foo.cpp + if: steps.boost_filesystem_built.conclusion == 'success' && matrix.toolset == 'clang' + + - name: Build foo.exe using clang-cl + run: | + clang-cl.exe ` + /EHsc ` + /MTd ` + "/I$env:BOOST_DIR" ` + /D BOOST_ALL_NO_LIB=1 ` + "/Fefoo.exe" ` + examples/boost/foo.cpp ` + libboost_filesystem.lib ` + libboost_system.lib ` + /link "/LIBPATH:$env:BOOST_LIBRARYDIR" + if: steps.boost_filesystem_built.conclusion == 'success' && matrix.toolset == 'clang-cl' + + - name: foo.exe + run: .\foo.exe + if: steps.boost_filesystem_built.conclusion == 'success' diff --git a/.github/workflows/boost_toolsets.yml b/.github/workflows/boost_toolsets.yml new file mode 100644 index 0000000..1319264 --- /dev/null +++ b/.github/workflows/boost_toolsets.yml @@ -0,0 +1,222 @@ +name: Boost (toolsets) + +on: + push: + pull_request: + schedule: + # Weekly, at 5:30 AM on Saturday (somewhat randomly chosen). + - cron: '30 5 * * 6' + workflow_dispatch: + +jobs: + build: + strategy: + fail-fast: false + matrix: + boost-version: [1.58.0, 1.65.0, 1.72.0] + toolset: [auto, clang, clang-cl, gcc, mingw, msvc] + cygwin: [0, 1] + os: [ubuntu-18.04, windows-2016, windows-2019] + + include: + # Prettier run names. + - {os: windows-2019, name: VS 2019} + - {os: windows-2016, name: VS 2017} + - {os: ubuntu-18.04, name: Ubuntu} + - {cygwin: 1, name: Cygwin} + # Target platform. + - {boost-version: 1.58.0, platform: x64} + - {boost-version: 1.65.0, platform: x86} + - {boost-version: 1.72.0, platform: x64} + # Configuration. + - {boost-version: 1.58.0, configuration: Debug} + - {boost-version: 1.65.0, configuration: MinSizeRel} + - {boost-version: 1.72.0, configuration: Release} + + # Some Boost libraries commonly used by me. + - libraries: filesystem program_options regex system test + # On Windows, clang fails to build Boost.Test prior to version 1.61 + # with the following error: + # + # .\boost/test/impl/execution_monitor.ipp:1134:20: error: cannot compile this 'this' captured by SEH yet + # + # This was fixed for 1.61 in this commit: + # https://github.com/boostorg/test/commit/c94ef6982e2ebe77f9376579547c228f0d62e45f. + # On Linux/Cygwin, everything should be fine though. + - toolset: clang + boost-version: 1.58.0 + os: windows-2019 + libraries: filesystem program_options regex system + - toolset: clang + boost-version: 1.58.0 + os: windows-2016 + libraries: filesystem program_options regex system + exclude: + # Ubuntu: no MSVC/clang-cl/Cygwin. + - {os: ubuntu-18.04, toolset: msvc} + - {os: ubuntu-18.04, toolset: clang-cl} + - {os: ubuntu-18.04, cygwin: 1} + # Cygwin: no MSVC/clang-cl. + - {cygwin: 1, toolset: msvc} + - {cygwin: 1, toolset: clang-cl} + # Cygwin is the same on Windows Server 2016 & 2019. + - {os: windows-2016, cygwin: 1} + # clang-cl is only supported by Boost.Build since 1.69 (see the + # boost_clang_windows.yml workflow). + - {toolset: clang-cl, boost-version: 1.58.0} + - {toolset: clang-cl, boost-version: 1.65.0} + + runs-on: '${{ matrix.os }}' + + name: '${{ matrix.boost-version }} / ${{ matrix.toolset }} / ${{ matrix.name }}' + + # 1) I have no idea why, but GCC 10.2 fails to build Boost.Filesystem with + # the following errors: + # + # libs\filesystem\src\path.cpp:36:11: fatal error: windows_file_codecvt.hpp: No such file or directory + # 36 | # include "windows_file_codecvt.hpp" + # | ^~~~~~~~~~~~~~~~~~~~~~~~~~ + # compilation terminated. + # libs\filesystem\src\windows_file_codecvt.cpp:25:10: fatal error: windows_file_codecvt.hpp: No such file or directory + # 25 | #include "windows_file_codecvt.hpp" + # | ^~~~~~~~~~~~~~~~~~~~~~~~~~ + # compilation terminated. + # + # This seems to be a compiler bug, since the file is _definitely_ there, + # and Clang 8.0.1 builds it successfully. This only applies to Boost + # versions up to and including 1.60.0 for some reason. I can easily + # reproduce this locally. TODO: remove when GCC on Cygwin is treated + # with a bugfix to this? + # + # 2) 32-bit Cygwin fucking sucks. In many ways actually, but the real + # reason was the incomprehensible + # + # undefined reference to `__chkstk_ms' + # + # error when building with Clang. + continue-on-error: ${{ + (matrix.cygwin == '1' && matrix.boost-version == '1.58.0' + && (matrix.toolset == 'auto' + || matrix.toolset == 'gcc' + || matrix.toolset == 'mingw')) + || (matrix.cygwin == '1' && matrix.platform == 'x86') + }} + + defaults: + run: + shell: pwsh + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Clean up PATH + uses: egor-tensin/cleanup-path@v1 + if: runner.os == 'Windows' + + - name: Set common variables + uses: ./.github/actions/common-variables + with: + toolset: '${{ matrix.toolset }}' + cygwin: '${{ matrix.cygwin }}' + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + if: '!env.CI_HOST_CYGWIN' + + - name: Install Cygwin + uses: egor-tensin/setup-cygwin@v3 + with: + platform: '${{ matrix.platform }}' + packages: cmake make python3 + hardlinks: 1 + if: env.CI_HOST_CYGWIN + + - name: Install GCC + uses: egor-tensin/setup-gcc@v1 + with: + cygwin: '${{ matrix.cygwin }}' + platform: '${{ matrix.platform }}' + hardlinks: 1 + if: env.CI_HOST_CYGWIN || (env.CI_HOST_LINUX && (matrix.toolset == 'auto' || matrix.toolset == 'gcc')) + + - name: Install Clang + uses: egor-tensin/setup-clang@v1 + with: + cygwin: '${{ matrix.cygwin }}' + platform: '${{ matrix.platform }}' + hardlinks: 1 + if: matrix.toolset == 'clang' || matrix.toolset == 'clang-cl' + + - name: Install MinGW + uses: egor-tensin/setup-mingw@v2 + with: + cygwin: '${{ matrix.cygwin }}' + platform: '${{ matrix.platform }}' + hardlinks: 1 + # toolset == 'clang' needs some kind of make, e.g. mingw32-make: + if: env.CI_MINGW || (matrix.toolset == 'clang' && env.CI_HOST_WINDOWS) + + - name: Set up software environment + uses: ./.github/actions/software-environment + with: + toolset: '${{ matrix.toolset }}' + platform: '${{ matrix.platform }}' + + - name: Set up Visual Studio + uses: egor-tensin/vs-shell@v2 + with: + arch: '${{ matrix.platform }}' + if: matrix.toolset == 'clang-cl' && env.CI_HOST_WINDOWS + + - name: Download Boost + uses: ./.github/actions/download-boost + with: + boost-version: '${{ matrix.boost-version }}' + + - name: Build Boost + uses: ./.github/actions/build-boost + with: + toolset: '${{ matrix.toolset }}' + libraries: '${{ matrix.libraries }}' + platform: '${{ matrix.platform }}' + configuration: '${{ matrix.configuration }}' + continue-on-error: true + + - name: Check that Boost was bootstrapped + uses: ./.github/actions/check-boost-bootstrapped + + - name: Check that Boost libraries were built + uses: ./.github/actions/check-boost-libraries + with: + libraries: '${{ matrix.libraries }}' + platform: '${{ matrix.platform }}' + configuration: '${{ matrix.configuration }}' + + - name: Build examples/boost + id: build_example + uses: ./.github/actions/build-example + with: + src-dir: examples/boost + boost-dir: '${{ env.BOOST_DIR }}' + toolset: '${{ matrix.toolset }}' + platform: '${{ matrix.platform }}' + configuration: '${{ matrix.configuration }}' + + - name: Verify runtime library linkage + uses: ./.github/actions/check-runtime-library + with: + path: '${{ steps.build_example.outputs.install-dir }}' + + - name: Verify architecture + uses: ./.github/actions/check-arch + with: + path: '${{ steps.build_example.outputs.install-dir }}' + expected: '${{ matrix.platform }}' + + - name: Run examples/boost + uses: ./.github/actions/run-example-boost + with: + path: '${{ steps.build_example.outputs.install-dir }}' diff --git a/.github/workflows/cygwin_static_libstdc++.yml b/.github/workflows/cygwin_static_libstdc++.yml new file mode 100644 index 0000000..156b111 --- /dev/null +++ b/.github/workflows/cygwin_static_libstdc++.yml @@ -0,0 +1,81 @@ +# -static-libstdc++ is broken on Cygwin for some reason, as this workflow tries +# to demonstrate. I don't know why exactly, but I'm not the only one with this +# problem: +# +# * https://stackoverflow.com/q/46854365/514684 +# * https://sourceforge.net/p/stlplus/discussion/345536/thread/48c7fc9c17/?limit=25 + +name: Cygwin & -static-libstdc++ + +on: + push: + pull_request: + schedule: + # Weekly, at 5:30 AM on Saturday (somewhat randomly chosen). + - cron: '30 5 * * 6' + workflow_dispatch: + +jobs: + test: + runs-on: windows-2019 + + name: Test + + defaults: + run: + shell: pwsh + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Clean up PATH + uses: egor-tensin/cleanup-path@v1 + if: runner.os == 'Windows' + + - name: Set common variables + uses: ./.github/actions/common-variables + with: + toolset: '${{ matrix.toolset }}' + cygwin: 1 + + - name: Install Cygwin + uses: egor-tensin/setup-cygwin@v3 + + - name: Install GCC + uses: egor-tensin/setup-gcc@v1 + with: + cygwin: 1 + + - name: Set up software environment + uses: ./.github/actions/software-environment + with: + toolset: gcc + + - name: test.cpp + run: | + $src = @" + #include <stdexcept> + + int main() { + std::runtime_error x{"x"}; + std::runtime_error y{x}; + return 0; + } + "@ + + echo $src > test.cpp + + - name: Build w/ -static-libstdc++ + run: C:\tools\cygwin\bin\g++.exe -static-libstdc++ -o test test.cpp + continue-on-error: true + + - name: Should fail + run: $(Test-Path test.exe -Type Leaf) -and $(throw "test.exe shouldn't have been built") + + - name: Build w/ --allow-multiple-definition + run: C:\tools\cygwin\bin\g++.exe '-Wl,--allow-multiple-definition' -static-libstdc++ -o test test.cpp + continue-on-error: true + + - name: Should succeed + run: $(Test-Path test.exe -Type Leaf) -or $(throw "test.exe should have been built") diff --git a/.github/workflows/example_toolsets.yml b/.github/workflows/example_toolsets.yml new file mode 100644 index 0000000..cb336aa --- /dev/null +++ b/.github/workflows/example_toolsets.yml @@ -0,0 +1,168 @@ +name: Examples (toolsets) + +on: + push: + pull_request: + schedule: + # Weekly, at 5:30 AM on Saturday (somewhat randomly chosen). + - cron: '30 5 * * 6' + workflow_dispatch: + +jobs: + build: + strategy: + fail-fast: false + matrix: + example: [simple, static, dynamic] + toolset: [auto, clang, clang-cl, gcc, mingw, msvc] + cygwin: [0, 1] + os: [ubuntu-18.04, windows-2016, windows-2019] + + include: + # Prettier run names. + - {os: windows-2019, name: VS 2019} + - {os: windows-2016, name: VS 2017} + - {os: ubuntu-18.04, name: Ubuntu} + - {cygwin: 1, name: Cygwin} + # Target platform. + - {example: simple, platform: x64} + - {example: static, platform: x86} + - {example: dynamic, platform: x64} + # Configuration. + - {example: simple, configuration: Release} + - {example: static, configuration: Debug} + - {example: dynamic, configuration: RelWithDebInfo} + # Expected symbols. + - example: simple + symbols: + - target: foo + type: exe + symbols: [] + - example: static + symbols: + - target: foo + type: exe + symbols: [main, bar] + - example: dynamic + symbols: + - target: foo + type: exe + symbols: [main] + - target: baz + type: dll + symbols: [baz] + exclude: + # Ubuntu: no MSVC/clang-cl/Cygwin. + - {os: ubuntu-18.04, toolset: msvc} + - {os: ubuntu-18.04, toolset: clang-cl} + - {os: ubuntu-18.04, cygwin: 1} + # Cygwin: no MSVC/clang-cl. + - {cygwin: 1, toolset: msvc} + - {cygwin: 1, toolset: clang-cl} + # Cygwin is the same on Windows Server 2016 & 2019. + - {os: windows-2016, cygwin: 1} + + runs-on: '${{ matrix.os }}' + + name: '${{ matrix.example }} / ${{ matrix.toolset }} / ${{ matrix.name }}' + + defaults: + run: + shell: pwsh + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Clean up PATH + uses: egor-tensin/cleanup-path@v1 + if: runner.os == 'Windows' + + - name: Set common variables + uses: ./.github/actions/common-variables + with: + toolset: '${{ matrix.toolset }}' + cygwin: '${{ matrix.cygwin }}' + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + if: '!env.CI_HOST_CYGWIN' + + - name: Install Cygwin + uses: egor-tensin/setup-cygwin@v3 + with: + platform: '${{ matrix.platform }}' + packages: cmake make python3 + hardlinks: 1 + if: env.CI_HOST_CYGWIN + + - name: Install GCC + uses: egor-tensin/setup-gcc@v1 + with: + cygwin: '${{ matrix.cygwin }}' + platform: '${{ matrix.platform }}' + hardlinks: 1 + if: (env.CI_HOST_LINUX || env.CI_HOST_CYGWIN) && (matrix.toolset == 'auto' || matrix.toolset == 'gcc') + + - name: Install Clang + uses: egor-tensin/setup-clang@v1 + with: + cygwin: '${{ matrix.cygwin }}' + platform: '${{ matrix.platform }}' + hardlinks: 1 + if: matrix.toolset == 'clang' || matrix.toolset == 'clang-cl' + + - name: Install MinGW + uses: egor-tensin/setup-mingw@v2 + with: + cygwin: '${{ matrix.cygwin }}' + platform: '${{ matrix.platform }}' + hardlinks: 1 + # toolset == 'clang' needs some kind of make, e.g. mingw32-make: + if: env.CI_MINGW || (matrix.toolset == 'clang' && env.CI_HOST_WINDOWS) + + - name: Set up software environment + uses: ./.github/actions/software-environment + with: + toolset: '${{ matrix.toolset }}' + platform: '${{ matrix.platform }}' + + - name: Set up Visual Studio + uses: egor-tensin/vs-shell@v2 + with: + arch: '${{ matrix.platform }}' + if: matrix.toolset == 'clang-cl' && env.CI_HOST_WINDOWS + + - name: Build example project + id: build + uses: ./.github/actions/build-example + with: + src-dir: 'examples/${{ matrix.example }}' + toolset: '${{ matrix.toolset }}' + platform: '${{ matrix.platform }}' + configuration: '${{ matrix.configuration }}' + + - name: Verify runtime library linkage + uses: ./.github/actions/check-runtime-library + with: + path: '${{ steps.build.outputs.install-dir }}' + + - name: Verify architecture + uses: ./.github/actions/check-arch + with: + path: '${{ steps.build.outputs.install-dir }}' + expected: '${{ matrix.platform }}' + + - name: Run example project + uses: ./.github/actions/run-example + with: + path: '${{ steps.build.outputs.install-dir }}' + + - name: Check symbols + uses: ./.github/actions/check-symbols + with: + path: '${{ steps.build.outputs.install-dir }}' + expected: '${{ toJson(matrix.symbols) }}' + if: env.CI_TARGET_ELF |