mirror of
				https://github.com/threeal/cmake-action.git
				synced 2025-11-04 05:43:42 +00:00 
			
		
		
		
	feat: append source dir to configure Cmake args only if specified
This commit is contained in:
		
							parent
							
								
									72821fb225
								
							
						
					
					
						commit
						17a89c9118
					
				
							
								
								
									
										6
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							@ -27735,7 +27735,11 @@ var exec = __nccwpck_require__(4926);
 | 
			
		||||
 * @param inputs - The action inputs.
 | 
			
		||||
 */
 | 
			
		||||
async function configureProject(inputs) {
 | 
			
		||||
    const configureArgs = [inputs.sourceDir, "-B", inputs.buildDir];
 | 
			
		||||
    const configureArgs = [];
 | 
			
		||||
    if (inputs.sourceDir) {
 | 
			
		||||
        configureArgs.push(inputs.sourceDir);
 | 
			
		||||
    }
 | 
			
		||||
    configureArgs.push("-B", inputs.buildDir);
 | 
			
		||||
    if (inputs.generator) {
 | 
			
		||||
        configureArgs.push(...["-G", inputs.generator]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,7 @@ interface TestCase {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const defaultInputs: Inputs = {
 | 
			
		||||
  sourceDir: ".",
 | 
			
		||||
  sourceDir: "",
 | 
			
		||||
  buildDir: "build",
 | 
			
		||||
  generator: "",
 | 
			
		||||
  cCompiler: "",
 | 
			
		||||
@ -29,7 +29,7 @@ describe("configure a CMake project", () => {
 | 
			
		||||
  const testCases: TestCase[] = [
 | 
			
		||||
    {
 | 
			
		||||
      name: "with nothing specified",
 | 
			
		||||
      expectedArgs: [".", "-B", "build"],
 | 
			
		||||
      expectedArgs: ["-B", "build"],
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      name: "with source directory specified",
 | 
			
		||||
@ -39,43 +39,37 @@ describe("configure a CMake project", () => {
 | 
			
		||||
    {
 | 
			
		||||
      name: "with build directory specified",
 | 
			
		||||
      inputs: { buildDir: "output" },
 | 
			
		||||
      expectedArgs: [".", "-B", "output"],
 | 
			
		||||
      expectedArgs: ["-B", "output"],
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      name: "with generator specified",
 | 
			
		||||
      inputs: { generator: "Ninja" },
 | 
			
		||||
      expectedArgs: [".", "-B", "build", "-G", "Ninja"],
 | 
			
		||||
      expectedArgs: ["-B", "build", "-G", "Ninja"],
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      name: "with C compiler specified",
 | 
			
		||||
      inputs: { cCompiler: "clang" },
 | 
			
		||||
      expectedArgs: [".", "-B", "build", "-DCMAKE_C_COMPILER=clang"],
 | 
			
		||||
      expectedArgs: ["-B", "build", "-DCMAKE_C_COMPILER=clang"],
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      name: "with C++ compiler specified",
 | 
			
		||||
      inputs: { cxxCompiler: "clang++" },
 | 
			
		||||
      expectedArgs: [".", "-B", "build", "-DCMAKE_CXX_COMPILER=clang++"],
 | 
			
		||||
      expectedArgs: ["-B", "build", "-DCMAKE_CXX_COMPILER=clang++"],
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      name: "with C flags specified",
 | 
			
		||||
      inputs: { cFlags: "-Werror -Wall" },
 | 
			
		||||
      expectedArgs: [".", "-B", "build", "-DCMAKE_C_FLAGS=-Werror -Wall"],
 | 
			
		||||
      expectedArgs: ["-B", "build", "-DCMAKE_C_FLAGS=-Werror -Wall"],
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      name: "with C++ flags specified",
 | 
			
		||||
      inputs: { cxxFlags: "-Werror -Wall -Wextra" },
 | 
			
		||||
      expectedArgs: [
 | 
			
		||||
        ".",
 | 
			
		||||
        "-B",
 | 
			
		||||
        "build",
 | 
			
		||||
        "-DCMAKE_CXX_FLAGS=-Werror -Wall -Wextra",
 | 
			
		||||
      ],
 | 
			
		||||
      expectedArgs: ["-B", "build", "-DCMAKE_CXX_FLAGS=-Werror -Wall -Wextra"],
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      name: "with additional options specified",
 | 
			
		||||
      inputs: { options: ["BUILD_TESTING=ON", "BUILD_EXAMPLES=ON"] },
 | 
			
		||||
      expectedArgs: [
 | 
			
		||||
        ".",
 | 
			
		||||
        "-B",
 | 
			
		||||
        "build",
 | 
			
		||||
        "-DBUILD_TESTING=ON",
 | 
			
		||||
@ -85,7 +79,7 @@ describe("configure a CMake project", () => {
 | 
			
		||||
    {
 | 
			
		||||
      name: "with additional arguments specified",
 | 
			
		||||
      inputs: { args: ["-Wdev", "-Wdeprecated"] },
 | 
			
		||||
      expectedArgs: [".", "-B", "build", "-Wdev", "-Wdeprecated"],
 | 
			
		||||
      expectedArgs: ["-B", "build", "-Wdev", "-Wdeprecated"],
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      name: "with all specified",
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,13 @@ import type { Inputs } from "./inputs.js";
 | 
			
		||||
 * @param inputs - The action inputs.
 | 
			
		||||
 */
 | 
			
		||||
export async function configureProject(inputs: Inputs): Promise<void> {
 | 
			
		||||
  const configureArgs = [inputs.sourceDir, "-B", inputs.buildDir];
 | 
			
		||||
  const configureArgs = [];
 | 
			
		||||
 | 
			
		||||
  if (inputs.sourceDir) {
 | 
			
		||||
    configureArgs.push(inputs.sourceDir);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  configureArgs.push("-B", inputs.buildDir);
 | 
			
		||||
 | 
			
		||||
  if (inputs.generator) {
 | 
			
		||||
    configureArgs.push(...["-G", inputs.generator]);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user