-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add plugin/CMakeLists.txt #37
Draft
awelzel
wants to merge
1
commit into
master
Choose a base branch
from
topic/awelzel/35-use-add-subdir
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" | ||
"${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY) | ||
|
||
include(ZeekPlugin) | ||
|
||
zeek_plugin_begin(@NS@ @NAME@) | ||
|
||
file(GLOB cc_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "src/*.cc") | ||
foreach(file ${cc_files}) | ||
zeek_plugin_cc(${file}) | ||
endforeach () | ||
|
||
file(GLOB bif_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "src/*.bif") | ||
foreach(file ${bif_files}) | ||
zeek_plugin_bif(${file}) | ||
endforeach () | ||
|
||
# Copy the dist files to package with the tarball into the top-level | ||
# build directory to fulfill zeek-plugin-create-package.sh assumptions | ||
# about them being located in the parent directory. | ||
set(dist_files README CHANGES COPYING VERSION) | ||
foreach(file ${dist_files}) | ||
if ( EXISTS ../${file} ) | ||
file(COPY ../${file} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/../) | ||
endif() | ||
endforeach () | ||
|
||
zeek_plugin_dist_files(${dist_files}) | ||
|
||
zeek_plugin_end() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
=== without test/scripts | ||
plugin/scripts/__load__.zeek | ||
plugin/scripts/__preload__.zeek | ||
=== with test/scripts | ||
plugin/scripts/__load__.zeek | ||
plugin/scripts/__preload__.zeek | ||
scripts/__load__.zeek | ||
scripts/main.zeek | ||
Hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# A test to verify that plugin/scripts/ is used as the plugin's script | ||
# directory rather than the top-level scripts/ directory. | ||
# | ||
# Regression test for #35. | ||
# | ||
# @TEST-REQUIRES: make --version | ||
# @TEST-REQUIRES: cmake --help | grep -q '^* Unix Makefiles' | ||
# | ||
# @TEST-EXEC: bash %INPUT | ||
# | ||
# @TEST-EXEC: cd test && ./configure 1>&2 | ||
# @TEST-EXEC: make -C test/build/ -j`nproc` 1>&2 | ||
# @TEST-EXEC: echo "=== without test/scripts" >>output | ||
# @TEST-EXEC: ZEEK_PLUGIN_PATH=./test/build zeek </dev/null >>output | ||
# @TEST-EXEC: echo "=== with test/scripts" >>output | ||
# @TEST-EXEC: ZEEK_PLUGIN_PATH=./test/build zeek ./test/scripts >>output | ||
# @TEST-EXEC: btest-diff output | ||
|
||
${SCRIPTS}/zkg create --packagedir=test --features plugin --user-var name=Name --user-var namespace=Namespace | ||
|
||
echo 'event zeek_init() &priority=40 { print "plugin/scripts/__load__.zeek"; }' >> test/plugin/scripts/__load__.zeek | ||
echo 'event zeek_init() &priority=30 { print "plugin/scripts/__preload__.zeek"; }' >> test/plugin/scripts/__preload__.zeek | ||
echo 'event zeek_init() &priority=20 { print "scripts/__load__.zeek"; }' >> test/scripts/__load__.zeek | ||
echo 'event zeek_init() &priority=10 { print "scripts/main.zeek"; }' >> test/scripts/main.zeek |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I mentioned offline, not a fan of the magic modifications to the "file names" since this makes it pretty hard to modify for users, what if they want to e.g., include a generated file in the tarball? I'd prefer just directly referencing files with relative paths and requiring them to exist; in addition to the technical implementation comment we also need a user-targeted comment explaining what this variable is for -- for anything else we use magic globs 🤢.
Probably worse, I just noticed that packaging already copies some files around, https://github.com/zeek/cmake/blob/2df3b8e82a843b7b8187963d259d32a9fb42b873/ConfigurePackaging.cmake#L133-L140, i.e., we would already create a
README.txt
andCOPYING.txt
in the build directory. This could potentially clash with what users set up here (e.g., if they named theirREADME
asREADME.txt
). I do not think there is a good automagic way to fix this, can we augmentzeek-plugin-create-package.sh
so it can understand explicit dist files?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I fully understand how to do this, but agree the file copying isn't great - it just attempts to please
zeek-plugin-create-package.sh
. Plainly using.../VERSION
currently fails as the create package script then copies it not intodist
, butdist/../VERSION
. Hmm, we could possibly just strip the leading../
's before determining the destination directory within./dist
, that could actually be "okay".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also just have the semantics that the files end up in the same place they were relative to the
CMakeLists.txt
withproject
here, e.g., from a subdirectory../README
(which is the same as<project>/README
) gets copied<dist>/README
. I left a similar comment on zeek/cmake#116.