Skip to content

Commit

Permalink
configure: (mostly) revert b7a56f0
Browse files Browse the repository at this point in the history
Plugins are a first-class citizen again.

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Jan 15, 2019
1 parent 94eb262 commit 61420bf
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 32 deletions.
8 changes: 0 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ CWARNFLAGS=${CWARNFLAGS:--Werror -Wall -Wundef -Wmissing-prototypes -Wmissing-de
CDEBUGFLAGS=${CDEBUGFLAGS:--std=gnu11 -g -fstack-protector}
DEVELOPER=${DEVELOPER:-0}
EXPERIMENTAL_FEATURES=${EXPERIMENTAL_FEATURES:-0}
PLUGINS=${PLUGINS:-0}
COMPAT=${COMPAT:-1}
STATIC=${STATIC:-0}
CONFIGURATOR_CC=${CONFIGURATOR_CC:-$CC}
Expand Down Expand Up @@ -56,10 +55,6 @@ usage()
echo " Compatibility mode, good to disable to see if your software breaks"
usage_with_default "--enable/disable-valgrind" "(autodetect)"
echo " Valgrind binary to use for tests"
usage_with_default "--enable/disable-experimental-features" "disable"
echo " Experimental features (not for network use!)"
usage_with_default "--enable/disable-plugins" "disable"
echo " Support for plugins"
usage_with_default "--enable/disable-static" "$STATIC" "enable" "disable"
echo " Static link binary"
exit 1
Expand Down Expand Up @@ -118,8 +113,6 @@ for opt in "$@"; do
--disable-developer) DEVELOPER=0;;
--enable-experimental-features) EXPERIMENTAL_FEATURES=1;;
--disable-experimental-features) EXPERIMENTAL_FEATURES=0;;
--enable-plugins) PLUGINS=1;;
--disable-plugins) PLUGINS=0;;
--enable-compat) COMPAT=1;;
--disable-compat) COMPAT=0;;
--enable-valgrind) VALGRIND=1;;
Expand Down Expand Up @@ -158,7 +151,6 @@ add_var CDEBUGFLAGS "$CDEBUGFLAGS"
add_var VALGRIND "$VALGRIND"
add_var DEVELOPER "$DEVELOPER" $CONFIG_HEADER
add_var EXPERIMENTAL_FEATURES "$EXPERIMENTAL_FEATURES" $CONFIG_HEADER
add_var PLUGINS "$PLUGINS" $CONFIG_HEADER
add_var COMPAT "$COMPAT" $CONFIG_HEADER
add_var PYTEST "$PYTEST"
add_var STATIC "$STATIC"
Expand Down
2 changes: 1 addition & 1 deletion doc/PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ variety of ways:
internal events in `lightningd` and alter its behavior or inject
custom behaviors.

*Notice: you need to pass `--enable-plugins` to `./configure` to turn on plugins for now, and hooks are not yet implemented. The API is under active development.*
*Note: Hooks are not yet implemented, and the API is under active development.*

A plugin may be written in any language, and communicates with
`lightningd` through the plugin's `stdin` and `stdout`. JSON-RPCv2 is
Expand Down
14 changes: 4 additions & 10 deletions lightningd/lightningd.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,8 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
*code. Here we initialize the context that will keep track and control
*the plugins.
*/
#ifdef PLUGINS
ld->plugins = plugins_new(ld, ld->log_book, ld->jsonrpc, ld);
#endif

return ld;
}

