Skip to content

Prebuild hook in new compiler #3799

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

Closed
wants to merge 1 commit into from
Closed

Prebuild hook in new compiler #3799

wants to merge 1 commit into from

Conversation

Wackerbarth
Copy link
Contributor

The new compiler dropped the prebuild hook

@Wackerbarth Wackerbarth changed the title Rebuild hook in new compiler Prebuild hook in new compiler Sep 15, 2015
@ffissore
Copy link
Contributor

No it didn't: see this line of code. Can you provide a platform.txt that specifies them?

@ffissore
Copy link
Contributor

Maybe that's the wrong place for executing that module and it should be moved down in the call chain

@ffissore
Copy link
Contributor

Yes indeed. My fault. Fixing right now

@ffissore
Copy link
Contributor

Fixed with 21ada82. Fix will be available with next hourly build http://www.arduino.cc/en/Main/Software#hourly

@ffissore ffissore closed this Sep 16, 2015
@ffissore ffissore added Type: Bug Component: Compilation Related to compilation of Arduino sketches labels Sep 16, 2015
@ffissore ffissore added this to the Release 1.6.6 milestone Sep 16, 2015
@ffissore ffissore self-assigned this Sep 16, 2015
@Wackerbarth
Copy link
Contributor Author

@ffissore -- Sorry, but your "fix" doesn't work.
Please re-open this PR.

(I just recompiled it myself after updating my local repository)

From my platform.local

compiler.cpp.extra_flags=-D USE_AUTOMATIC_VERSIONING
build.custom_bin.path.macosx=/usr/local/bin/
recipe.hooks.prebuild0.pattern=mkdir -p "{build.path}/sketch/"
recipe.hooks.prebuild1.pattern={build.custom_bin.path}generate_version_header_for_marlin "{build.source.path}" "{build.path}/sketch/_Version.h"

Note that the prebuild0 recipe was just added because the target area doesn't yet exist when my patch gets executed.

generate_version_header_for_marlin is a simple bash script:
The significant part of it is

DIR=`dirname $1` export DIR
OUTFILE="$2" export OUTFILE
echo "" >>"$OUTFILE"

and other lines that build the useful contents of the _Version.h file

And that file is expected because the headers have a

 #include "_Version.h"

So, I expect my hook to be called before the preprocessor runs.

@ffissore
Copy link
Contributor

You're right. Bug is that in looking for the hooks I forgot to prefix "recipe.". Fixing right now

@ffissore ffissore reopened this Sep 17, 2015
@NicoHood
Copy link
Contributor

May anyone explain me the feature you are talking about? I am interested and I'v never heard of that, sorry.

@ffissore
Copy link
Contributor

Another fix is available with hourly builds http://www.arduino.cc/en/Main/Software#hourly. Please give it a try

@ffissore ffissore closed this Sep 17, 2015
@Wackerbarth
Copy link
Contributor Author

This time I think you got it.

@Wackerbarth
Copy link
Contributor Author

@NicoHood -- As with a number of build procedures, it is often useful to have a custom operation performed at the beginning of the build process.

I utilize this hook to run a script which uses git describe to extract information from the currently checked out version of my repository and create a header file which I then include in the compiled sources to make available, at run time, a version identification string.

The advantage in doing so is that each build is uniquely identified without the necessity of my manual updating of that identifier string.

I might also add that it allows the version string to be generated without subsequently modifying the repository. This allows a true self-reference that reflects the true commit identifier of the complete source used to generate the resulting object files.

You can look in my comments (above) to see an example.

@thaanstad
Copy link

I believe this bug has reappeared. I am compiling for the adafruit NRF52 and the build.source.path is pointing to the .ino file.

platform.txt file:
recipe.hooks.sketch.prebuild.0.pattern= C:\Program Files (x86)\Arduino\increment.bat {build.path} {build.source.path} {build.project_name}

build output:
recipe.hooks.sketch.prebuild.0.pattern C:\Program Files (x86)\Arduino\increment.bat C:\Users\thaanstad\AppData\Local\Temp\VMBuilds\RTCSleepTest\adafruit_feather52\Release C:\Users\thaanstad\Desktop\ArduinoSketchLocationWC\trunk\RTCSleepTest\RTCSleepTest.ino RTCSleepTest.ino Process: C:\Program Files (x86)\Arduino\increment.bat C:\Users\thaanstad\AppData\Local\Temp\VMBuilds\RTCSleepTest\adafruit_feather52\Release C:\Users\thaanstad\Desktop\ArduinoSketchLocationWC\trunk\RTCSleepTest\RTCSleepTest.ino RTCSleepTest.ino The system cannot find the file specified

@facchinm
Copy link
Member

Hi @thaanstad ,
which IDE version and NRF core are you using?

@thaanstad
Copy link

facchinm,

I am using Arduino 1.8.5 along with visual micro however the output is from a compile in the Arduino IDE. I am using Adafruit's NRF52 0.8.4 core downloaded from boards manager. I can provide files or portions thereof if needed for debugging.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Compilation Related to compilation of Arduino sketches Type: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants