mirror of
				https://github.com/threeal/cmake-action.git
				synced 2025-11-04 05:43:42 +00:00 
			
		
		
		
	feat: specify default input value in getInputs function
				
					
				
			This commit is contained in:
		
							parent
							
								
									db12bd1063
								
							
						
					
					
						commit
						82bd44ab08
					
				
							
								
								
									
										20
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							@ -27704,8 +27704,8 @@ var io = __nccwpck_require__(1793);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
function getInputs() {
 | 
					function getInputs() {
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
        sourceDir: (0,core.getInput)("source-dir"),
 | 
					        sourceDir: (0,core.getInput)("source-dir") || ".",
 | 
				
			||||||
        buildDir: (0,core.getInput)("build-dir"),
 | 
					        buildDir: (0,core.getInput)("build-dir") || "build",
 | 
				
			||||||
        generator: (0,core.getInput)("generator"),
 | 
					        generator: (0,core.getInput)("generator"),
 | 
				
			||||||
        cCompiler: (0,core.getInput)("c-compiler"),
 | 
					        cCompiler: (0,core.getInput)("c-compiler"),
 | 
				
			||||||
        cxxCompiler: (0,core.getInput)("cxx-compiler"),
 | 
					        cxxCompiler: (0,core.getInput)("cxx-compiler"),
 | 
				
			||||||
@ -27727,11 +27727,7 @@ function getInputs() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
async function main() {
 | 
					async function main() {
 | 
				
			||||||
    const inputs = getInputs();
 | 
					    const inputs = getInputs();
 | 
				
			||||||
    const configureArgs = [
 | 
					    const configureArgs = [inputs.sourceDir, "-B", inputs.buildDir];
 | 
				
			||||||
        inputs.sourceDir || ".",
 | 
					 | 
				
			||||||
        "-B",
 | 
					 | 
				
			||||||
        inputs.buildDir || "build",
 | 
					 | 
				
			||||||
    ];
 | 
					 | 
				
			||||||
    if (inputs.generator) {
 | 
					    if (inputs.generator) {
 | 
				
			||||||
        configureArgs.push(...["-G", inputs.generator]);
 | 
					        configureArgs.push(...["-G", inputs.generator]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -27763,18 +27759,14 @@ async function main() {
 | 
				
			|||||||
    configureArgs.push(...inputs.options.map((opt) => "-D" + opt));
 | 
					    configureArgs.push(...inputs.options.map((opt) => "-D" + opt));
 | 
				
			||||||
    configureArgs.push(...inputs.args);
 | 
					    configureArgs.push(...inputs.args);
 | 
				
			||||||
    await (0,exec.exec)("cmake", configureArgs);
 | 
					    await (0,exec.exec)("cmake", configureArgs);
 | 
				
			||||||
    core.setOutput("build-dir", inputs.buildDir || "build");
 | 
					    core.setOutput("build-dir", inputs.buildDir);
 | 
				
			||||||
    if (inputs.runBuild || inputs.runTest) {
 | 
					    if (inputs.runBuild || inputs.runTest) {
 | 
				
			||||||
        await (0,exec.exec)("cmake", [
 | 
					        await (0,exec.exec)("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs]);
 | 
				
			||||||
            "--build",
 | 
					 | 
				
			||||||
            inputs.buildDir || "build",
 | 
					 | 
				
			||||||
            ...inputs.buildArgs,
 | 
					 | 
				
			||||||
        ]);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (inputs.runTest) {
 | 
					    if (inputs.runTest) {
 | 
				
			||||||
        await (0,exec.exec)("ctest", [
 | 
					        await (0,exec.exec)("ctest", [
 | 
				
			||||||
            "--test-dir",
 | 
					            "--test-dir",
 | 
				
			||||||
            inputs.buildDir || "build",
 | 
					            inputs.buildDir,
 | 
				
			||||||
            "--output-on-failure",
 | 
					            "--output-on-failure",
 | 
				
			||||||
            "--no-tests=error",
 | 
					            "--no-tests=error",
 | 
				
			||||||
            ...inputs.testArgs,
 | 
					            ...inputs.testArgs,
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										16
									
								
								src/index.ts
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/index.ts
									
									
									
									
									
								
							@ -6,11 +6,7 @@ import { getInputs } from "./inputs.js";
 | 
				
			|||||||
async function main() {
 | 
					async function main() {
 | 
				
			||||||
  const inputs = getInputs();
 | 
					  const inputs = getInputs();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const configureArgs = [
 | 
					  const configureArgs = [inputs.sourceDir, "-B", inputs.buildDir];
 | 
				
			||||||
    inputs.sourceDir || ".",
 | 
					 | 
				
			||||||
    "-B",
 | 
					 | 
				
			||||||
    inputs.buildDir || "build",
 | 
					 | 
				
			||||||
  ];
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (inputs.generator) {
 | 
					  if (inputs.generator) {
 | 
				
			||||||
    configureArgs.push(...["-G", inputs.generator]);
 | 
					    configureArgs.push(...["-G", inputs.generator]);
 | 
				
			||||||
@ -50,20 +46,16 @@ async function main() {
 | 
				
			|||||||
  configureArgs.push(...inputs.args);
 | 
					  configureArgs.push(...inputs.args);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  await exec("cmake", configureArgs);
 | 
					  await exec("cmake", configureArgs);
 | 
				
			||||||
  core.setOutput("build-dir", inputs.buildDir || "build");
 | 
					  core.setOutput("build-dir", inputs.buildDir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (inputs.runBuild || inputs.runTest) {
 | 
					  if (inputs.runBuild || inputs.runTest) {
 | 
				
			||||||
    await exec("cmake", [
 | 
					    await exec("cmake", ["--build", inputs.buildDir, ...inputs.buildArgs]);
 | 
				
			||||||
      "--build",
 | 
					 | 
				
			||||||
      inputs.buildDir || "build",
 | 
					 | 
				
			||||||
      ...inputs.buildArgs,
 | 
					 | 
				
			||||||
    ]);
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (inputs.runTest) {
 | 
					  if (inputs.runTest) {
 | 
				
			||||||
    await exec("ctest", [
 | 
					    await exec("ctest", [
 | 
				
			||||||
      "--test-dir",
 | 
					      "--test-dir",
 | 
				
			||||||
      inputs.buildDir || "build",
 | 
					      inputs.buildDir,
 | 
				
			||||||
      "--output-on-failure",
 | 
					      "--output-on-failure",
 | 
				
			||||||
      "--no-tests=error",
 | 
					      "--no-tests=error",
 | 
				
			||||||
      ...inputs.testArgs,
 | 
					      ...inputs.testArgs,
 | 
				
			||||||
 | 
				
			|||||||
@ -18,8 +18,8 @@ export interface Inputs {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export function getInputs(): Inputs {
 | 
					export function getInputs(): Inputs {
 | 
				
			||||||
  return {
 | 
					  return {
 | 
				
			||||||
    sourceDir: getInput("source-dir"),
 | 
					    sourceDir: getInput("source-dir") || ".",
 | 
				
			||||||
    buildDir: getInput("build-dir"),
 | 
					    buildDir: getInput("build-dir") || "build",
 | 
				
			||||||
    generator: getInput("generator"),
 | 
					    generator: getInput("generator"),
 | 
				
			||||||
    cCompiler: getInput("c-compiler"),
 | 
					    cCompiler: getInput("c-compiler"),
 | 
				
			||||||
    cxxCompiler: getInput("cxx-compiler"),
 | 
					    cxxCompiler: getInput("cxx-compiler"),
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user