-
Notifications
You must be signed in to change notification settings - Fork 1k
Use recipe.hooks feature of the platform.txt file #41
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
Comments
Thanks @fprwi6labs. |
Fix stm32duino#41 Signed-off-by: Frederic Pillon <[email protected]>
stm32duino/Arduino_Core_STM32#41 Signed-off-by: Frederic Pillon <[email protected]>
It is now possible to customize some core definitions or gcc options thanks a file named "build_opt.h" in the sketch directory. (using @file gcc option) Example of file content to change F_CPU value: -UF_CPU -DF_CPU=72000000UL If the file does not exist an empty one is created. Fix stm32duino#41 Signed-off-by: Frederic Pillon <[email protected]>
Hi @RickKimball |
I just saw your change. Excellent thanks! I'll give it a spin.. Your idea to use a .h file is a great idea. |
It is now possible to customize some core definitions or gcc options thanks a file named "build_opt.h" in the sketch directory. (using @file gcc option) Example of file content to change F_CPU value: -UF_CPU -DF_CPU=72000000UL If the file does not exist an empty one is created. Fix stm32duino#41 Signed-off-by: Frederic Pillon <[email protected]>
It is now possible to customize some core definitions or gcc options thanks a file named "build_opt.h" in the sketch directory. (using @file gcc option) Example of file content to change F_CPU value: -UF_CPU -DF_CPU=72000000UL If the file does not exist an empty one is created. Fix stm32duino#41 Signed-off-by: Frederic Pillon <[email protected]>
It is now possible to customize some core definitions or gcc options thanks a file named "build_opt.h" in the sketch directory. (using @file gcc option) Example of file content to change F_CPU value: -UF_CPU -DF_CPU=72000000UL If the file does not exist an empty one is created. Fix stm32duino#41 Signed-off-by: Frederic Pillon <[email protected]>
Orignally posted in #38 by @RickKimball
I think you could take advantage of the recipe.hooks feature of the platform.txt file to conditionally override defines and gcc command line arguments on a per sketch basis. This seems to be a fairly new feature (since Arduino 1.6.something) something they added since I last looked to accomplish something like this.
You might approach it like this:
In the stm32 tools directory create a new tool called 'cpif' which copies a file called gcc_options.txt into the build directory if the file exists in the sketch directory or copies /dev/null if it doesn't
In platform.txt you add a recipe hook that is called before starting the build process.
modify the board.txt to use the @file feature of gcc or just add it to the platform.txt for all boards
When the user wants to override defines and gcc command line arguments they create a file called gcc_options.txt in the sketch directory. Here I imagine I want to override the F_CPU value
When I compile it uses the sketch specific defines and overrides.
Of course you would have to make this work with the different OS types. You would also have to deal with finding the users preference sketch home directory. I just hard coded it in the example above to use my $HOME/Arduino directory.
Seems doable (I actually have this working ) if you care to open yourself to all kinds of user problems when they do bad things : )
The text was updated successfully, but these errors were encountered: