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

Add support for custom compiler flags in plugins #3110

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/plugins/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ Makefile: Makefile.in

../../plugins/%@DLLEXT@: %.c $(ALL_H) $$(shell ls %/* 2>/dev/null)
@echo " CC $<"
@$(CC) $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @PLUGINSTATIC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ @LIBS@ @MYSQL_LIBS@ -o $@ $<
$(eval PLUGINFLAGS=$(shell grep " #PLUGINFLAGS" $<))
@$(CC) $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @PLUGINSTATIC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ $(PLUGINFLAGS) @SOFLAGS@ @LIBS@ @MYSQL_LIBS@ -o $@ $<

../../plugins/HPMHooking_login@DLLEXT@: HPMHOOKINGTYPE = LOGIN
../../plugins/HPMHooking_char@DLLEXT@: HPMHOOKINGTYPE = CHAR
Expand Down
15 changes: 15 additions & 0 deletions src/plugins/sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/*
// add custom compile flags. Can be any compiler flags.
-DTESTVAR -DTESTVAR2=2 #PLUGINFLAGS
*/

// check is TESTVAR defined from custom compile flags
#ifndef TESTVAR
#error TESTVAR not defined
#endif

// check is TESTVAR2 defined to value 2 from custom compile flags
#if !(TESTVAR2 == 2)
#error TESTVAR2 not defined
#endif

/// Sample Hercules Plugin

#include "common/hercules.h" /* Should always be the first Hercules file included! (if you don't make it first, you won't be able to use interfaces) */
Expand Down