feat(build): integrate target configuration system into build pipeline

- Add Target field to build.Config struct
- Update build system to use crosscompile.UseWithTarget()
- Enable target-based cross-compilation in build pipeline
- Maintain backward compatibility with existing GOOS/GOARCH workflow

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Li Jie
2025-07-26 12:05:33 +10:00
parent 5424b53b62
commit f571dde538

View File

@@ -70,6 +70,7 @@ const (
type Config struct { type Config struct {
Goos string Goos string
Goarch string Goarch string
Target string // target name (e.g., "rp2040", "wasi") - takes precedence over Goos/Goarch
BinPath string BinPath string
AppExt string // ".exe" on Windows, empty on Unix AppExt string // ".exe" on Windows, empty on Unix
OutFile string // only valid for ModeBuild when len(pkgs) == 1 OutFile string // only valid for ModeBuild when len(pkgs) == 1
@@ -251,7 +252,7 @@ func Do(args []string, conf *Config) ([]Package, error) {
os.Setenv("PATH", env.BinDir()+":"+os.Getenv("PATH")) // TODO(xsw): check windows os.Setenv("PATH", env.BinDir()+":"+os.Getenv("PATH")) // TODO(xsw): check windows
output := conf.OutFile != "" output := conf.OutFile != ""
export, err := crosscompile.Use(conf.Goos, conf.Goarch, IsWasiThreadsEnabled()) export, err := crosscompile.UseWithTarget(conf.Goos, conf.Goarch, IsWasiThreadsEnabled(), conf.Target)
check(err) check(err)
ctx := &context{env: env, conf: cfg, progSSA: progSSA, prog: prog, dedup: dedup, ctx := &context{env: env, conf: cfg, progSSA: progSSA, prog: prog, dedup: dedup,
patches: patches, built: make(map[string]none), initial: initial, mode: mode, patches: patches, built: make(map[string]none), initial: initial, mode: mode,