Changeset 471


Ignore:
Timestamp:
Oct 25, 2012, 12:56:14 AM (8 years ago)
Author:
ehem
Message:

Split $(PLUGIN_LIST) into $(PLUGINS_AVAIL) and $(PLUGINS_ENAB). Note they're
currently the same value, but the plan is... Add a couple handy variables for
plugins. Adjust documentation to match.

Location:
branches/contrib/plugins
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/contrib/plugins/README

    r447 r471  
    2222will not be applied!
    2323
    24 plugin.mk is included by the plugins.mk Makefile.  The suggested usage is to
    25 add a plugin's target as a prerequisite of an existing DebWrt target.  The
    26 plugin's target will then be invoked before that DebWrt target.  The variable
    27 $(PLUGIN_IDX) will be set to  a unique index for the plugin and the variable
    28 $(PLUGIN_NAME) will be set to the name (directory) of the plugin during the
    29 time Make is parsing the file, beware these WILL change afterwards.  Due to
    30 the way Make works, some machinations are required.
     24plugin.mk is included by the plugins.mk Makefile.  See
     25plugins/example/plugin.mk.example for an example.  Note most rules will require
     26$(PLUGIN_ID) to be copied into a pattern-specific variable.
    3127
    32 An example plugin.mk:
    33 
    34 PLUGIN_$(PLUGIN_IDX)_TESTVAR = some value
    35 
    36 plugins/$(PLUGIN_NAME)/test: PLUGIN_IDX := $(PLUGIN_IDX)
    37 
    38 plugins/$(PLUGIN_NAME)/test:
    39         @echo the variable is \"$(PLUGIN_$(PLUGIN_IDX)_TESTVAR)\"
    40 
    41 With this, running `make plugins/<name of plugin>/test` will produce what you
    42 expect.  It is STRONGLY RECOMMENDED all plugin variables be named
    43 PLUGIN_$(PLUGIN_IDX)<something>, and all plugin rules be named
    44 plugins/$(PLUGIN_NAME)/<something>.
    4528
    4629Make targets to manage plugings. Normally only needed when developing a plugin. Targets:
  • branches/contrib/plugins/example/plugin.mk.example

    r455 r471  
    22#
    33# Copyright (C) 2012 Elliott Mitchell <ehem+debwrt@m5p.com>
     4#       2012-10-21  Initial version of this sample plugin.mk file.
    45#
    56# This program is free software: you can redistribute it and/or modify
     
    2425
    2526#
    26 # This saves our directory name in a variable, this needs to be a simply-
    27 # expanded variable, because $(PLUGIN_NAME) will have a different value later
    28 #
    29 PLUGIN_$(PLUGIN_IDX) := $(PLUGIN_NAME)
    30 
    31 #
    3227# Create a Make variable with a random value
    3328#
    34 PLUGIN_$(PLUGIN_IDX)_TESTVAR = some value
     29$(PLUGIN_VAR)_TESTVAR = some value
    3530
    3631#
    3732# This creates a pattern-specific Make variable, this is needed in order to
    3833# access our variables when the rule is used.  By the time the rule is used,
    39 # $(PLUGIN_IDX) will no longer exist.
     34# $(PLUGIN_ID) will no longer exist.
    4035#
    41 plugins/$(PLUGIN_NAME)/test: PLUGIN_IDX := $(PLUGIN_IDX)
     36$(PLUGIN_RULE)/test: PLUGIN_ID := $(PLUGIN_ID)
     37
    4238#
    4339# This is our rule, it simply prints a couple strings.  This can be invoked
     
    4541# in).
    4642#
    47 plugins/$(PLUGIN_NAME)/test:
    48         @echo I\'m located in the directory \"$(PLUGIN_$(PLUGIN_IDX))\", the variable is \"$(PLUGIN_$(PLUGIN_IDX)_TESTVAR)\", my id is $(PLUGIN_IDX)
     43$(PLUGIN_RULE)/test:
     44        @echo I\'m located in the directory \"$(PLUGIN_NAME)\", the variable is \"$($(PLUGIN_VAR)_TESTVAR)\", my id is $(PLUGIN_ID) you are number 6
     45
    4946#
    5047# This makes us a prerequisite of the "clean" rule, so `make clean` will cause
    5148# us to be invoked.
    5249#
    53 clean: plugins/$(PLUGIN_NAME)/test
     50clean: $(PLUGIN_RULE)/test
    5451
  • branches/contrib/plugins/plugins.mk

    r469 r471  
    2020# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    2121
     22PLUGINS_AVAIL:=$(shell find $(PLUGINS_DIR) -maxdepth 1 -mindepth 1 -type d ! -name '.*' -printf '%f\n')
     23
    2224ifeq ($(PLUGIN),)
    23         PLUGIN_LIST:=$(shell find $(PLUGINS_DIR) -maxdepth 1 -mindepth 1 -type d -name '*' ! -name '.*' -printf '%f\n')
     25        PLUGINS_ENAB=$(PLUGINS_AVAIL)
    2426else
    25         PLUGIN_LIST:=$(PLUGIN)
     27        PLUGINS_ENAB=$(PLUGIN)
    2628endif
    2729
    2830# include plugin.mk from each plugin (allows influence on build process
    2931# without needing to patch Makefiles)
    30 $(foreach PLUGIN_IDX,$(shell seq $(words $(PLUGIN_LIST))),\
    31 $(eval PLUGIN_NAME:=$(word $(PLUGIN_IDX),$(PLUGIN_LIST)))\
    32 $(eval -include $(addprefix plugins/,$(addsuffix /plugin.mk,$(PLUGIN_NAME)))))
    33 PLUGIN_NAME:=\<invalid\>
     32PLUGIN_VAR = PLUGIN_$(PLUGIN_ID)
     33PLUGIN_NAME = $($(PLUGIN_VAR))
     34PLUGIN_RULE = $(PLUGINS_DIR)/$(PLUGIN_NAME)
     35
     36$(foreach PLUGIN_ID,$(shell seq $(words $(PLUGINS_ENAB))),\
     37$(eval $(PLUGIN_VAR):=$(word $(PLUGIN_ID),$(PLUGINS_ENAB)))\
     38$(eval -include $(addprefix $(PLUGINS_DIR)/,$(addsuffix /plugin.mk,$(PLUGIN_NAME)))))
    3439
    3540PLUGIN_CONFIG_LINE = menu \"Plugin $${plugin_up}\"\n\
     
    3742
    3843# add the plugin patches to the list of patches to OpenWRT
    39 OPENWRT_PATCH_DIRS += $(wildcard $(addprefix $(PLUGINS_DIR)/,$(addsuffix /openwrt,$(PLUGIN_LIST))))
     44OPENWRT_PATCH_DIRS += $(wildcard $(addprefix $(PLUGINS_DIR)/,$(addsuffix /openwrt,$(PLUGINS_ENAB))))
    4045
    4146plugins/generate-config: $(TMP_DIR)
    4247        rm -f $(TOPDIR)/tmp/plugins-generated.in
    43         @for plugin in $(PLUGIN_LIST); \
     48        @for plugin in $(PLUGINS_AVAIL); \
    4449        do \
    4550          plugin_up=$$(echo $${plugin} | tr [a-z] [A-Z]); \
     
    5055
    5156plugins/list:
    52         @for plugin in $(PLUGIN_LIST); \
     57        @for plugin in $(PLUGINS_AVAIL); \
    5358        do \
    5459           echo $${plugin}; \
     
    5661
    5762plugins/apply:
    58         @for plugin in $(PLUGIN_LIST); do \
     63        @for plugin in $(PLUGINS_ENAB); do \
    5964                echo "Applying plugin '$$plugin' on DebWrt:"; \
    6065                for patch in `find $(PLUGINS_DIR)/$$plugin/debwrt -maxdepth 2 -mindepth 1 -type f -printf '%f\n' | sort`; do \
     
    7580                exit 0 ; \
    7681        fi ; \
    77         @for plugin in $(PLUGIN_LIST); do \
     82        @for plugin in $(PLUGINS_ENAB); do \
    7883                echo "De-applying plugin '$$plugin' on DebWrt:"; \
    7984                for patch in `find $(PLUGINS_DIR)/$$plugin/debwrt/ -maxdepth 1 -mindepth 1 -type f -printf '%f\n' | sort -r`; do \
Note: See TracChangeset for help on using the changeset viewer.