Skip to content

Commit

Permalink
Static linking (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
MOZGIII committed Mar 11, 2023
1 parent 4e6d9eb commit 6b9b15e
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 189 deletions.
55 changes: 36 additions & 19 deletions .github/actions/plan/plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const allPlatforms = {
buildEnvScript: buildEnvScriptPath("windows.sh"),
essential: false,
env: {
CARGO_INCREMENTAL: "0"
CARGO_INCREMENTAL: "0",
},
cacheKey: "windows-amd64",
isBroken: false,
Expand Down Expand Up @@ -83,45 +83,53 @@ const buildModes = {
cargoArgs: "--release",
cargoCacheKey: "release-build",
},
}
};

const code = () => {
// Compute the effective list of platforms to use.
const effectivePlatforms = Object.values(allPlatforms).filter(platform => !platform.isBroken && platform.essential);
const effectivePlatforms = Object.values(allPlatforms).filter(
(platform) => !platform.isBroken && platform.essential
);

// Compute the effective list of modes that should run for each of the platforms.
const effectiveModes = Object.values(codeModes).filter(mode => !mode.platformIndependent);
const effectiveModes = Object.values(codeModes).filter(
(mode) => !mode.platformIndependent
);

// Compute the effective list of modes that are platform indepedent and only
// have to be run once.
const effectiveIndepModes = Object.values(codeModes).filter(mode => mode.platformIndependent);
const effectiveIndepModes = Object.values(codeModes).filter(
(mode) => mode.platformIndependent
);

// Compute the individual mixins for indep modes.
const effectiveIncludes = effectiveIndepModes.map(mode => ({
const effectiveIncludes = effectiveIndepModes.map((mode) => ({
// Run the platform independent tests on Ubuntu.
platform: allPlatforms.ubuntu,
mode,
}))
}));

// Prepare the effective matrix.
const matrix = provideMatrix(
{
platform: effectivePlatforms,
mode: effectiveModes,
},
effectiveIncludes,
effectiveIncludes
);

// Print the matrix, useful for local debugging.
logMatrix(matrix);

// Export the matrix so it's available to the Github Actions script.
return matrix;
}
};

const build = () => {
// Compute the effective list of platforms to use.
const effectivePlatforms = Object.values(allPlatforms).filter(platform => !platform.isBroken);
const effectivePlatforms = Object.values(allPlatforms).filter(
(platform) => !platform.isBroken
);

// Compute the effective list of modes that should run for each of the platforms.
const effectiveModes = Object.values(buildModes);
Expand All @@ -140,20 +148,29 @@ const build = () => {

// Export the matrix so it's available to the Github Actions script.
return matrix;
}
};

const evalMatrix = (dimensions, includes) => {
const evalNext = (allVariants, key, values) => allVariants.flatMap((variant) => values.map(value => ({...variant, [key]: value })))
const dimensionKeys = Object.keys(dimensions)
const evaluated = dimensionKeys.reduce((allVariants, dimensionKey) => evalNext(allVariants, dimensionKey, dimensions[dimensionKey]), [{}])
return [...evaluated, ...includes]
}
const evalNext = (allVariants, key, values) =>
allVariants.flatMap((variant) =>
values.map((value) => ({ ...variant, [key]: value }))
);
const dimensionKeys = Object.keys(dimensions);
const evaluated = dimensionKeys.reduce(
(allVariants, dimensionKey) =>
evalNext(allVariants, dimensionKey, dimensions[dimensionKey]),
[{}]
);
return [...evaluated, ...includes];
};

const provideMatrix = (dimensions, includes) => ({ plan: evalMatrix(dimensions, includes) })
const provideMatrix = (dimensions, includes) => ({
plan: evalMatrix(dimensions, includes),
});

const logMatrix = (matrix) => console.log(JSON.stringify(matrix, null, ' '));
const logMatrix = (matrix) => console.log(JSON.stringify(matrix, null, " "));

module.exports = {
code,
build,
}
};
Loading

0 comments on commit 6b9b15e

Please sign in to comment.