Skip to content

Commit

Permalink
Merge pull request #148 from ecmwf-actions/feature/toolchain-file
Browse files Browse the repository at this point in the history
Support cmake toolchain files
  • Loading branch information
figi44 committed Jun 22, 2023
2 parents 3bfbc6f + 2d58cef commit 35bda4e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ inputs:
description: Current Fortran compiler alias.
required: false
default: ${{ matrix.compiler_fc }}
toolchain_file:
description: Path to toolchan file.
required: false
default: ${{ matrix.toolchain_file }}
github_token:
description: Github access token, with `repo` and `actions:read` scopes.
required: true
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/build-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ const buildPackage = async (
env: EnvironmentVariables,
parallelismFactor: string,
cpackGenerator?: string,
cpackOptions?: string
cpackOptions?: string,
toolchainFile?: string
): Promise<boolean> => {
core.startGroup(`Build ${repository}`);

Expand Down Expand Up @@ -165,6 +166,11 @@ const buildPackage = async (
const srcDir = path.resolve(sourceDir);
core.info(`==> srcDir: ${srcDir}`);

if (toolchainFile && fs.existsSync(toolchainFile)) {
configureOptions.push(`-DCMAKE_TOOLCHAIN_FILE=${toolchainFile}`);
core.info(`==> using toolchain file: ${toolchainFile}`);
}

const cmakeOptionsFile = path.join(srcDir, ".github", ".cmake-options");
const deprecatedCmakeOptionsFile = path.join(
srcDir,
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import main from "./main";
* @param {string} compiler_cc Current C compiler alias.
* @param {string} compiler_cxx Current C++ compiler alias.
* @param {string} compiler_fc Current Fortran compiler alias.
* @param {string} toolchain_file Path to toolchain file.
* @param {string} github_token Github access token, with `repo` and `actions:read` scopes.
* @param {string} install_dir Directory where the dependencies and current package will be installed. Each
* dependency will be installed in its own subdirectory.
Expand Down
11 changes: 9 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ const main = async () => {
const compilerCc = core.getInput("compiler_cc", { required: false });
const compilerCxx = core.getInput("compiler_cxx", { required: false });
const compilerFc = core.getInput("compiler_fc", { required: false });
const toolchain_file = core.getInput("toolchain_file", {
required: false,
});
const githubToken = core.getInput("github_token", { required: true });
const installDir = core.getInput("install_dir", { required: true });
const downloadDir = core.getInput("download_dir", { required: true });
Expand Down Expand Up @@ -188,7 +191,10 @@ const main = async () => {
os,
compiler,
env,
parallelismFactor
parallelismFactor,
undefined,
undefined,
toolchain_file
);

if (!isBuilt) return Promise.reject("Error building dependency");
Expand Down Expand Up @@ -254,7 +260,8 @@ const main = async () => {
env,
parallelismFactor,
cpackGenerator,
cpackOptions
cpackOptions,
toolchain_file
);

if (!isBuilt) return Promise.reject("Error building package");
Expand Down
16 changes: 13 additions & 3 deletions tests/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ describe("main", () => {
testEnv,
inputs.parallelism_factor,
undefined,
undefined,
undefined
);
});
Expand Down Expand Up @@ -279,7 +280,10 @@ describe("main", () => {
inputs.os,
inputs.compiler,
testEnv,
inputs.parallelism_factor
inputs.parallelism_factor,
undefined,
undefined,
undefined
);
expect(buildPackage).toHaveBeenCalledWith(
inputs.dependencies[1],
Expand All @@ -293,7 +297,10 @@ describe("main", () => {
inputs.os,
inputs.compiler,
testEnv,
inputs.parallelism_factor
inputs.parallelism_factor,
undefined,
undefined,
undefined
);
expect(buildPackage).toHaveBeenCalledWith(
inputs.dependencies[2],
Expand All @@ -307,7 +314,10 @@ describe("main", () => {
inputs.os,
inputs.compiler,
testEnv,
inputs.parallelism_factor
inputs.parallelism_factor,
undefined,
undefined,
undefined
);
});

Expand Down

0 comments on commit 35bda4e

Please sign in to comment.