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

CMake: provide plugin name as compiler definition #2360

Merged

Conversation

petermax2
Copy link
Member

@petermax2 petermax2 commented Feb 1, 2019

Provides ELEKTRA_PLUGIN_NAME and ELEKTRA_PLUGIN_NAME_C as compiler definitions via CMake.

See #1042 .

EDIT: This PR does NOT close the issue #1042 .

Basics

Do not describe the purpose here but:

  • Short descriptions should be in the release notes (added as entry in
    doc/news/_preparation_next_release.md which contains *(my name)*)
    Please always add something to the the release notes.
  • Longer descriptions should be in documentation or in design decisions.
  • Describe details of how you changed the code in commit messages
    (first line should have module: short statement syntax)
  • References to issues, e.g. close #X, should be in the commit messages.

Checklist

Check relevant points but please do not remove entries.
For docu fixes, spell checking, and similar none of these points below
need to be checked.

  • I added unit tests
  • I ran all tests locally and everything went fine
  • affected documentation is fixed
  • I added code comments, logging, and assertions (see doc/CODING.md)
  • meta data is updated (e.g. README.md of plugins)

Review

Remove the line below and add the "work in progress" label if you do
not want the PR to be reviewed:

@markus2330 please review my pull request

@markus2330
Copy link
Contributor

Wow, great to see this. I am looking forward to review it soon.

@petermax2
Copy link
Member Author

petermax2 commented Feb 1, 2019

Do you want to get rid of CRYPTO_PLUGIN_FUNCTION and simplify ELEKTRA_PLUGIN_FUNCTION from

ELEKTRA_PLUGIN_FUNCTION(module, function) ELEKTRA_PLUGIN_FUNCTION2 (module, ELEKTRA_VARIANT, function)

to

ELEKTRA_PLUGIN_FUNCTION(function) ELEKTRA_PLUGIN_FUNCTION2 (ELEKTRA_PLUGIN_NAME_C, ELEKTRA_VARIANT, function)

?

It should be possible with the changes in this PR.

Do you prefer a small PR or should I just continue?

@markus2330
Copy link
Contributor

Yes ELEKTRA_PLUGIN_FUNCTION(function) would be great!

Do you prefer a small PR or should I just continue?

Depends on your time budget. It would be good if the PR does not get stuck in the middle.

@petermax2
Copy link
Member Author

OK let's mrege it then, to be sure. I'll use #1042 as follow-up task.

Copy link
Member

@sanssecours sanssecours left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as far as I can tell. Thank you for the update.

# Provides additional compiler definitions:
#
# - ELEKTRA_PLUGIN_NAME containing the short plugin name as string
# - ELEKTRA_PLUGIN_NAME_C contai the short plugin name which can be used in function names
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: contaicontaining


# provide the plugin name as macro that can be used for building function names, etc.
if (NOT "${ARG_COMPILE_DEFINITIONS}" MATCHES "ELEKTRA_PLUGIN_NAME_C")
if (ADDITIONAL_COMPILE_DEFINITIONS_PART1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can replace this if-statement with the following simpler code:

list (APPEND ADDITIONAL_COMPILE_DEFINITIONS_PART2 "ELEKTRA_PLUGIN_NAME_C=${shortname}")

.

@@ -256,7 +256,9 @@ you up to date with the multi-language support provided by Elektra.
anymore, if it is unable to locate a Lua executable. *(René Schwaiger)*
- We added code that makes sure you can compile [IO GLIB](https://www.libelektra.org/bindings/io_glib) on macOS, even if `pkg-config`
erroneously reports that GLIB requires linking to the library `intl` (part of [GNU gettext](https://www.gnu.org/software/gettext)).
*(René Schwaiger)*
(René Schwaiger)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line is already correct, no need to change it back again 😊.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sometimes rebase messes with my brain 😆

@@ -256,7 +256,9 @@ you up to date with the multi-language support provided by Elektra.
anymore, if it is unable to locate a Lua executable. *(René Schwaiger)*
- We added code that makes sure you can compile [IO GLIB](https://www.libelektra.org/bindings/io_glib) on macOS, even if `pkg-config`
erroneously reports that GLIB requires linking to the library `intl` (part of [GNU gettext](https://www.gnu.org/software/gettext)).
*(René Schwaiger)*
(René Schwaiger)
- The plugin name is provided as compiler definition via CMake. See #1042 .*(Peter Nirschl)*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice, if you could also provide a link to issue #1042 here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And a link to the docu or ideally also say which compiler definitions were added.

Copy link
Contributor

@markus2330 markus2330 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, great job!

@@ -1,6 +1,41 @@
include (LibAddMacros)
include (LibAddTest)

# ~~~
# Provides additional compiler definitions:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have this docu also in the API docu of plugins or even in the plugin writing tutorial. But this can also be done in a later PR.

@@ -256,7 +256,9 @@ you up to date with the multi-language support provided by Elektra.
anymore, if it is unable to locate a Lua executable. *(René Schwaiger)*
- We added code that makes sure you can compile [IO GLIB](https://www.libelektra.org/bindings/io_glib) on macOS, even if `pkg-config`
erroneously reports that GLIB requires linking to the library `intl` (part of [GNU gettext](https://www.gnu.org/software/gettext)).
*(René Schwaiger)*
(René Schwaiger)
- The plugin name is provided as compiler definition via CMake. See #1042 .*(Peter Nirschl)*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And a link to the docu or ideally also say which compiler definitions were added.

@@ -5,8 +5,6 @@ add_plugin (base64
base64_functions.c
base64.h
base64.c
COMPILE_DEFINITIONS ELEKTRA_PLUGIN_NAME=\"base64\"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see this simplification!

Similar changes can be done for gpgme, resolver, mmap* (@mpranj)

@markus2330
Copy link
Contributor

Maybe you can also rebase, the Jenkins build failure in master should hopefully be resolved by now #2351

@mpranj mpranj mentioned this pull request Feb 2, 2019
12 tasks
@petermax2
Copy link
Member Author

Thank you both for the great feedback!

@petermax2
Copy link
Member Author

Travis seems to be stuck.

@sanssecours
Copy link
Member

Travis seems to be stuck.

It is not stuck, but the Mac build jobs are just super slow 🐌. I currently work on transferring most of the Mac build jobs to Cirrus CI, which uses VMs that are much faster (about 5 times faster, as far as I can tell).

@markus2330 markus2330 merged commit 182d3a9 into ElektraInitiative:master Feb 4, 2019
@markus2330
Copy link
Contributor

Thank you for this great work!

@petermax2 petermax2 deleted the 1042_elektra_plugin_name branch February 4, 2019 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants