Skip to content

Now compile --only-compilation-database will run all pre-* hooks #1549

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
Nov 17, 2021
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions legacy/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,31 @@ func (s *Builder) Run(ctx *types.Context) error {
utils.LogIfVerbose("info", tr("Compiling sketch...")),
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.sketch.prebuild", Suffix: ".pattern"},
&phases.SketchBuilder{},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.sketch.postbuild", Suffix: ".pattern"},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.sketch.postbuild", Suffix: ".pattern", SkipIfOnlyUpdatingCompilationDatabase: true},

utils.LogIfVerbose("info", tr("Compiling libraries...")),
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.libraries.prebuild", Suffix: ".pattern"},
&UnusedCompiledLibrariesRemover{},
&phases.LibrariesBuilder{},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.libraries.postbuild", Suffix: ".pattern"},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.libraries.postbuild", Suffix: ".pattern", SkipIfOnlyUpdatingCompilationDatabase: true},

utils.LogIfVerbose("info", tr("Compiling core...")),
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.core.prebuild", Suffix: ".pattern"},
&phases.CoreBuilder{},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.core.postbuild", Suffix: ".pattern"},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.core.postbuild", Suffix: ".pattern", SkipIfOnlyUpdatingCompilationDatabase: true},

utils.LogIfVerbose("info", tr("Linking everything together...")),
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.linking.prelink", Suffix: ".pattern"},
&phases.Linker{},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.linking.postlink", Suffix: ".pattern"},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.linking.postlink", Suffix: ".pattern", SkipIfOnlyUpdatingCompilationDatabase: true},

&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.objcopy.preobjcopy", Suffix: ".pattern"},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.objcopy.", Suffix: ".pattern"},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.objcopy.postobjcopy", Suffix: ".pattern"},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.objcopy.", Suffix: ".pattern", SkipIfOnlyUpdatingCompilationDatabase: true},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.objcopy.postobjcopy", Suffix: ".pattern", SkipIfOnlyUpdatingCompilationDatabase: true},

&MergeSketchWithBootloader{},

&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.postbuild", Suffix: ".pattern"},
&RecipeByPrefixSuffixRunner{Prefix: "recipe.hooks.postbuild", Suffix: ".pattern", SkipIfOnlyUpdatingCompilationDatabase: true},
}

mainErr := runCommands(ctx, commands)
Expand Down
7 changes: 4 additions & 3 deletions legacy/builder/recipe_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ import (
)

type RecipeByPrefixSuffixRunner struct {
Prefix string
Suffix string
Prefix string
Suffix string
SkipIfOnlyUpdatingCompilationDatabase bool
}

func (s *RecipeByPrefixSuffixRunner) Run(ctx *types.Context) error {
Expand All @@ -53,7 +54,7 @@ func (s *RecipeByPrefixSuffixRunner) Run(ctx *types.Context) error {
return errors.WithStack(err)
}

if ctx.OnlyUpdateCompilationDatabase {
if ctx.OnlyUpdateCompilationDatabase && s.SkipIfOnlyUpdatingCompilationDatabase {
if ctx.Verbose {
ctx.GetLogger().Println("info", tr("Skipping: {0}"), strings.Join(command.Args, " "))
}
Expand Down
16 changes: 16 additions & 0 deletions test/test_compile_part_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,22 @@ def test_compile_with_esp8266_bundled_libraries(run_command, data_dir, copy_sket
assert "\n".join(expected_output) not in res.stdout


def test_generate_compile_commands_json_with_esp32(run_command, data_dir, copy_sketch):
# https://github.com/arduino/arduino-cli/issues/1547
assert run_command(["update"])

# Update index with esp32 core and install it
url = "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
assert run_command(["core", "update-index", f"--additional-urls={url}"])
assert run_command(["core", "install", "esp32:esp32", f"--additional-urls={url}"])

# Install a library with the same name as one bundled with the core
assert run_command(["lib", "install", "SD"])

sketch_path = copy_sketch("sketch_simple")
assert run_command(["compile", "-b", "esp32:esp32:featheresp32", "--only-compilation-database", sketch_path])


def test_compile_sketch_with_tpp_file_include(run_command, copy_sketch):
assert run_command(["update"])

Expand Down