moredip/Frank — pull request #220 by krukow (2013-05-26 16:47:46+00:00)
Title: Add support for plugins

This pull-request adds support for plugins for Frank (for example Calabash iOS will be a plugin to Frank soon via this mechanism).

A plugin will typically add a selector engine, add routes, add categories and generally interact with or configure other core Frank objects.

Plugins are linked-in at "frank build"-time.

The idea is to formalise plugins in the following way.

1. frank setup now creates a new directory Frank/plugins. Plugins are 'installed' in a project by creating a sub-directory of this plugins directory (and adding certain files).

2. each plugin must have a unique name, e.g. 'calabash', and place files in Frank/plugins/[NAME], e,g.

Frank/plugins/calabash/libCalabash.a

3. each plugin must participate in frank build by placing an ERB file: [NAME].xcconfig.erb file in its plugin-directory e.g,

Frank/plugins/calabash/calabash.xcconfig.erb

So for the Calabash plugin:

06:13 PM $ tree Frank/plugins
└── calabash
├── calabash.xcconfig.erb
└── libCalabash.a

Now 'frank build' is changed slightly to allow for these plugins to participate: A frank.xcconfig file is generated at build-time to include frank core and all plugins' .xcconfigs.

Here's the Calabash example generated frank.xcconfig:

#include "frankify.xcconfig"
#include "plugins/calabash/calabash.xcconfig"

INSTALL_PATH = /./

FRANK_LDFLAGS = $(FRANK_CORE_LDFLAGS) $(CALABASH_LDFLAGS)

FRANK_GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = $(FRANK_CORE_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS) $(CALABASH_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS)

(see also frankify.xcconfig which defines FRANK_CORE_XX).

Finally, plugins may themselves have other dependencies. Here is an imaginary example:

06:39 PM $ cat Frank/plugins/calabash/calabash.xcconfig.erb
CALABASH_LDFLAGS=-lCalabash <%= dependency 'Example' %>

These are added by calling the dependency method inside the .erb file. This will usually just link-in the dependency (-lExample), but allows the user to exclude the dependency at build-time using --without-dependencies, e.g.:

frank build --workspace=WordPress.xcworkspace --scheme WordPress --without-dependencies Example OtherExample
...
Detected plugins: calabash
Excluding plugin dependencies: Example, OtherExample

As a first example, we'll provide libCalabash.a as a dependency very soon.