Browse Source

configure: (mostly) revert b7a56f0531

Plugins are a first-class citizen again.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
plugin-timeout-inc
Rusty Russell 6 years ago
parent
commit
61420bf79b
  1. 8
      configure
  2. 2
      doc/PLUGINS.md
  3. 14
      lightningd/lightningd.c
  4. 3
      lightningd/lightningd.h
  5. 3
      lightningd/options.c
  6. 1
      tests/fixtures.py
  7. 8
      tests/test_plugin.py
  8. 1
      tests/utils.py

8
configure

@ -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}
@ -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
@ -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;;
@ -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"

2
doc/PLUGINS.md

@ -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

14
lightningd/lightningd.c

@ -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;
}
@ -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));
@ -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;
}
@ -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);
@ -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

3
lightningd/lightningd.h

@ -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);

3
lightningd/options.c

@ -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,
@ -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,

1
tests/fixtures.py

@ -17,6 +17,7 @@ VALGRIND = os.getenv("VALGRIND", config['VALGRIND']) == "1"
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)

8
tests/test_plugin.py

@ -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.
@ -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.
@ -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'
@ -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'})
@ -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',

1
tests/utils.py

@ -41,7 +41,6 @@ EXPERIMENTAL_FEATURES = os.getenv("EXPERIMENTAL_FEATURES", config['EXPERIMENTAL_
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):

Loading…
Cancel
Save