Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

compile: fix export when artifacts contains a folder #2788

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 2 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions 1 commands/service_compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ func (s *arduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu
return &cmderrors.PermissionDeniedError{Message: i18n.Tr("Error reading build directory"), Cause: err}
}
buildFiles.FilterPrefix(baseName)
buildFiles.FilterOutDirs()
for _, buildFile := range buildFiles {
exportedFile := exportPath.Join(buildFile.Base())
logrus.WithField("src", buildFile).WithField("dest", exportedFile).Trace("Copying artifact.")
Expand Down
43 changes: 43 additions & 0 deletions 43 internal/integrationtest/compile_1/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1321,3 +1321,46 @@ func buildWithCustomBuildPathAndOUtputDirFlag(t *testing.T, env *integrationtest
require.NotEmpty(t, content)
}
}

func TestCompileWithOutputDirFlagIgnoringFoldersCreatedByEsp32RainMakerLib(t *testing.T) {
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
defer env.CleanUp()

_, _, err := cli.Run("update")
require.NoError(t, err)

// Update index with esp32 core and install it
url := "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json"
_, _, err = cli.Run("core", "update-index", "--additional-urls="+url)
require.NoError(t, err)
_, _, err = cli.Run("core", "install", "esp32:esp32@3.0.7", "--additional-urls="+url)
require.NoError(t, err)

sketchName := "RainMakerSketch"
sketchPath := cli.SketchbookDir().Join(sketchName)
_, _, err = cli.Run("sketch", "new", sketchPath.String())
require.NoError(t, err)

// When importing the `RMaker` library, the esp32 core produces in output a folder,
// containing all the binaries exported. The name of the folder matches the sketch name.
// In out case:
// cache-dir/
// |- RainMakerSketch.ino/ <--- This should be ignored
// |- RainMakerSketch.ino.uf2
// |- RainMakerSketch.ino.bin
// |- ...
err = sketchPath.Join(sketchName + ".ino").WriteFile([]byte(`
#include "RMaker.h"
alessio-perugini marked this conversation as resolved.
Show resolved Hide resolved
void setup() { }
void loop() { }`,
))
require.NoError(t, err)

buildPath := cli.DataDir().Join("test_dir", "build_dir")
outputDir := cli.SketchbookDir().Join("test_dir", "output_dir")
_, stderr, err := cli.Run("compile", "-b", "esp32:esp32:esp32", sketchPath.String(), "--build-path", buildPath.String(), "--output-dir", outputDir.String())
require.NoError(t, err)
require.NotContains(t, stderr, []byte("Error during build: Error copying output file"))
require.DirExists(t, buildPath.Join(sketchName+".ino").String())
require.NoDirExists(t, outputDir.Join(sketchName+".ino").String())
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.