Skip to content

Commit

Permalink
Allow installing ARM64 images (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusJx authored Apr 27, 2022
1 parent 9241b9d commit 60e4230
Show file tree
Hide file tree
Showing 14 changed files with 177 additions and 26 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/test-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,39 @@ jobs:
- os: ubuntu-20.04
COMPILER: gcc
PLATFORM: 20.04
ARCH: x86
- os: ubuntu-20.04
COMPILER: gcc
PLATFORM: 20.04
ARCH: aarch64
- os: windows-2019
COMPILER: msvc
PLATFORM: 2019
ARCH: x86
- os: windows-2019
COMPILER: mingw
PLATFORM: 2019
ARCH: x86

steps:
- uses: actions/checkout@v2
- name: Install boost
uses: ./
id: install-boost
with:
boost_version: 1.78.0
boost_version: 1.79.0
platform_version: ${{matrix.PLATFORM}}
toolset: ${{matrix.COMPILER}}
arch: ${{matrix.ARCH}}

- name: Setup MinGW
uses: egor-tensin/setup-mingw@v2
if: ${{runner.os == 'Windows' && matrix.COMPILER == 'mingw'}}

- name: Install arm64 compiler
run: sudo apt-get update && sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y
if: matrix.ARCH == 'aarch64'

- name: Configure CMake mingw
shell: bash
working-directory: test
Expand All @@ -50,11 +62,19 @@ jobs:
env:
BOOST_ROOT: ${{steps.install-boost.outputs.BOOST_ROOT}}

- name: Configure CMake arm64
shell: bash
working-directory: test
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_ARM_BINARIES=1 -DBoost_LIBRARY_DIRS="${{steps.install-boost.outputs.BOOST_ROOT}}/lib" -B build
if: matrix.ARCH == 'aarch64'
env:
BOOST_ROOT: ${{steps.install-boost.outputs.BOOST_ROOT}}

- name: Configure CMake
shell: bash
working-directory: test
run: cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBoost_LIBRARY_DIRS="${{steps.install-boost.outputs.BOOST_ROOT}}/lib" -B build
if: ${{matrix.COMPILER != 'mingw'}}
if: ${{matrix.COMPILER != 'mingw' && matrix.ARCH != 'aarch64'}}
env:
BOOST_ROOT: ${{steps.install-boost.outputs.BOOST_ROOT}}
- name: Build
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ default both static and shared libraries. On windows, only ``static`` or ``share
may be specified, as these binares can only contain either static or shared libraries.
If nothing is specified, static libraries will be preferred.

### `arch`
**Optional** The architecture the binares were built for. Must be either ``x86`` for
default x86/amd64 or ``aarch64`` for arm64 systems. The ``x86`` can be used for
the default github runners, the ``aarch64`` images may be used for cross-compiling
binaries for arm systems. If not set, ``x86`` images will be used. Only works on
``linux`` images with version ``20.04`` (or just specify no os version).

## Outputs
### `BOOST_ROOT`
The boost root directory path, to be passed to another tool, e.g. CMake to find Boost:
Expand All @@ -52,6 +59,17 @@ The boost root directory path, to be passed to another tool, e.g. CMake to find
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
```
**Notes**: Sometimes you'll have to pass the path to the include and library directories to cmake:
```yml
- name: Configure CMake
run: |
cmake . -DCMAKE_BUILD_TYPE=$BUILD_TYPE -B build\
-DBoost_INCLUDE_DIR=${{steps.install-boost.outputs.BOOST_ROOT}}/include\
-DBoost_LIBRARY_DIRS=${{steps.install-boost.outputs.BOOST_ROOT}}/lib
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
```
### `BOOST_VER`
The version of boost installed, e.g. ``boost-1.73.0-linux-16.04``.

Expand Down Expand Up @@ -93,6 +111,8 @@ The version of boost installed, e.g. ``boost-1.73.0-linux-16.04``.
boost_install_dir: /home/runner/some_directory
# OPTIONAL: Specify a toolset
toolset: gcc
# OPTIONAL: Specify an architecture
arch: x86
# NOTE: If a boost version matching all requirements cannot be found,
# this build step will fail
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ inputs:
description: 'Whether the boost libraries are linked statically or dynamically'
required: false
default: ''
arch:
description: 'The architecture the binaries were built for'
required: false
default: 'x86'
boost_install_dir:
description: 'The dirctory to install boost into'
required: false
Expand Down
25 changes: 20 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function main() {
const platform_version = core.getInput("platform_version");
const boost_install_dir = core.getInput("boost_install_dir");
const link = core.getInput("link");
const arch = core.getInput("arch");
let script_version = core.getInput("version");
if (boost_version.length <= 0) {
throw new Error("the boost_version variable must be defined");
Expand All @@ -50,14 +51,17 @@ function main() {
if (link && link !== "static" && link !== "shared" && link !== "static+shared") {
throw new Error("'link' must be one of: 'static', 'shared' or 'static+shared'");
}
if (arch && arch !== "x86" && arch !== "aarch64") {
throw new Error("'arch' must be one of: 'x86' or 'aarch64'");
}
if (script_version === "legacy") {
if (link) {
core.warning("The script version was set to 'legacy', but the 'link' option was supplied, ignoring this");
}
yield installV1_1.default(boost_version, toolset, platform_version, BOOST_ROOT_DIR);
}
else if (script_version === "default") {
yield installV2_1.default(boost_version, toolset, platform_version, link, BOOST_ROOT_DIR);
yield installV2_1.default(boost_version, toolset, platform_version, link, arch, BOOST_ROOT_DIR);
}
else {
throw new Error("Invalid value entered for option 'version'");
Expand Down Expand Up @@ -155,12 +159,12 @@ const core = __nccwpck_require__(2186);
const path = __nccwpck_require__(5622);
const shared_1 = __nccwpck_require__(6058);
const VERSION_MANIFEST_ADDR = "https://raw.githubusercontent.com/MarkusJx/prebuilt-boost/main/versions-manifest.json";
function installV2(boost_version, toolset, platform_version, link, BOOST_ROOT_DIR) {
function installV2(boost_version, toolset, platform_version, link, arch, BOOST_ROOT_DIR) {
return __awaiter(this, void 0, void 0, function* () {
console.log("Downloading versions-manifest.json...");
const versions = yield shared_1.getVersions(VERSION_MANIFEST_ADDR);
console.log("Parsing versions-manifest.json...");
const ver_data = shared_1.parseArguments(versions, boost_version, toolset, platform_version, link);
const ver_data = shared_1.parseArguments(versions, boost_version, toolset, platform_version, link, arch);
const download_url = ver_data.url;
const filename = ver_data.filename;
core.startGroup(`Create ${BOOST_ROOT_DIR}`);
Expand Down Expand Up @@ -257,7 +261,7 @@ exports.createDirectory = createDirectory;
* @param platform_version the requested platform version
* @returns the url and file name or throws an error if the requested version could not be found
*/
function parseArguments(versions, boost_version, toolset, platform_version, link = null) {
function parseArguments(versions, boost_version, toolset, platform_version, link = null, arch = null) {
let platform = process.platform;
if (platform === "darwin") {
platform = "macos";
Expand Down Expand Up @@ -294,7 +298,18 @@ function parseArguments(versions, boost_version, toolset, platform_version, link
continue;
}
else if (!link && file.hasOwnProperty("link") && file["link"] === "shared") {
core.debug("The file's 'link' was set to 'shared', but 'link' was specified, ignoring this file");
core.debug("The file's 'link' was set to 'shared', but 'link' was not specified, ignoring this file");
continue;
}
if (arch && !file["arch"]) {
core.warning("The parameter 'arch' was specified, which doesn't have any effect on this boost version");
}
else if (arch && file.hasOwnProperty("arch") && arch !== file["arch"]) {
core.debug("File does not match param 'arch'");
continue;
}
else if (!arch && file.hasOwnProperty("arch") && file["arch"] !== "x86") {
core.debug("The file's 'arch' was not set to 'x86', but 'arch' was not specified, ignoring this file");
continue;
}
return { url: file["download_url"], filename: file["filename"] };
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/installV2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/installV2.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions dist/shared.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 60e4230

Please sign in to comment.