Skip to content
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

Fix compile errors after renaming files, related to unsaved changes in the sketch #4358

Merged
merged 2 commits into from
Jan 19, 2016

Conversation

matthijskooijman
Copy link
Collaborator

Fix #4335 by always deleting the temporary sketch copy after every build. With that, the name of that directory can be random again, instead of needing to be deterministic using a hash of the main sketch filename.

When a sketch has unsaved changes, a temporary copy of the sketch is
made with those changes applied. This copy is then passed to
arduino-builder.

Previously, this temporary copy was kept around and only deleted when
the IDE was closed. However, all files were written to it again on every
build, so keeping the old files around did not serve any real purpose.

When a file was renamed in the IDE, the original name would still be
present in the temporary copy, and could cause linker errors because
both were compiled.

This commit makes sure the temporary copy is deleted after every build,
instead of at IDE exit, which fixes this problem with renames.

When a file is deleted from the sketch, the file would also be deleted
from the temporary copy, presumably to fix this same problem for
deletes (but renames were forgotten). With this commit, this special
handling for deleting files is no longer needed, so it is removed.

This fixes arduino#4335
When a sketch has unsaved changes, a temporary copy of the sketch is
made with those changes applied. This copy is then passed to
arduino-builder.

Previously, the name of this directory contained a hash of the main
sketch filename, so the same directory would be used between builds. Now
that this directory is deleted after every build, it can just use a
randomized directory name, which is what this commit does.

Addtionally, the prefix used for generating the name is changed from
"arduino_" to "arduino_modified_sketch_" to make it slightly clearer
what the directory is for (just in case it somehow survives the build,
or a user sees it during the build).
@PaulStoffregen
Copy link
Contributor

If a sketch has many .cpp files, will this change force them to all be rebuild even if only the main .ino has changed?

@matthijskooijman
Copy link
Collaborator Author

Nope, currently arduino-builder currently compares the contents of all files in this temporary directory with their copies in the build directory, and only copies/recompiles them if they actually changed (disregarding the timestamps on the files). See these comments for some more details:

This PR does not implement the additional improvement suggested in the first comment, it just fixes the problem without needing changes to arduino-builder.

@cmaglie
Copy link
Member

cmaglie commented Dec 29, 2015

LGTM 👍

@cmaglie cmaglie added Component: IDE The Arduino IDE feature request A request to make an enhancement (not a bug fix) labels Dec 29, 2015
@cmaglie cmaglie added this to the Release 1.6.8 milestone Dec 29, 2015
@matthijskooijman matthijskooijman mentioned this pull request Dec 30, 2015
@cmaglie cmaglie merged commit 7949e7e into arduino:master Jan 19, 2016
@matthijskooijman matthijskooijman deleted the renaming branch January 28, 2016 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE The Arduino IDE feature request A request to make an enhancement (not a bug fix)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants