github.com/metux/go-metabuild@v0.0.0-20240118143255-d9ed5ab697f9/engine/builder/c/library_static.go (about)

     1  package c
     2  
     3  import (
     4  	"github.com/metux/go-metabuild/spec/target"
     5  	"github.com/metux/go-metabuild/util/compiler"
     6  )
     7  
     8  type BuilderCLibraryStatic struct {
     9  	BaseCBuilder
    10  }
    11  
    12  func (b BuilderCLibraryStatic) JobRun() error {
    13  	ci := b.BuildConf.CompilerInfo(b.ForBuild(), b.CompilerLang())
    14  	cc := compiler.NewCCompiler(ci, b.TempDir())
    15  
    16  	args := compiler.CompilerArg{
    17  		Sources:    b.Sources(),
    18  		PkgImports: b.AllImports(),
    19  		Defines:    b.CDefines(),
    20  		Output:     b.RequiredEntryStr(target.KeyFile),
    21  		Flags:      b.CFlags(),
    22  	}
    23  
    24  	if err := cc.CompileLibraryStatic(args); err != nil {
    25  		return err
    26  	}
    27  
    28  	b.InstallPkgFileAuto()
    29  
    30  	return nil
    31  }