Skip to content

Fix compile --build-path not working with relative paths #1423

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 1 commit into from
Aug 31, 2021
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
2 changes: 1 addition & 1 deletion commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
if req.GetBuildPath() == "" {
builderCtx.BuildPath = sk.BuildPath
} else {
builderCtx.BuildPath = paths.New(req.GetBuildPath())
builderCtx.BuildPath = paths.New(req.GetBuildPath()).Canonical()
}
if err = builderCtx.BuildPath.MkdirAll(); err != nil {
return nil, &commands.PermissionDeniedError{Message: tr("Cannot create build directory"), Cause: err}
Expand Down
30 changes: 30 additions & 0 deletions test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,3 +1155,33 @@ def test_compile_sketch_with_ipp_file_include(run_command, copy_sketch):
fqbn = "arduino:avr:uno"

assert run_command(f"compile -b {fqbn} {sketch_path} --verbose")


def test_compile_with_relative_build_path(run_command, data_dir, copy_sketch):
assert run_command("update")

run_command("core install arduino:[email protected]")

sketch_name = "sketch_simple"
sketch_path = copy_sketch(sketch_name)
fqbn = "arduino:avr:uno"

build_path = Path("..", "build_path")
working_dir = Path(data_dir, "working_dir")
working_dir.mkdir()
assert run_command(f"compile -b {fqbn} --build-path {build_path} {sketch_path} -v", custom_working_dir=working_dir)

absolute_build_path = Path(data_dir, "build_path")
built_files = [f.name for f in absolute_build_path.glob("*")]
assert f"{sketch_name}.ino.eep" in built_files
assert f"{sketch_name}.ino.elf" in built_files
assert f"{sketch_name}.ino.hex" in built_files
assert f"{sketch_name}.ino.with_bootloader.bin" in built_files
assert f"{sketch_name}.ino.with_bootloader.hex" in built_files
assert "build.options.json" in built_files
assert "compile_commands.json" in built_files
assert "core" in built_files
assert "includes.cache" in built_files
assert "libraries" in built_files
assert "preproc" in built_files
assert "sketch" in built_files