Expand Down Expand Up @@ -362,11 +361,10 @@ static const char *find_my_pkglibexec_path(struct lightningd *ld,

/*~ The plugin dir is in ../libexec/c-lightning/plugins, which (unlike
* those given on the command line) does not need to exist. */
#ifdef PLUGINS
add_plugin_dir(ld->plugins,
path_join(tmpctx, pkglibexecdir, "plugins"),
true);
#endif

/*~ Sometimes take() can be more efficient, since the routine can
* manipulate the string in place. This is the case here. */
return path_simplify(ld, take(pkglibexecdir));
Expand All @@ -379,11 +377,9 @@ static const char *find_daemon_dir(struct lightningd *ld, const char *argv0)
/* If we're running in-tree, all the subdaemons are with lightningd. */
if (has_all_subdaemons(my_path)) {
/* In this case, look in ../plugins */
#ifdef PLUGINS
add_plugin_dir(ld->plugins,
path_join(tmpctx, my_path, "../plugins"),
true);
#endif
return my_path;
}

Expand Down Expand Up @@ -665,9 +661,8 @@ int main(int argc, char *argv[])
/*~ Initialize all the plugins we just registered, so they can
* do their thing and tell us about themselves (including
* options registration). */
#ifdef PLUGINS
plugins_init(ld->plugins, ld->dev_debug_subprocess);
#endif

/*~ Handle options and config; move to .lightningd (--lightning-dir) */
handle_opts(ld, argc, argv);

Expand Down Expand Up @@ -767,9 +762,8 @@ int main(int argc, char *argv[])

/*~ Now that the rpc path exists, we can start the plugins and they
* can start talking to us. */
#ifdef PLUGINS
plugins_config(ld->plugins);
#endif

/*~ We defer --daemon until we've completed most initialization: that
* way we'll exit with an error rather than silently exiting 0, then
* realizing we can't start and forcing the confused user to read the
Expand Down
3 changes: 1 addition & 2 deletions lightningd/lightningd.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,8 @@ struct lightningd {
bool use_proxy_always;
char *tor_service_password;
bool pure_tor_setup;
#ifdef PLUGINS

struct plugins *plugins;
#endif
};

const struct chainparams *get_chainparams(const struct lightningd *ld);
Expand Down
3 changes: 1 addition & 2 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ static void config_register_opts(struct lightningd *ld)
&ld->config_filename,
"Specify configuration file. Relative paths will be prefixed by lightning-dir location. (default: config)");

#ifdef PLUGINS
/* Register plugins as an early args, so we can initialize them and have
* them register more command line options */
opt_register_early_arg("--plugin", opt_add_plugin, NULL, ld,
Expand All @@ -332,7 +331,7 @@ static void config_register_opts(struct lightningd *ld)
opt_register_early_arg("--disable-plugin", opt_disable_plugin,
NULL, ld,
"Disable a particular plugin by filename/name");
#endif

opt_register_noarg("--daemon", opt_set_bool, &ld->daemon,
"Run in the background, suppress stdout/stderr");
opt_register_arg("--ignore-fee-limits", opt_set_bool_arg, opt_show_bool,
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
DEVELOPER = os.getenv("DEVELOPER", config['DEVELOPER']) == "1"
TEST_DEBUG = os.getenv("TEST_DEBUG", "0") == "1"


if TEST_DEBUG:
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)

Expand Down
8 changes: 0 additions & 8 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from collections import OrderedDict
from fixtures import * # noqa: F401,F403
from lightning import RpcError
from utils import PLUGINS

import pytest
import subprocess
import unittest


@unittest.skipIf(not PLUGINS, "plugin subsystem requires PLUGINS flag")
def test_option_passthrough(node_factory):
""" Ensure that registering options works.
Expand All @@ -35,7 +32,6 @@ def test_option_passthrough(node_factory):
n.stop()


@unittest.skipIf(not PLUGINS, "plugin subsystem requires PLUGINS flag")
def test_rpc_passthrough(node_factory):
"""Starting with a plugin exposes its RPC methods.
Expand All @@ -62,14 +58,12 @@ def test_rpc_passthrough(node_factory):
n.rpc.fail()


@unittest.skipIf(not PLUGINS, "plugin subsystem requires PLUGINS flag")
def test_plugin_dir(node_factory):
"""--plugin-dir works"""
plugin_dir = 'contrib/plugins'
node_factory.get_node(options={'plugin-dir': plugin_dir, 'greeting': 'Mars'})


@unittest.skipIf(not PLUGINS, "plugin subsystem requires PLUGINS flag")
def test_plugin_disable(node_factory):
"""--disable-plugin works"""
plugin_dir = 'contrib/plugins'
Expand All @@ -89,7 +83,6 @@ def test_plugin_disable(node_factory):
n.rpc.hello(name='Sun')


@unittest.skipIf(not PLUGINS, "plugin subsystem requires PLUGINS flag")
def test_plugin_notifications(node_factory):
l1, l2 = node_factory.get_nodes(2, opts={'plugin': 'contrib/plugins/helloworld.py'})

Expand All @@ -102,7 +95,6 @@ def test_plugin_notifications(node_factory):
l2.daemon.wait_for_log(r'Received disconnect event')


@unittest.skipIf(not PLUGINS, "plugin subsystem requires PLUGINS flag")
def test_failing_plugins():
fail_plugins = [
'contrib/plugins/fail/failtimeout.py',
Expand Down
1 change: 0 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
TIMEOUT = int(os.getenv("TIMEOUT", "60"))
VALGRIND = os.getenv("VALGRIND", config['VALGRIND']) == "1"
SLOW_MACHINE = os.getenv("SLOW_MACHINE", "0") == "1"
PLUGINS = os.getenv("PLUGINS", config['PLUGINS']) == "1"


def wait_for(success, timeout=TIMEOUT):
Expand Down

0 comments on commit 61420bf

Please sign in to comment.