Skip to content

Commit

Permalink
Run compiler from the project directory
Browse files Browse the repository at this point in the history
In an attempt to solve issue constabulary#406, run the compiler instead of from
the package directory from the root of the project. Make all paths
passed to the compiler relative to the project root.

This appears to work, and the tests still pass; but it corrects the
output of compiler errors and they now appear with filenames relative
to the `GB_PROJECT_DIR`.
  • Loading branch information
Scott S. McCoy committed Nov 4, 2016
1 parent 65d8604 commit b04809c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ func gc(pkg *Package, gofiles []string) error {
t0 := time.Now()
includes := pkg.IncludePaths()
importpath := pkg.ImportPath

wd := pkg.Context.Project.Projectdir()

if pkg.TestScope && pkg.ExtraIncludes != "" {
// TODO(dfc) gross
includes = append([]string{pkg.ExtraIncludes}, includes...)
Expand All @@ -280,14 +283,17 @@ func gc(pkg *Package, gofiles []string) error {
continue
}
fullpath := filepath.Join(pkg.Dir, gofiles[i])
path, err := filepath.Rel(pkg.Dir, fullpath)

// Run this relative to the *working* directory.
path, err := filepath.Rel(wd, fullpath)

if err == nil {
gofiles[i] = path
} else {
gofiles[i] = fullpath
}
}
err := pkg.tc.Gc(pkg, includes, importpath, pkg.Dir, objfile(pkg), gofiles)
err := pkg.tc.Gc(pkg, includes, importpath, wd, objfile(pkg), gofiles)
pkg.Record("gc", time.Since(t0))
return err
}
Expand Down

0 comments on commit b04809c

Please sign in to comment.