Skip to content

Include cache fixes and refactorings #236

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
66cdcc0
Fix past-end-of-cache handling in includeCache.ExpectFile
matthijskooijman Jun 6, 2017
f69a8cc
Convert IncludesFinderWithRegExp to a normal function
matthijskooijman Jun 6, 2017
be08809
Convert GCCPreprocRunner(ForDiscoveringIncludes) to a normal function
matthijskooijman Jun 6, 2017
85d3624
Refactor path generation for ctags_target_for_gcc_minus_e.cpp
matthijskooijman Jun 6, 2017
a14e0ef
Pass FileToRead to ReadFileAndStoreInContext explicitly
matthijskooijman Jun 6, 2017
73bae11
Remove GCCPreprocSourceSaver
matthijskooijman Jun 6, 2017
b861a84
execSizeRecipe: Fix typo in method name
matthijskooijman Jun 16, 2017
108e65f
Pass types.Context down into compilation helpers
matthijskooijman Jun 16, 2017
0f1baa5
Show the sizer commandline in verbose mode
matthijskooijman Jun 16, 2017
2254d74
Show stdout of preproc commands in verbose mode
matthijskooijman Jun 16, 2017
611f07a
Do not ignore command errors in ExecRecipeCollectStdErr
matthijskooijman Jun 16, 2017
5eb37bc
Let ExecRecipeCollectStdErr return []byte for stderr
matthijskooijman Jun 16, 2017
ca9008e
Improve error handling in include detection
matthijskooijman Jun 16, 2017
60265b5
Merge ExecRecipeCollectStdErr into ExecRecipe
matthijskooijman Jun 16, 2017
31e42b7
Merge some duplicate code into prepareGCCPreprocRecipeProperties
matthijskooijman Jun 16, 2017
b03ecab
Let utils.ExecCommand print the command in verbose mode
matthijskooijman Jun 16, 2017
9abc875
Fix removal of -MMD option when running the preprocessor
matthijskooijman Jun 16, 2017
788cecd
Use utils.ExecCommand for running ctags
matthijskooijman Jun 16, 2017
cc978ec
Pass Context to ObjFileIsUpToDate
matthijskooijman Nov 30, 2017
e92bf65
Let ObjFileIsUpToDate output verbose debug output
matthijskooijman Mar 2, 2017
d2d49e6
ContainerFindIncludes: Add some temporary variables
matthijskooijman Mar 2, 2017
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
Prev Previous commit
Next Next commit
Do not ignore command errors in ExecRecipeCollectStdErr
Previously, this function would ignore any errors returned by `Run()`
since the command is expected to fail in most cases. However, in
addition to ignoring a non-zero exit code from the command, it would
also ignore errors in running the command itself.

With this commit, `ExecRecipeCollectStdErr()` simply returns all errors,
but its caller checks the type of the error. If it is `ExitError`, this
indicates a non-zero exit status, which is ignored. Otherwise, the error
is reported as normal.

Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
  • Loading branch information
matthijskooijman committed May 28, 2018
commit 611f07a5df0efc8b5086a9635cc36d6f41b53678
4 changes: 2 additions & 2 deletions builder_utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ func ExecRecipeCollectStdErr(buildProperties properties.Map, recipe string, remo

buffer := &bytes.Buffer{}
command.Stderr = buffer
command.Run()
return string(buffer.Bytes()), nil
err = command.Run()
return string(buffer.Bytes()), err
}

func RemoveHyphenMDDFlagFromGCCCommandLine(buildProperties properties.Map) {
Expand Down
8 changes: 7 additions & 1 deletion container_find_includes.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ import (
"encoding/json"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"time"

Expand Down Expand Up @@ -324,7 +325,12 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFile t
}
} else {
stderr, err := GCCPreprocRunnerForDiscoveringIncludes(ctx, sourcePath, targetFilePath, includes)
if err != nil {
// Unwrap error and see if it is an ExitError.
// Ignore ExitErrors (e.g. gcc returning
// non-zero status), but bail out on other
// errors
_, is_exit_error := i18n.UnwrapError(err).(*exec.ExitError)
if err != nil && !is_exit_error {
return i18n.WrapError(err)
}
include = IncludesFinderWithRegExp(ctx, stderr)
Expand Down
2 changes: 1 addition & 1 deletion gcc_preproc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func GCCPreprocRunnerForDiscoveringIncludes(ctx *types.Context, sourceFilePath s

stderr, err := builder_utils.ExecRecipeCollectStdErr(properties, constants.RECIPE_PREPROC_MACROS, true, verbose, verbose, logger)
if err != nil {
return "", i18n.WrapError(err)
return string(stderr), i18n.WrapError(err)
}

return string(stderr), nil
Expand Down
11 changes: 11 additions & 0 deletions i18n/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ func WrapError(err error) error {
}
return errors.Wrap(err, 0)
}

func UnwrapError(err error) error {
// Perhaps go-errors can do this already in later versions?
// See https://github.com/go-errors/errors/issues/14
switch e := err.(type) {
case *errors.Error:
return e.Err
default:
return err
}
}