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

Added 'output' directive to specify final target name #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func runStage(s Stage) {
func run() {
percentPer = 100 / float64(nSteps)
progress = 0
oname = ""
printProgress("Beginning build")
for _, stage := range script {
runStage(stage)
Expand Down
4 changes: 4 additions & 0 deletions flagcompiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var cflags []string
var cxxflags []string
var ldflags []string
var libs []string
var oname string

func pkgconfig(which string, pkgs []string) []string {
cmd := exec.Command("pkg-config", append([]string{which}, pkgs...)...)
Expand Down Expand Up @@ -51,6 +52,8 @@ func parseFile(filename string) {
cxxflags = append(cxxflags, parts[1:]...)
case "LDFLAGS:":
ldflags = append(ldflags, parts[1:]...)
case "output:":
oname = parts[1]
case "pkg-config:":
xcflags := pkgconfig("--cflags", parts[1:])
xlibs := pkgconfig("--libs", parts[1:])
Expand Down Expand Up @@ -83,6 +86,7 @@ func compileFlags() {
cflags = append(cflags, strings.Fields(os.Getenv("CFLAGS"))...)
cxxflags = append(cxxflags, strings.Fields(os.Getenv("CXXFLAGS"))...)
ldflags = append(ldflags, strings.Fields(os.Getenv("LDFLAGS"))...)
oname = ""

for _, f := range cfiles {
parseFile(f)
Expand Down
8 changes: 6 additions & 2 deletions gcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ func (g *GCCBase) BuildRCFile(filename string, cflags []string) (stages []Stage,
return stages, object
}

func (g *GCCBase) Link(objects []string, ldflags []string, libs []string) *Step {
func (g *GCCBase) Link(objects []string, ldflags []string, libs []string, target string) *Step {
if g.LD == "" {
g.LD = g.CC
}
target := targetName()

if target == "" {
target = targetName()
}

for i := 0; i < len(libs); i++ {
libs[i] = "-l" + libs[i]
}
Expand Down
7 changes: 5 additions & 2 deletions msvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ func (m *MSVC) BuildRCFile(filename string, cflags []string) (stages []Stage, ob
return stages, object
}

func (m *MSVC) Link(objects []string, ldflags []string, libs []string) *Step {
target := targetName()
func (m *MSVC) Link(objects []string, ldflags []string, libs []string, target string) *Step {

if target == "" {
target = targetName()
}
for i := 0; i < len(libs); i++ {
libs[i] = libs[i] + ".lib"
}
Expand Down
2 changes: 1 addition & 1 deletion scriptgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func buildScript() {
objects = append(objects, obj)
}

s := toolchain.Link(objects, ldflags, libs)
s := toolchain.Link(objects, ldflags, libs, oname)
script = append(script, Stage{s})
nSteps++
}
2 changes: 1 addition & 1 deletion toolchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Toolchain interface {
BuildMFile(filename string, cflags []string) (stages []Stage, object string)
BuildMMFile(filename string, cflags []string) (stages []Stage, object string)
BuildRCFile(filename string, cflags []string) (stages []Stage, object string)
Link(objects []string, ldflags []string, libs []string) *Step
Link(objects []string, ldflags []string, libs []string, target string) *Step
}

var toolchains = make(map[string]Toolchain)
Expand Down