8000 [skip-changelog] legacy: some simple refactorings by cmaglie · Pull Request #2206 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

Skip to content

[skip-changelog] legacy: some simple refactorings #2206

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

Merged
merged 8 commits into from
Jun 8, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rename variables to use snakeCase (golang idiomatic)
  • Loading branch information
cmaglie committed Jun 7, 2023
commit 35798bfcdb159479ddb4311fae6cb9802a254373
36 changes: 18 additions & 18 deletions legacy/builder/container_find_includes.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,33 +361,33 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFileQu
}
}

var preproc_err error
var preproc_stderr []byte
var preprocErr error
var preprocStderr []byte

if unchanged && cache.valid {
include = cache.Next().Include
if first && ctx.Verbose {
ctx.Info(tr("Using cached library dependencies for file: %[1]s", sourcePath))
}
} else {
var preproc_stdout []byte
preproc_stdout, preproc_stderr, preproc_err = preprocessor.GCC(sourcePath, targetFilePath, includeFolders, ctx.BuildProperties)
var preprocStdout []byte
preprocStdout, preprocStderr, preprocErr = preprocessor.GCC(sourcePath, targetFilePath, includeFolders, ctx.BuildProperties)
if ctx.Verbose {
ctx.WriteStdout(preproc_stdout)
ctx.WriteStdout(preproc_stderr)
ctx.WriteStdout(preprocStdout)
ctx.WriteStdout(preprocStderr)
}
// Unwrap error and see if it is an ExitError.
_, is_exit_error := errors.Cause(preproc_err).(*exec.ExitError)
if preproc_err == nil {
_, isExitErr := errors.Cause(preprocErr).(*exec.ExitError)
if preprocErr == nil {
// Preprocessor successful, done
include = ""
} else if !is_exit_error || preproc_stderr == nil {
} else if !isExitErr || preprocStderr == nil {
// Ignore ExitErrors (e.g. gcc returning
// non-zero status), but bail out on
// other errors
return errors.WithStack(preproc_err)
return errors.WithStack(preprocErr)
} else {
include = IncludesFinderWithRegExp(string(preproc_stderr))
include = IncludesFinderWithRegExp(string(preprocStderr))
if include == "" && ctx.Verbose {
ctx.Info(tr("Error while detecting libraries included by %[1]s", sourcePath))
}
Expand All @@ -403,23 +403,23 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFileQu
library := ResolveLibrary(ctx, include)
if library == nil {
// Library could not be resolved, show error
if preproc_err == nil || preproc_stderr == nil {
if preprocErr == nil || preprocStderr == nil {
// Filename came from cache, so run preprocessor to obtain error to show
var preproc_stdout []byte
preproc_stdout, preproc_stderr, preproc_err = preprocessor.GCC(sourcePath, targetFilePath, includeFolders, ctx.BuildProperties)
var preprocStdout []byte
preprocStdout, preprocStderr, preprocErr = preprocessor.GCC(sourcePath, targetFilePath, includeFolders, ctx.BuildProperties)
if ctx.Verbose {
ctx.WriteStdout(preproc_stdout)
ctx.WriteStdout(preprocStdout)
}
if preproc_err == nil {
if preprocErr == nil {
// If there is a missing #include in the cache, but running
// gcc does not reproduce that, there is something wrong.
// Returning an error here will cause the cache to be
// deleted, so hopefully the next compilation will succeed.
return errors.New(tr("Internal error in cache"))
}
}
ctx.WriteStderr(preproc_stderr)
return errors.WithStack(preproc_err)
ctx.WriteStderr(preprocStderr)
return errors.WithStack(preprocErr)
}

// Add this library to the list of libraries, the
Expand Down
0