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

ARDUIFINE: global compiler options extracted from ctags parsing #1117

Closed
wants to merge 1 commit into from

Conversation

d-a-v
Copy link
Contributor

@d-a-v d-a-v commented Dec 28, 2020

  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • The PR follows our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Example: these lines in the .ino file:

    const char* ARDUIFINE_abc = "MYLIB_BUFFER_LEN=1234";
    const char* ARDUIFINE_def = "MYLIB_PARAM";
    const char* ARDUINOGLOBAL_ghi = "-DMYLIB2_BUFFER_LEN=1234";
    const char* ARDUINOGLOBAL_jkl = "-DMYLIB2_PARAM";

will globally enable the following options in the compiler command line:

        -DMYLIB_BUFFER_LEN=1234 -DMYLIB_PARAM -DMYLIB2_BUFFER_LEN=1234 -DMYLIB2_PARAM

That, including during compilation of the core and libraries.

If they are not otherwise used by the sketch, the symbols ARDUIFINExxx and ARDUINOGLOBALyyy are excluded from the final binary at link time.

This PR aims at giving a solution to arduino/Arduino#421
and is maybe related to #846.


arduifine
(the missing M is fixed)

@d-a-v
Copy link
Contributor Author

d-a-v commented Dec 28, 2020

I would have preferred to propose something like

#arduifine BLAH 1

or

#pragma comment("ARDUIFINE: -Dblah")

but that would have required parsing the whole .ino files.
The simpler the better: the ctags parser is already here.

@d-a-v
Copy link
Contributor Author

d-a-v commented Jan 4, 2021

About security, the compiler command line is affected but user is warned in the message console.
Additional parsing can be added to ensure that not too special characters are used in the macro defined by "ARDUIFINE" and "ARDUINOGLOBAL" feature can be disabled if it is considered as too dangerous.
@facchinm this is close to this comment.

This PR, apart from adding more noise to an old feature request, is another attempt to finally find an answer to arduino/Arduino#421.
Per this PR, I'd like to bring to anyone interested's attention that the feature is needed.
One of the important use-cases is that it allows users to avoid modifying libraries when some parameters are to be tuned.
(this feature is provided with other IDE able to compile Arduino projects like platformIO or sloeber)

I'm aware that I updated in the legacy/ directory. Are there specific considerations about this directory that should be known by contributors ?

I will be happy to close this PR if any other way is found to close arduino/Arduino#421 which has been opened for 8 years. Attempts or explorations are quite numerous, like this commit(from @facchinm in #421), or one from the link list compiled by @per1234 in #846's OP. I'll also be glad to update this PR until it fits with maintainers idea of what are arduino-cli / arduino-builder.

@github-actions github-actions bot closed this Mar 30, 2021
@per1234 per1234 reopened this Mar 30, 2021
@d-a-v
Copy link
Contributor Author

d-a-v commented May 10, 2021

My opinion is that there are valid use cases for macro-based interfaces [...] but that it is not appropriate to expect normal users to define global macros in order to use a library

@per1234, this change proposal even as a PoC is orthogonal to your above statement.
You make me believe this opinion is close to official Arduino's, in which case I should close this PR :)

#846's title "Provide dedicated sets of "extra flags" properties for platform developers and users" did make me think that it is "legal" to provide such facility to users.

I have indeed two use-cases on widely used arduino libraries:

IMHO It could be a normal use for an Arduino library to need a global define to get some extended behaviour, at no cost when
they are not needed (= without state variable and related code that costs space on small hw).

I would really like clarification on how Arduino plans to address such issues.

edit 24 days later:

@d-a-v
Copy link
Contributor Author

d-a-v commented Oct 20, 2021

closed per #1517 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants