Difference between revisions of "Building HPM Plugin for gcc"

From Hercules Wiki
Jump to: navigation, search
(Created page with "This is a guide on how to prepare your gcc environment for a new HPM plugin. = Guide = Lets say your '''src/plugins/Makefile.in''' file looks like the following (it probab...")
 
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
This is a guide on how to prepare your gcc environment for a new [[HPM]] plugin.
 
This is a guide on how to prepare your gcc environment for a new [[HPM]] plugin.
 
= Guide =
 
= Guide =
Lets say your '''src/plugins/Makefile.in''' file looks like the following (it probably will be similar):
+
In your '''src/plugins/Makefile.in''' file you should find something like:
  COMMON_H = ../common/HPMi.h ../common/cbasetypes.h
+
  ################  PLUGIN CONFIGURATION  ##############################
 +
#                                                                    #
 +
# When you add a plugin, add its name here:                          #
 +
# Example: if you have a plugin named my_cool_plugin.c and another  #
 +
# one named my_second_plugin.c, add them to the list like this:      #
 +
#                                                                    #
 +
# MYPLUGINS = my_cool_plugin my_second_plugin                        #
 +
#                                                                    #
 +
# Note: DO NOT include the .c extension!!!                          #
 
   
 
   
  PLUGINS = sample
+
  MYPLUGINS =  
+
add your plugin name (without the .c extension), after '''MYPLUGINS =''' save and close.<br/>
@SET_MAKE@
+
Lastly, run '''make plugins''' command at the root folder of Hercules, and you're good to go.
+
 
#####################################################################
+
 
.PHONY : all $(PLUGINS) sample clean help
+
Edit '''conf/plugins.conf'''
+
and add your plugin in the plugins list:
all: $(PLUGINS)
+
 
+
  plugins_list: [
sample: sample@DLLEXT@
+
        /* Enable HPMHooking when plugins in use rely on Hooking */
+
        "HPMHooking",
clean:
+
        //"example",
@echo " CLEAN plugins"
+
        //"other",
  @rm -rf *.o
+
        "my_cool_plugin",
+
        "my_second_plugin",
help:
+
  ]
@echo "possible targets are $(PLUGINS:%='%') 'all' 'clean' 'help'"
+
 
@echo "'sample'  - sample plugin"
+
 
@echo "'help'    - outputs this message"
+
Run your server.(And plugins will be loaded)
+
 
#####################################################################
+
+
%@DLLEXT@: %.c $(COMMON_H)
+
@echo " CC $<"
+
@@CC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o ../../plugins/$@ $<
+
and the plugin you want to add is called '''sample2''', it will end up like the following:
+
COMMON_H = ../common/HPMi.h ../common/cbasetypes.h
+
+
PLUGINS = sample sample2
+
+
@SET_MAKE@
+
+
#####################################################################
+
.PHONY : all $(PLUGINS) sample sample2 clean help
+
+
all: $(PLUGINS)
+
+
  sample: sample@DLLEXT@
+
+
sample2: sample2@DLLEXT@
+
+
clean:
+
@echo " CLEAN plugins"
+
@rm -rf *.o
+
+
help:
+
@echo "possible targets are $(PLUGINS:%='%') 'all' 'clean' 'help'"
+
@echo "'sample'  - sample plugin"
+
@echo "'help'    - outputs this message"
+
   
+
#####################################################################
+
+
%@DLLEXT@: %.c $(COMMON_H)
+
@echo " CC $<"
+
@@CC@ @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o ../../plugins/$@ $<
+
Use CTRL+F to ensure you locate all the occurrences of '''sample2''', then edit the same way in your '''src/plugins/Makefile.in''', save and close.<br/>
+
Lastly, re-run your '''./configure''' command at the root folder of Hercules, and you're good to go.
+
 
[[HPM]]
 
[[HPM]]
 +
[[Category:Installation]]

Latest revision as of 05:38, 24 October 2014

This is a guide on how to prepare your gcc environment for a new HPM plugin.

Guide

In your src/plugins/Makefile.in file you should find something like:

################  PLUGIN CONFIGURATION  ##############################
#                                                                    #
# When you add a plugin, add its name here:                          #
# Example: if you have a plugin named my_cool_plugin.c and another   #
# one named my_second_plugin.c, add them to the list like this:      #
#                                                                    #
# MYPLUGINS = my_cool_plugin my_second_plugin                        #
#                                                                    #
# Note: DO NOT include the .c extension!!!                           #

MYPLUGINS = 

add your plugin name (without the .c extension), after MYPLUGINS = save and close.
Lastly, run make plugins command at the root folder of Hercules, and you're good to go.


Edit conf/plugins.conf and add your plugin in the plugins list:

plugins_list: [
       /* Enable HPMHooking when plugins in use rely on Hooking */
       "HPMHooking",
       //"example",
       //"other",
       "my_cool_plugin",
       "my_second_plugin",
]


Run your server.(And plugins will be loaded)

HPM