Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #38 from schibsted/osx-fixes
Browse files Browse the repository at this point in the history
OS X fixes
  • Loading branch information
perj authored Oct 8, 2019
2 parents 69ba742 + 341b577 commit c08a046
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 14 additions & 4 deletions pkg/buildbuild/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ func (ops *GlobalOps) FindCompilerCC() error {

ops.CompilerFlavor = ""

minGcc := comparableVersion("4.8")
minClang := comparableVersion("3.4")
versionRE := regexp.MustCompile(`(\S+) version ([0-9]+\.[0-9]+)`)
for _, cc := range candidates {
minv := ""
Expand All @@ -153,15 +155,15 @@ func (ops *GlobalOps) FindCompilerCC() error {
}

c := match[1]
v := match[2]
v := comparableVersion(match[2])

if minv != "" && v < minv {
if minv != "" && v < comparableVersion(minv) {
continue
}
if c == "gcc" && v < "4.8" {
if c == "gcc" && v < minGcc {
continue
}
if c == "clang" && v < "3.4" {
if c == "clang" && v < minClang {
continue
}

Expand Down Expand Up @@ -189,6 +191,14 @@ func (ops *GlobalOps) FindCompilerCC() error {
return nil
}

func comparableVersion(v string) string {
var vlong strings.Builder
for _, vpart := range strings.Split(v, ".") {
fmt.Fprintf(&vlong, "%4s", vpart)
}
return vlong.String()
}

func (l *LinkDesc) CompileC(srcdir, src, srcbase string) {
opts := map[string]bool{"incdeps": true}
l.AddTarget(srcbase+".o", "cc", []string{src}, "obj", srcdir, nil, opts)
Expand Down
4 changes: 2 additions & 2 deletions rules/rules.ninja
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ rule yaccxx
description = yacc $out

rule install_conf
command = install -p -m0644 $in $out
command = rm -f $out ; install -p -m0644 $in $out
description = copy $in to $out

rule install_script
command = install -p -m0755 $in $out
command = rm -f $out ; install -p -m0755 $in $out
description = copy $in to $out

rule install_header
Expand Down

0 comments on commit c08a046

Please sign in to comment.