Skip to content

Commit

Permalink
Merge pull request #1737 from xnox/packagenote
Browse files Browse the repository at this point in the history
build: Write a GCC specs file into workspace
  • Loading branch information
xnox authored Jan 15, 2025
2 parents 03772f6 + 0916058 commit 7c33aed
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"slices"
"strconv"
"strings"
"text/template"
"time"

"chainguard.dev/apko/pkg/apk/apk"
Expand Down Expand Up @@ -75,6 +76,10 @@ rm -Rf "$@"`,
"shellEmptyDir",
}

var gccLinkTemplate = `*link:
+ --package-metadata={"type":"apk","os":"{{.Namespace}}","name":"{{.Configuration.Package.Name}}","version":"{{.Configuration.Package.FullVersion}}","architecture":"{{.Arch.ToAPK}}"}
`

var ErrSkipThisArch = errors.New("error: skip this arch")

type Build struct {
Expand Down Expand Up @@ -678,6 +683,20 @@ func (b *Build) populateWorkspace(ctx context.Context, src fs.FS) error {
return err
}

// Write out build settings into workspacedir
// For now, just the gcc spec file and just link settings.
// In the future can control debug symbol generation, march/mtune, etc.
specFile, err := os.Create(filepath.Join(b.WorkspaceDir, ".melange.gcc.spec"))
if err != nil {
return err
}
specTemplate := template.New("gccSpecFile")
if err := template.Must(specTemplate.Parse(gccLinkTemplate)).Execute(specFile, b); err != nil {
return err
}
if err := specFile.Close(); err != nil {
return err
}
return fs.WalkDir(src, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
Expand Down

0 comments on commit 7c33aed

Please sign in to comment.