diff options
author | Loïc Hoguin <[email protected]> | 2019-07-18 09:59:28 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-07-18 10:08:46 +0200 |
commit | 136d443b5c38bee96f5d995dfea3629ef07564c3 (patch) | |
tree | 1d31540baebc43ca0b2dceeda212c44f5da7e7a8 /docs/en/erlang.mk/1/guide/external_plugins.asciidoc | |
parent | e031713c0e8bd871248dbbbbdec1ea28609f4431 (diff) | |
download | ninenines.eu-136d443b5c38bee96f5d995dfea3629ef07564c3.tar.gz ninenines.eu-136d443b5c38bee96f5d995dfea3629ef07564c3.tar.bz2 ninenines.eu-136d443b5c38bee96f5d995dfea3629ef07564c3.zip |
Announce Ranch 2.0.0-rc.1
Adds Ranch 2.0 documentation and removes documentation for
very old Cowboy and Ranch, along with Erlang.mk documentation
which is available on its own website.
Diffstat (limited to 'docs/en/erlang.mk/1/guide/external_plugins.asciidoc')
-rw-r--r-- | docs/en/erlang.mk/1/guide/external_plugins.asciidoc | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/docs/en/erlang.mk/1/guide/external_plugins.asciidoc b/docs/en/erlang.mk/1/guide/external_plugins.asciidoc deleted file mode 100644 index 5f165f50..00000000 --- a/docs/en/erlang.mk/1/guide/external_plugins.asciidoc +++ /dev/null @@ -1,140 +0,0 @@ -[[plugins_usage]] -== External plugins - -It is often convenient to be able to keep the build files -used by all your projects in one place. Those files could -be Makefiles, configuration files, templates and more. - -Erlang.mk allows you to automatically load plugins from -dependencies. Plugins can do anything, including defining -new variables, defining file templates, hooking themselves -inside the normal Erlang.mk processing or even adding new -rules. - -You can load plugins using one of two methods. You can -either load all plugins from a dependency, or just one. -We will also cover conventions about writing external -plugins. - -=== Loading all plugins from a dependency - -To load plugins from a dependency, all you need to do is add -the dependency name to `DEP_PLUGINS` in addition to the list -of dependencies. - -For example, if you have `cowboy` in `DEPS`, add `cowboy` in -`DEP_PLUGINS` also: - -[source,make] -DEPS = cowboy -DEP_PLUGINS = cowboy - -This will load the file 'plugins.mk' in the root folder of -the Cowboy repository. - -=== Loading one plugin from a dependency - -Now that we know how to load all plugins, let's take a look -at how to load one specific plugin from a dependency. - -To do this, instead of writing only the name of the dependency, -we will write its name and the path to the plugin file. This -means that writing `DEP_PLUGINS = cowboy` is equivalent to -writing `DEP_PLUGINS = cowboy/plugins.mk`. - -Knowing this, if we were to load the plugin 'mk/dist.mk' -from Cowboy and no other, we would write the following in -our Makefile: - -[source,make] -DEPS = cowboy -DEP_PLUGINS = cowboy/mk/dist.mk - -=== Writing external plugins - -The 'plugins.mk' file is a convention. It is meant to load -all the plugins from the dependency. The code for the plugin -can be written directly in 'plugins.mk' or be separate. - -If you are providing more than one plugin with your repository, -the recommended way is to create one file per plugin in the -'mk/' folder in your repository, and then include those -individual plugins in 'plugins.mk'. - -For example, if you have two plugins 'mk/dist.mk' and -'mk/templates.mk', you could write the following 'plugins.mk' -file: - -[source,make] -THIS := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) -include $(THIS)/mk/dist.mk -include $(THIS)/mk/templates.mk - -The `THIS` variable is required to relatively include files. - -This allows users to not only be able to select individual -plugins, but also select all plugins from the dependency -in one go if they wish to do so. - -Plugins can include some help text by extending the target -`help-plugins`: - -[source,make] ----- -help-plugins:: - $(verbose) printf "%s\n" "" "Run benchmark: $(MAKE) perfs" ----- - -=== Early-stage plugins - -Plugins declared in `DEP_PLUGINS` are loaded near the end of Erlang.mk. -That's why you have access to all previously initialized variables. -However, if you want your plugin to add common dependencies to -your applications, a regular is loaded too late in the process. -You need to use "Early-stage plugins". They are declared using the -`DEP_EARLY_PLUGINS` variable instead. Plugins listed in this variable -are loaded near the beginning of Erlang.mk Otherwise, they work exactly -the same. - -If you only give the name of a dependency, the default file loaded is -'early-plugins.mk'. You can specify a filename exactly like you would -have done it with regular plugins. - -[source,make] -# In your application's Makefile -BUILD_DEPS = common_deps -DEP_EARLY_PLUGINS = common_deps - -[source,make] -# In the plugin's early-plugins.mk -DEPS += cowboy -TEST_DEPS = ct_helper -dep_ct_helper = git https://github.com/ninenines/ct_helper master - -=== Loading plugins local to the application - -If the Erlang.mk plugin lives in the same directory or repository as your -application or library, then you can load it exactly like an external -plugin: the dependency name is simply the name of your application or -library. - -For example, the following Makefile loads a plugin in the 'mk' -subdirectory: - -[source,make] -DEP_PLUGINS = $(PROJECT)/mk/dist.mk - -This also works with early-stage plugins: - -[source,make] -DEP_EARLY_PLUGINS = $(PROJECT)/mk/variables.mk - -Like external plugins, if you do not specify the path to the plugin, it -defaults to 'plugins.mk' or 'early-plugins.mk', located at the root of -your application: - -[source,make] -# Loads ./early-plugins.mk -DEP_EARLY_PLUGINS = $(PROJECT) -# Loads ./plugins.mk -DEP_PLUGINS = $(PROJECT) |