Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Write a GCC specs file into workspace #1737

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading