Skip to content

Commit

Permalink
Add optional target parameter for build
Browse files Browse the repository at this point in the history
Introduced an optional target parameter in both 'action.yml' and 'index.js' to directly specify the target to build. Adjusted the build process in 'builder.js' to use this new target parameter when building, and also to reflect the target in the cache key.
  • Loading branch information
vicr123 committed Mar 23, 2024
1 parent 57ddb91 commit 3ea3f99
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions build-project/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ inputs:
description: 'Build project for the host system regardless of LCNTP_TARGET_PLATFORM environment variable'
required: false
default: 'false'
target:
description: 'Target to build'
required: false
default: ''
outputs:
install-prefix:
description: "Path to installed files"
Expand Down
9 changes: 7 additions & 2 deletions build-project/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module.exports = async options => {
}
}

const cacheKey = `build-project-${buildFolder.join("/")}-${calculateSHA256(cmakeArgs.join(" "))}`;
const cacheKey = `build-project-target${options.target}-${buildFolder.join("/")}-${calculateSHA256(cmakeArgs.join(" "))}`;

let needBuild = true;
if (options.project !== ".") {
Expand All @@ -137,7 +137,12 @@ module.exports = async options => {

if (needBuild) {
await exec.exec(`cmake`, cmakeArgs);
await exec.exec(`cmake`, ["--build", buildDir]);

const buildArgs = ["--build", buildDir];
if (options.target) {
buildArgs.push("--target", options.target);
}
await exec.exec(`cmake`, buildArgs);
}

if (process.platform === "linux") {
Expand Down
4 changes: 3 additions & 1 deletion build-project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ async function run() {
const extraCmakeArgs = core.getInput("extra-cmake-args");
const arch = core.getInput("arch");
const forceHostBuild = core.getInput("force-host-build");
const target = core.getInput("target");

let options = {
project: project,
arch: arch,
forceHostBuild: forceHostBuild === "true"
forceHostBuild: forceHostBuild === "true",
target: target
};

if (commitish) options.commitish = commitish;
Expand Down

0 comments on commit 3ea3f99

Please sign in to comment.