Coder Social home page Coder Social logo

build-boost's Introduction

Build Boost

Test Boost.Python

This GitHub action downloads & builds Boost libraries in your workflow run.

  • Downloads a distribution of the specified Boost version and unpacks it.
  • Builds the required libraries using the specified toolset.

Use it in your workflow like this:

- name: Build Boost
  id: boost
  uses: egor-tensin/build-boost@v1
  with:
    version: 1.71.0
    libraries: filesystem program_options system
    platform: x64
    configuration: Release

- name: Show paths
  run: |
    printf 'Boost has been unpacked to: %s\n' '${{ steps.boost.outputs.root }}'
    printf 'Libraries can be found here: %s\n' '${{ steps.boost.outputs.librarydir }}'
  shell: bash
  • x64 is the default value for the platform parameter and can be omitted. Use x86 if you want to build 32-bit binaries.
  • Release is the default value for the configuration parameter and can be omitted. Use Debug if you want to build debug binaries.
  • Set static to 1 if you want to build static libraries.
  • Set static-runtime to 1 if you want to link to the static runtime.

API

Input Value Default Description
version required Boost version to build, e.g. 1.71.0.
libraries required Space-separated list of libraries to build, e.g. filesystem program_options system.
toolset auto Use GCC on Linux and MSVC on Windows.
msvc Use MSVC. Supports different versions [1].
vs Visual Studio; same as "msvc". Supports different versions [2].
gcc Use GCC.
mingw Use MinGW-w64.
clang Use Clang.
platform x64 Build 64-bit binaries.
x86 Build 32-bit binaries.
configuration Release Build Release binaries.
Debug Build Debug binaries.
static any Shared libraries.
1 Static libraries.
static-runtime any Link to the shared runtime.
1 Link to the static runtime.
directory empty Build in ${{ runner.workspace }}/boost.
any Build in a custom directory.
  1. Toolset "msvc" can have an optional version suffix: msvc140, msvc141, msvc142, msvc143.
  2. Toolset "vs" can have an optional version suffix: vs2015, vs2017, vs2019, vs2022.
Output Example CMake input Description
root D:\a\project\boost BOOST_ROOT Root Boost directory.
librarydir D:\a\project\boost\stage\x64\Debug\lib BOOST_LIBRARYDIR Directory that contains the built libraries.

Use the librarydir output to locate the built libraries. You can pass it to CMake using the BOOST_LIBRARYDIR parameter:

> cmake -D "BOOST_ROOT=${{ steps.boost.outputs.root }}" \
        -D "BOOST_LIBRARYDIR=${{ steps.boost.outputs.librarydir }}" \
        ...

Caching

Cache the Boost distribution archive by using the actions/cache action. For example, for Boost version 1.72.0:

- name: Cache Boost
  uses: actions/cache@v2
  with:
    path: '${{ runner.workspace }}/boost_*.tar.gz'
    key: 'boost-1.72.0'

- name: Build Boost
  # This won't re-download the archive unnecessarily:
  uses: egor-tensin/build-boost@v1
  with:
    version: 1.72.0
  ...

Boost.Python

See an example CMakeLists.txt file for how to link to Boost.Python libraries using CMake.

Notes

  • This action uses my other project cmake-common to actually download and build Boost.
  • cmake-common sees a lot more testing than this action, while this action delegates almost everything to it.
  • You can use my other actions setup-gcc, setup-mingw, setup-clang to set up different toolsets targetting both x86 and x64.

License

Distributed under the MIT License. See LICENSE.txt for details.

build-boost's People

Contributors

egor-tensin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

build-boost's Issues

Support for vs2022 and msvc143

Is this a planned addition? If I specify windows-2022 and use MSVC 14.3 I just get this error:
boost-build: error: argument --toolset: invalid Visual Studio version: 2022

Running on macOS?

It does not seem to work on macOS or am I doing something wrong here?

I'm getting

  shell: /usr/local/bin/pwsh -command ". '{0}'"
110
  env:
111
    BUILD_TYPE: Release
113
boost-download: /Users/runner/work/_temp/c0677176-fc7f-4b75-9376-a283096882c9.ps1:38
114
Line |
115
  38 |  boost-download --cache $base_dir -- $version $boost_dir
116
     |  ~~~~~~~~~~~~~~
117
     | The term 'boost-download' is not recognized as a name of a
118
     | cmdlet, function, script file, or executable program. Check
119
     | the spelling of the name, or if a path was included, verify
120
     | that the path is correct and try again.

Action fails with installing boost python libs in windows-latest runner

Github action:

      - name: Build Boost        
        uses: egor-tensin/build-boost@v1
        id: boost
        with:
          version: 1.73.0
          toolset: msvc142
          libraries: atomic chrono context coroutine container date_time exception filesystem graph graph_parallel iostreams locale log math mpi program_options python random regex serialization signals system test thread timer wave

Produces the following error:

2022-03-22 18:09:55 | INFO | Trying URL: https://boostorg.jfrog.io/artifactory/main/release/1.73.0/source/boost_1_73_0.tar.gz
2022-03-22 18:10:00 | INFO | Writing Boost archive: D:\a\hyprdsp\boost_1_73_0.tar.gz
2022-03-22 18:10:00 | INFO | Unpacking Boost to: D:\a\hyprdsp\boost_1_73_0
2022-03-22 18:10:41 | INFO | Running executable: ['.\\bootstrap.bat']
Building Boost.Build engine

Failed to build Boost.Build engine.
Please consult bootstrap.log for further diagnostics.

2022-03-22 18:10:42 | ERROR | Command '['.\\bootstrap.bat']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "C:\Users\runneradmin\AppData\Roaming\Python\Python39\site-packages\project\utils.py", line 64, in setup_logging
    yield
  File "C:\Users\runneradmin\AppData\Roaming\Python\Python39\site-packages\project\boost\build.py", line 202, in _main
    build(BuildParameters.from_cmd_args(args))
  File "C:\Users\runneradmin\AppData\Roaming\Python\Python39\site-packages\project\boost\build.py", line 138, in build
    boost_dir.build(params)
  File "C:\Users\runneradmin\AppData\Roaming\Python\Python39\site-packages\project\boost\directory.py", line 25, in build
    self._bootstrap_if_required(params)
  File "C:\Users\runneradmin\AppData\Roaming\Python\Python39\site-packages\project\boost\directory.py", line 32, in _bootstrap_if_required
    self.bootstrap(params)
  File "C:\Users\runneradmin\AppData\Roaming\Python\Python39\site-packages\project\boost\directory.py", line 36, in bootstrap
    run([self._bootstrap_path()] + self._bootstrap_args(params.toolset_version))
  File "C:\Users\runneradmin\AppData\Roaming\Python\Python39\site-packages\project\utils.py", line 82, in run
    return subprocess.run(cmd_line, check=True, **kwargs)
  File "C:\hostedtoolcache\windows\Python\3.9.10\x64\lib\subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['.\\bootstrap.bat']' returned non-zero exit status 1.

under the windows-latest github runner

Possibility of b2 invocation with explicit "cxxstd=20" argument

Great action. Already saved me a lot of hassle with the yml files.
I might have a little corner case(?), where it seems I need to invoke b2 with "cxxstd=20" argument.

Is this in any way possible already or would it make sense to make it possible in your opinion?

Background:
I'm experimenting with the new boost::cobalt library, which reqiures C++20 to be build.
This library-binaries doesn't seem to be build on a standard setup, either on github actions, my local environment or by downloading the pre-build windows releases.

The only way I was able to actually build it, was to invoke b2 with an explicit "cxxstd=20" argument. After that it was available inside the boost staging area. My assumption is, this is not the default value(?).

Can't find boost python library

Using this action to build python boost library i get the following error when running a cmake file with:

# boost
set(Boost_NO_SYSTEM_PATHS true)
set (Boost_USE_STATIC_LIBS OFF CACHE BOOL "use static libraries from Boost")
set (Boost_USE_MULTITHREADED ON)
set (BUILD_SHARED_LIBS ON)
find_package(Boost REQUIRED COMPONENTS python REQUIRED)

Action Setup:

jobs:
  build:
    name: Build and Test
    runs-on: windows-latest
    strategy:
      matrix:
        python-version: ["3.9"]
        
    steps:
    - name: Checkout branch
      uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
          python-version: ${{ matrix.python-version }}
    - name: Get cmake
      uses: lukka/get-cmake@latest
    - name: Build Boost
      id: boost
      uses: egor-tensin/build-boost@v1
      with:
        version: 1.78.0
        libraries: headers system python
        platform: x64
        configuration: Release
        toolset: vs2022
    - name: Configure
      run: |
        mkdir build
        cd build
        cmake .. -D "BOOST_ROOT=${{ steps.boost.outputs.root }}" -D "BOOST_LIBRARYDIR=${{ steps.boost.outputs.librarydir }}" 
      env:
        BOOST_ROOT: ${{ steps.boost.outputs.root }}

CMake can't find libraries: Could NOT find Boost (missing: python) (found version "1.78.0")

Is there anything i do wrong?

Does not seem to work with CMake find_package

Hi,

thanks a lot for your great action!

So, it seems that CMake cannot really use this with find_package. The output dir has nice libs with clear names, but find_package creates different output lib file names... Is this known? I could just hard-code the filenames, of course, but it's not just as nice and would not work outside of GitHub Actions.

Build Boost for C#

I want to use Boost Libraries in C#. Is it possible and how can I achieve that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.