diff --git a/cmd/firmware-action/recipes/edk2.go b/cmd/firmware-action/recipes/edk2.go index cd6d9030..15d37ba7 100644 --- a/cmd/firmware-action/recipes/edk2.go +++ b/cmd/firmware-action/recipes/edk2.go @@ -5,10 +5,8 @@ package recipes import ( "context" - "errors" "fmt" "log/slog" - "os" "runtime" "dagger.io/dagger" @@ -27,7 +25,7 @@ type Edk2Specific struct { // "source ./edksetup.sh; build -t GCC5 -a IA32 -p UefiPayloadPkg/UefiPayloadPkg.dsc" // "python UefiPayloadPkg/UniversalPayloadBuild.py" // "Intel/AlderLakeFspPkg/BuildFv.sh" - BuildCommand string `json:"build_command" validate:"required"` + BuildCommand []string `json:"build_command" validate:"required"` } // ANCHOR_END: Edk2Specific @@ -52,11 +50,6 @@ type Edk2Opts struct { // - 'X64' Arch string `json:"arch"` - // Gives the (relative) path to the defconfig that should be used to build the target. - // For EDK2 this is a one-line file containing the build arguments such as - // '-D BOOTLOADER=COREBOOT -D TPM_ENABLE=TRUE -D NETWORK_IPXE=TRUE'. - DefconfigPath string `json:"defconfig_path" validate:"filepath"` - // Coreboot specific options Edk2Specific `validate:"required"` } @@ -105,24 +98,6 @@ func (opts Edk2Opts) buildFirmware(ctx context.Context, client *dagger.Client, d myContainer = myContainer.WithEnvVariable(key, value) } - // Assemble build arguments - // and read content of the config file at "defconfig_path" - var defconfigFileArgs []byte - if opts.DefconfigPath != "" { - if _, err := os.Stat(opts.DefconfigPath); !errors.Is(err, os.ErrNotExist) { - defconfigFileArgs, err = os.ReadFile(opts.DefconfigPath) - if err != nil { - return nil, err - } - } else { - slog.Warn( - fmt.Sprintf("Failed to read file '%s' as defconfig_path: file does not exist", opts.DefconfigPath), - slog.String("suggestion", "Double check the path for defconfig"), - slog.Any("error", err), - ) - } - } - // Assemble commands to build buildSteps := [][]string{} if !(runtime.GOARCH == "386" || runtime.GOARCH == "amd64") { @@ -130,7 +105,9 @@ func (opts Edk2Opts) buildFirmware(ctx context.Context, client *dagger.Client, d // Docs: https://go.dev/doc/install/source#environment buildSteps = append(buildSteps, []string{"bash", "-c", "cd ${TOOLSDIR}/Edk2/; make -C BaseTools/ -j $(nproc)"}) } - buildSteps = append(buildSteps, []string{"bash", "-c", fmt.Sprintf("%s %s", opts.BuildCommand, string(defconfigFileArgs))}) + for _, cmd := range opts.BuildCommand { + buildSteps = append(buildSteps, []string{"bash", "-c", cmd}) + } // Build var myContainerPrevious *dagger.Container diff --git a/cmd/firmware-action/recipes/edk2_test.go b/cmd/firmware-action/recipes/edk2_test.go index b5a2fed9..31125d53 100644 --- a/cmd/firmware-action/recipes/edk2_test.go +++ b/cmd/firmware-action/recipes/edk2_test.go @@ -48,10 +48,9 @@ func TestEdk2(t *testing.T) { { name: "normal build", edk2Options: Edk2Opts{ - CommonOpts: common, - DefconfigPath: "defconfig", + CommonOpts: common, Edk2Specific: Edk2Specific{ - BuildCommand: "source ./edksetup.sh; build -a X64 -p UefiPayloadPkg/UefiPayloadPkg.dsc -b DEBUG -t GCC5", + BuildCommand: []string{"source ./edksetup.sh; build -a X64 -p UefiPayloadPkg/UefiPayloadPkg.dsc -b DEBUG -t GCC5 -D BOOTLOADER=COREBOOT"}, }, }, version: "edk2-stable202105", @@ -96,10 +95,6 @@ func TestEdk2(t *testing.T) { assert.NoError(t, err) defer os.Chdir(pwd) // nolint:errcheck - // Create "defconfig_path" file - err = os.WriteFile(tc.edk2Options.DefconfigPath, []byte("-D BOOTLOADER=COREBOOT"), 0o644) - assert.NoError(t, err) - // Artifacts outputPath := filepath.Join(tmpDir, tc.edk2Options.OutputDir) err = os.MkdirAll(outputPath, os.ModePerm) diff --git a/tests/example_config.json b/tests/example_config.json index 3c413a3a..93885a74 100644 --- a/tests/example_config.json +++ b/tests/example_config.json @@ -32,13 +32,14 @@ "sdk_url": "ghcr.io/9elements/firmware-action/${EDK2_VERSION}:main", "arch": "X64", "repo_path": "Edk2/", - "defconfig_path": "edk2_config.cfg", "output_dir": "output-edk2/", "container_output_dirs": [ "Build/" ], "container_output_files": null, - "build_command": "source ./edksetup.sh; build -a X64 -p UefiPayloadPkg/UefiPayloadPkg.dsc -b DEBUG -t ${GCC_TOOLCHAIN_VERSION}", + "build_command": [ + "source ./edksetup.sh; build -a X64 -p UefiPayloadPkg/UefiPayloadPkg.dsc -b DEBUG -t ${GCC_TOOLCHAIN_VERSION}" + ], "container_input_dir": "inputs/", "input_dirs": null, "input_files": null diff --git a/tests/example_config__edk2.json b/tests/example_config__edk2.json index 25294652..16c23933 100644 --- a/tests/example_config__edk2.json +++ b/tests/example_config__edk2.json @@ -5,11 +5,12 @@ "sdk_url": "ghcr.io/9elements/firmware-action/${EDK2_VERSION}:main", "arch": "X64", "repo_path": "Edk2/", - "defconfig_path": "edk2_config.cfg", "output_dir": "output-edk2/", "container_output_dirs": ["Build/"], "container_output_files": null, - "build_command": "source ./edksetup.sh; build -a X64 -p UefiPayloadPkg/UefiPayloadPkg.dsc -b DEBUG -t ${GCC_TOOLCHAIN_VERSION}", + "build_command": [ + "source ./edksetup.sh; build -a X64 -p UefiPayloadPkg/UefiPayloadPkg.dsc -b DEBUG -t ${GCC_TOOLCHAIN_VERSION}" + ], "container_input_dir": "inputs/", "input_dirs": null, "input_files": null