-
Notifications
You must be signed in to change notification settings - Fork 2k
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
arduino/sketches: build sketches as a module #7654
Conversation
f3be607
to
424420e
Compare
Finally updated the documentation. My questions are:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to generate the sketch code in a separate module under BINDIR. Can we rename the Makefile.arduino_sketches.inc file though? We were moving away from the Makefile.* pattern and to a *.inc.mk pattern. Would it make sense to move these makefiles to /makefiles?
@mkdir -p $@ | ||
|
||
# Make everything rebuild if current makefile changes | ||
CURMK = $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use the lastword function instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better use a different name than CURMK. This file is included from the Makefile.include which means it will pollute the name space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change to lastword
I learned it after writing this, and update to a namespaced variable name.
I will change the Makefile name too. Do I just add However, I do not want to move it to |
sys/arduino/arduino_sketches.inc.mk
Outdated
@mkdir -p $@ | ||
|
||
# Make everything rebuild if current makefile changes | ||
_ARDUINO_SKETCHES_MAKEFILE = $(lastword $(MAKEFILE_LIST)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs an immediate assignment (:=
)to avoid the situation where MAKEFILE_LIST is updated by including another file later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value is used directly and only in the two following lines, so following imports will not impact.
However, as I am not using immediate assignment, lastword
is executed twice, so I will change.
@cladmi sounds reasonable. 👍 for arduino_sketches.inc.mk |
Can I rebase and squash ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question and one minor nit
sys/arduino/arduino_sketches.inc.mk
Outdated
@@ -0,0 +1,31 @@ | |||
# Compile together the Arduino sketches of the application | |||
# They are declared a as new module $(SKETCH_MODULE) in $(SKETCH_MOD_DIR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo SKETCH_MOD_DIR -> SKETCH_MODULE_DIR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I missed this one.
sys/arduino/arduino_sketches.inc.mk
Outdated
# Building the module files | ||
# Do not use $^ in receipes as Makefile is also a prerequisite | ||
$(SKETCH_MODULE_DIR)/Makefile: $(SKETCH_MODULE_DIR)/$(SKETCH_CPP) | ||
$(Q)echo 'SRCXX = $(SKETCH_CPP)' > $@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way this recipe can be called multiple times during the same build? (race condition clobbering the destination file)
For example if building multiple sketches in different source directories?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot put sketches in multiple directories as post.snip
is defining the main
function.
As I understood it, its to replace the code you would put in your application directory by this arduino sketches thing. That's why SKETCHES are in APPDIR
which is basically CURDIR
.
OK to squash |
cf6969f
to
04756e5
Compare
@smlng @haukepetersen do you agree with this version ? |
untested ACK |
I forgot about this one, I think it is pretty much ready for merge. |
I noticed this one suffers from the same problem as all modules where deleting one of the There are different ways to properly fix it:
|
04756e5
to
cb5b52d
Compare
I needs to modify this as now "link" is not the right target to depend anymore |
I was thinking on putting this in |
This was ACK'd almost a year ago. What's the hold-up? |
As my previous comment said, as other PRs were merged I changed things in this one after it was ACK. And I just noticed that, as we had the issue recently in another PR, the directory target will not work on mac as is as it is using I will look into these ones when I find time. |
3cdbe11
to
d683826
Compare
I removed the directory creation target and included it in the The handling of re-building is still done with a |
@smlng this update needs a review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested ACK for arduino-uno
, configuration and documentation looks good.
One question: why sys/arduino/arduino_sketches.inc.mk
and not makefiles/arduino/arduino_sketches.inc.mk
- and (as it is already in a subdir) call the file sketches.inc.mk
?
Otherwise this is good to be merged.
also: please squash |
I find it really stupid as organization to not be in the For the |
Generate a module for arduino sketches in a subfolder of BINDIR. This prevents issues when doing concurrent builds or out of tree build with readonly sources. Declare all generated files as `BUILDDEPS` to be re-created after `clean` on parrallel `clean all`.
c3035df
to
be30f07
Compare
Why is it not showing the commit in the text description? it was this one to help you review: c3035df |
agreed, thanks for the explanation! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
retested ACK
Thank you for the review. This now does not generate files while parsing dependencies anymore ! |
Generate a module for arduino sketches in a subfolder of BINDIR.
This prevents issues when doing concurrent builds or out of tree build with readonly sources.
This fixes #5848
The concept is instead of generating a cpp file in the source directory, it is generated into the build directory. However, this requires defining a new module for this directory.
It is now generated during build and not parsing.
I did not addressed the "write atomically" as I think it is not necessary anymore.
To do this, I replaced the previous bash script by a Makefile script which creates the module as
link
target prerequisite.Testing procedure
As it was not asked before, I will give a testing procedure:
Setup:
Cleanup
chmod u+w examples/arduino_hello-world
It works with this PR.
It fails on master, as we try to write in the directory and so the main function is never declared.
You can also notice that the Permission denied are there before even starting to build. make clean also tries to create the file.
Fixes #5848