aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/action.yml
blob: 1448e6e0888239e421406ff850ed84fd45516280 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Build Boost
description: Download & build Boost

inputs:
  version:
    description: Version to build
    required: true
  libraries:
    description: Space-separated list of libraries
    required: true
  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: Release
  static:
    description: Build static libraries
    required: false
    default: 0
  static-runtime:
    description: Link to the static runtime
    required: false
    default: 0
  directory:
    description: Destination directory
    required: false

outputs:
  root:
    description: Root Boost directory
    value: '${{ steps.build.outputs.root }}'
  librarydir:
    description: Directory with built Boost libraries
    value: '${{ steps.build.outputs.librarydir }}'

runs:
  using: composite
  steps:
    - id: install
      run: |
        New-Variable os -Value '${{ runner.os }}' -Option Constant
        New-Variable windows_host -Value ($os -eq 'Windows') -Option Constant

        if (Get-Command python3 -ErrorAction SilentlyContinue) {
            $python = @('python3')
        } elseif (Get-Command py -ErrorAction SilentlyContinue) {
            $python = @('py', '-3')
        } elseif (Get-Command python -ErrorAction SilentlyContinue) {
            $python = @('python')
        } else {
            echo @'
        ::error ::
        egor-tensin/build-boost depends on a PyPI package, which requires Python 3.6 or later.
        We couldn't find a Python installation in this environment.
        '@
            exit 1
        }

        $exe, $args = $python
        & $exe $args -m pip install --user --upgrade cmake-common~=3.0

        if ($windows_host) {
            $bin_dir = & $exe $args -c "import sysconfig; print(sysconfig.get_path('scripts', 'nt_user'))"
        } else {
            $bin_dir = & $exe $args -c "import sysconfig; print(sysconfig.get_path('scripts', 'posix_user'))"
        }

        echo "::set-output name=bin_dir::$bin_dir"
      env:
        PIP_NO_PYTHON_VERSION_WARNING: 1
        PIP_DISABLE_PIP_VERSION_CHECK: 1
        # This is hilarious: --no-warn-script-location is defined with
        # action='store_false', which is why it's kind of inverted compared to
        # the options above.
        # https://github.com/pypa/pip/issues/5200
        PIP_NO_WARN_SCRIPT_LOCATION: 0
      shell: pwsh

    - id: build
      run: |
        New-Variable os -Value '${{ runner.os }}' -Option Constant
        New-Variable windows_host -Value ($os -eq 'Windows') -Option Constant
        New-Variable macos_host -Value ($os -eq 'macOS') -Option Constant

        New-Variable base_dir -Value '${{ runner.workspace }}' -Option Constant
        New-Variable version -Value '${{ inputs.version }}' -Option Constant
        New-Variable toolset -Value '${{ inputs.toolset }}' -Option Constant
        New-Variable platform -Value '${{ inputs.platform }}' -Option Constant
        New-Variable configuration -Value '${{ inputs.configuration }}' -Option Constant
        New-Variable static -Value ('${{ inputs.static }}' -eq '1') -Option Constant
        New-Variable static_runtime -Value ('${{ inputs.static-runtime }}' -eq '1') -Option Constant

        $boost_dir = '${{ inputs.directory }}'
        if (-not $boost_dir) {
            $boost_dir = Join-Path $base_dir boost
        }

        $libraries = '${{ inputs.libraries }}'
        $libraries = $libraries.Split(' ', [System.StringSplitOptions]::RemoveEmptyEntries)

        if (-not $libraries) {
            echo @'
        ::warning ::
        No Boost libraries were explicitly selected for building, going to try to build them all.
        This is likely to fail.
        '@
        }

        $libraries = $libraries | %{"--with-$_"}

        $bin_dir = '${{ steps.install.outputs.bin_dir }}'
        $path_sep = [IO.Path]::PathSeparator
        $env:Path = "$bin_dir$path_sep$env:PATH"

        $link = if ($static) {'static'} else {'shared'}
        $runtime_link = if ($static_runtime) {'static'} else {'shared'}

        if ($macos_host) {
            # This is pure insanity. For some reason, the Python's bin/
            # directory is in Path, but not in PATH (found out using echo)!
            # Every person responsible for this mess is insane.
            $env:PATH = $env:Path
        }

        boost-download --cache $base_dir -- $version $boost_dir
        boost-build `
            --toolset $toolset `
            --platform $platform `
            --configuration $configuration `
            --link $link `
            --runtime-link $runtime_link `
            -- `
            $boost_dir `
            $libraries

        $platformdir = $platform
        if ($platformdir -eq 'auto' -and $windows_host) {
            $platformdir = 'x64'
        }
        $librarydir = Join-Path $boost_dir 'stage' $platformdir $configuration 'lib'

        echo "::set-output name=root::$boost_dir"
        echo "::set-output name=librarydir::$librarydir"
      shell: pwsh

branding:
  icon: star
  color: green