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

Bundle C++ extensions into a single executable #4335

Merged
merged 4 commits into from Jun 3, 2018
Merged

Bundle C++ extensions into a single executable #4335

merged 4 commits into from Jun 3, 2018

Conversation

alessandrogario
Copy link
Member

Introduction

This PR adds a new CMake function (add_osquery_extension_ex) that can be used to declare extension targets that will eventually get compiled into a single executable.

The executable name and version can be changed using the following two environment variables:

  1. OSQUERY_EXTENSION_GROUP_NAME
  2. OSQUERY_EXTENSION_GROUP_VERSION

If they are not present, the executable will be called osquery_extension_group.ext and the version will be set to 1.0.

How it works

First of all, old behavior is not modified in any way; extensions will have to be slightly modified to make use of this functionality. The two approaches can be mixed and will not conflict.

The new add_osquery_extension_ex() function aggregates all extension targets into global project properties. Once the osquery/external folder has been completely evaluated, a C++ file containing all the required includes and REGISTER_EXTERNAL directives is generated. This file is then compiled with the user-supplied implementation files in order to form a single executable.

@facebook-github-bot facebook-github-bot added the cla signed Automated label: Pull Request author has signed the osquery CLA label Apr 27, 2018
@muffins muffins added feature extensions Related to osquery extension SDK or to extensions themselves labels Apr 27, 2018
@obelisk obelisk added this to the 3.3.0 milestone Apr 27, 2018
Copy link
Member

@theopolis theopolis left a comment

Choose a reason for hiding this comment

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

Seems like a neat feature! I haven't read all of the cmake :(

@@ -0,0 +1,9 @@
All the extensions made with the **add_osquery_extension_ex()** CMake function will be automatically bundled into a single executable.
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this inline README approach, can we add a section to the /docs/wiki with similar content?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's better! I moved everything inside the wiki and deleted my README file

* You may select, at your option, one of the above-listed licenses.
*/

#include <osquery/sdk.h>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use the /tools/codegen folder?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done! I moved it in the codegen folder and used a more meaningful name

@facebook-github-bot
Copy link

@alessandrogario has updated the pull request. View: changes

@facebook-github-bot
Copy link

@alessandrogario has updated the pull request.

@facebook-github-bot
Copy link

@alessandrogario has updated the pull request. View: changes

@alessandrogario alessandrogario changed the title WIP: Bundle C++ extensions into a single executable Bundle C++ extensions into a single executable May 1, 2018
@obelisk obelisk self-assigned this May 4, 2018
@obelisk obelisk self-requested a review May 4, 2018 17:39
@facebook-github-bot
Copy link

@alessandrogario has updated the pull request.

@facebook-github-bot
Copy link

@alessandrogario has updated the pull request.

@mkareta mkareta self-requested a review May 28, 2018 13:24
@mkareta
Copy link
Contributor

mkareta commented May 28, 2018

Hi, @alessandrogario, Is it still in progress?
It's look good to me and I generally like idea of producing less binaries, so maybe we should go further and add ability to compile osqueryd and extension into one binary if they are built at the same time. What do you think?

@alessandrogario
Copy link
Member Author

Hello @mkareta!

I feel like this is complete and ready for review (thanks for looking at this!)

I'm not really sure about the idea of merging extensions and osqueryd into a single executable, as I never really thought about this use case.

We are maintaining an extension repository so we felt the need of bundling them together to make them easier to use, but we will keep using the official packages. One thing that I really like is that the maintainers are doing an awesome job at keeping the release quality high, so my preference would still be to avoid grouping extensions and core into a single executable.

This may be really interesting for other user cases though (especially for heavy osqueryi users).

@muffins muffins added ready for review Pull requests that are ready to be reviewed by a maintainer and removed in progress labels May 28, 2018
Copy link
Contributor

@mkareta mkareta left a comment

Choose a reason for hiding this comment

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

Alt text

@mkareta
Copy link
Contributor

mkareta commented Jun 2, 2018

ok to test

@mkareta mkareta merged commit 5006a02 into osquery:master Jun 3, 2018
@alessandrogario alessandrogario deleted the alessandro/feature/extension-bundling branch June 12, 2018 12:21
trizt pushed a commit to trizt/osquery that referenced this pull request May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Automated label: Pull Request author has signed the osquery CLA extensions Related to osquery extension SDK or to extensions themselves feature ready for review Pull requests that are ready to be reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants