mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
configure: (mostly) revert b7a56f0531
Plugins are a first-class citizen again. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
8
configure
vendored
8
configure
vendored
@@ -10,7 +10,6 @@ CWARNFLAGS=${CWARNFLAGS:--Werror -Wall -Wundef -Wmissing-prototypes -Wmissing-de
|
|||||||
CDEBUGFLAGS=${CDEBUGFLAGS:--std=gnu11 -g -fstack-protector}
|
CDEBUGFLAGS=${CDEBUGFLAGS:--std=gnu11 -g -fstack-protector}
|
||||||
DEVELOPER=${DEVELOPER:-0}
|
DEVELOPER=${DEVELOPER:-0}
|
||||||
EXPERIMENTAL_FEATURES=${EXPERIMENTAL_FEATURES:-0}
|
EXPERIMENTAL_FEATURES=${EXPERIMENTAL_FEATURES:-0}
|
||||||
PLUGINS=${PLUGINS:-0}
|
|
||||||
COMPAT=${COMPAT:-1}
|
COMPAT=${COMPAT:-1}
|
||||||
STATIC=${STATIC:-0}
|
STATIC=${STATIC:-0}
|
||||||
CONFIGURATOR_CC=${CONFIGURATOR_CC:-$CC}
|
CONFIGURATOR_CC=${CONFIGURATOR_CC:-$CC}
|
||||||
@@ -56,10 +55,6 @@ usage()
|
|||||||
echo " Compatibility mode, good to disable to see if your software breaks"
|
echo " Compatibility mode, good to disable to see if your software breaks"
|
||||||
usage_with_default "--enable/disable-valgrind" "(autodetect)"
|
usage_with_default "--enable/disable-valgrind" "(autodetect)"
|
||||||
echo " Valgrind binary to use for tests"
|
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"
|
usage_with_default "--enable/disable-static" "$STATIC" "enable" "disable"
|
||||||
echo " Static link binary"
|
echo " Static link binary"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -118,8 +113,6 @@ for opt in "$@"; do
|
|||||||
--disable-developer) DEVELOPER=0;;
|
--disable-developer) DEVELOPER=0;;
|
||||||
--enable-experimental-features) EXPERIMENTAL_FEATURES=1;;
|
--enable-experimental-features) EXPERIMENTAL_FEATURES=1;;
|
||||||
--disable-experimental-features) EXPERIMENTAL_FEATURES=0;;
|
--disable-experimental-features) EXPERIMENTAL_FEATURES=0;;
|
||||||
--enable-plugins) PLUGINS=1;;
|
|
||||||
--disable-plugins) PLUGINS=0;;
|
|
||||||
--enable-compat) COMPAT=1;;
|
--enable-compat) COMPAT=1;;
|
||||||
--disable-compat) COMPAT=0;;
|
--disable-compat) COMPAT=0;;
|
||||||
--enable-valgrind) VALGRIND=1;;
|
--enable-valgrind) VALGRIND=1;;
|
||||||
@@ -158,7 +151,6 @@ add_var CDEBUGFLAGS "$CDEBUGFLAGS"
|
|||||||
add_var VALGRIND "$VALGRIND"
|
add_var VALGRIND "$VALGRIND"
|
||||||
add_var DEVELOPER "$DEVELOPER" $CONFIG_HEADER
|
add_var DEVELOPER "$DEVELOPER" $CONFIG_HEADER
|
||||||
add_var EXPERIMENTAL_FEATURES "$EXPERIMENTAL_FEATURES" $CONFIG_HEADER
|
add_var EXPERIMENTAL_FEATURES "$EXPERIMENTAL_FEATURES" $CONFIG_HEADER
|
||||||
add_var PLUGINS "$PLUGINS" $CONFIG_HEADER
|
|
||||||
add_var COMPAT "$COMPAT" $CONFIG_HEADER
|
add_var COMPAT "$COMPAT" $CONFIG_HEADER
|
||||||
add_var PYTEST "$PYTEST"
|
add_var PYTEST "$PYTEST"
|
||||||
add_var STATIC "$STATIC"
|
add_var STATIC "$STATIC"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ variety of ways:
|
|||||||
internal events in `lightningd` and alter its behavior or inject
|
internal events in `lightningd` and alter its behavior or inject
|
||||||
custom behaviors.
|
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
|
A plugin may be written in any language, and communicates with
|
||||||
`lightningd` through the plugin's `stdin` and `stdout`. JSON-RPCv2 is
|
`lightningd` through the plugin's `stdin` and `stdout`. JSON-RPCv2 is
|
||||||
|
|||||||
@@ -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
|
*code. Here we initialize the context that will keep track and control
|
||||||
*the plugins.
|
*the plugins.
|
||||||
*/
|
*/
|
||||||
#ifdef PLUGINS
|
|
||||||
ld->plugins = plugins_new(ld, ld->log_book, ld->jsonrpc, ld);
|
ld->plugins = plugins_new(ld, ld->log_book, ld->jsonrpc, ld);
|
||||||
#endif
|
|
||||||
return ld;
|
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
|
/*~ The plugin dir is in ../libexec/c-lightning/plugins, which (unlike
|
||||||
* those given on the command line) does not need to exist. */
|
* those given on the command line) does not need to exist. */
|
||||||
#ifdef PLUGINS
|
|
||||||
add_plugin_dir(ld->plugins,
|
add_plugin_dir(ld->plugins,
|
||||||
path_join(tmpctx, pkglibexecdir, "plugins"),
|
path_join(tmpctx, pkglibexecdir, "plugins"),
|
||||||
true);
|
true);
|
||||||
#endif
|
|
||||||
/*~ Sometimes take() can be more efficient, since the routine can
|
/*~ Sometimes take() can be more efficient, since the routine can
|
||||||
* manipulate the string in place. This is the case here. */
|
* manipulate the string in place. This is the case here. */
|
||||||
return path_simplify(ld, take(pkglibexecdir));
|
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 we're running in-tree, all the subdaemons are with lightningd. */
|
||||||
if (has_all_subdaemons(my_path)) {
|
if (has_all_subdaemons(my_path)) {
|
||||||
/* In this case, look in ../plugins */
|
/* In this case, look in ../plugins */
|
||||||
#ifdef PLUGINS
|
|
||||||
add_plugin_dir(ld->plugins,
|
add_plugin_dir(ld->plugins,
|
||||||
path_join(tmpctx, my_path, "../plugins"),
|
path_join(tmpctx, my_path, "../plugins"),
|
||||||
true);
|
true);
|
||||||
#endif
|
|
||||||
return my_path;
|
return my_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,9 +661,8 @@ int main(int argc, char *argv[])
|
|||||||
/*~ Initialize all the plugins we just registered, so they can
|
/*~ Initialize all the plugins we just registered, so they can
|
||||||
* do their thing and tell us about themselves (including
|
* do their thing and tell us about themselves (including
|
||||||
* options registration). */
|
* options registration). */
|
||||||
#ifdef PLUGINS
|
|
||||||
plugins_init(ld->plugins, ld->dev_debug_subprocess);
|
plugins_init(ld->plugins, ld->dev_debug_subprocess);
|
||||||
#endif
|
|
||||||
/*~ Handle options and config; move to .lightningd (--lightning-dir) */
|
/*~ Handle options and config; move to .lightningd (--lightning-dir) */
|
||||||
handle_opts(ld, argc, argv);
|
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
|
/*~ Now that the rpc path exists, we can start the plugins and they
|
||||||
* can start talking to us. */
|
* can start talking to us. */
|
||||||
#ifdef PLUGINS
|
|
||||||
plugins_config(ld->plugins);
|
plugins_config(ld->plugins);
|
||||||
#endif
|
|
||||||
/*~ We defer --daemon until we've completed most initialization: that
|
/*~ We defer --daemon until we've completed most initialization: that
|
||||||
* way we'll exit with an error rather than silently exiting 0, then
|
* 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
|
* realizing we can't start and forcing the confused user to read the
|
||||||
|
|||||||
@@ -205,9 +205,8 @@ struct lightningd {
|
|||||||
bool use_proxy_always;
|
bool use_proxy_always;
|
||||||
char *tor_service_password;
|
char *tor_service_password;
|
||||||
bool pure_tor_setup;
|
bool pure_tor_setup;
|
||||||
#ifdef PLUGINS
|
|
||||||
struct plugins *plugins;
|
struct plugins *plugins;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const struct chainparams *get_chainparams(const struct lightningd *ld);
|
const struct chainparams *get_chainparams(const struct lightningd *ld);
|
||||||
|
|||||||
@@ -318,7 +318,6 @@ static void config_register_opts(struct lightningd *ld)
|
|||||||
&ld->config_filename,
|
&ld->config_filename,
|
||||||
"Specify configuration file. Relative paths will be prefixed by lightning-dir location. (default: config)");
|
"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
|
/* Register plugins as an early args, so we can initialize them and have
|
||||||
* them register more command line options */
|
* them register more command line options */
|
||||||
opt_register_early_arg("--plugin", opt_add_plugin, NULL, ld,
|
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,
|
opt_register_early_arg("--disable-plugin", opt_disable_plugin,
|
||||||
NULL, ld,
|
NULL, ld,
|
||||||
"Disable a particular plugin by filename/name");
|
"Disable a particular plugin by filename/name");
|
||||||
#endif
|
|
||||||
opt_register_noarg("--daemon", opt_set_bool, &ld->daemon,
|
opt_register_noarg("--daemon", opt_set_bool, &ld->daemon,
|
||||||
"Run in the background, suppress stdout/stderr");
|
"Run in the background, suppress stdout/stderr");
|
||||||
opt_register_arg("--ignore-fee-limits", opt_set_bool_arg, opt_show_bool,
|
opt_register_arg("--ignore-fee-limits", opt_set_bool_arg, opt_show_bool,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ VALGRIND = os.getenv("VALGRIND", config['VALGRIND']) == "1"
|
|||||||
DEVELOPER = os.getenv("DEVELOPER", config['DEVELOPER']) == "1"
|
DEVELOPER = os.getenv("DEVELOPER", config['DEVELOPER']) == "1"
|
||||||
TEST_DEBUG = os.getenv("TEST_DEBUG", "0") == "1"
|
TEST_DEBUG = os.getenv("TEST_DEBUG", "0") == "1"
|
||||||
|
|
||||||
|
|
||||||
if TEST_DEBUG:
|
if TEST_DEBUG:
|
||||||
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
|
logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from fixtures import * # noqa: F401,F403
|
from fixtures import * # noqa: F401,F403
|
||||||
from lightning import RpcError
|
from lightning import RpcError
|
||||||
from utils import PLUGINS
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import subprocess
|
import subprocess
|
||||||
import unittest
|
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(not PLUGINS, "plugin subsystem requires PLUGINS flag")
|
|
||||||
def test_option_passthrough(node_factory):
|
def test_option_passthrough(node_factory):
|
||||||
""" Ensure that registering options works.
|
""" Ensure that registering options works.
|
||||||
|
|
||||||
@@ -35,7 +32,6 @@ def test_option_passthrough(node_factory):
|
|||||||
n.stop()
|
n.stop()
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(not PLUGINS, "plugin subsystem requires PLUGINS flag")
|
|
||||||
def test_rpc_passthrough(node_factory):
|
def test_rpc_passthrough(node_factory):
|
||||||
"""Starting with a plugin exposes its RPC methods.
|
"""Starting with a plugin exposes its RPC methods.
|
||||||
|
|
||||||
@@ -62,14 +58,12 @@ def test_rpc_passthrough(node_factory):
|
|||||||
n.rpc.fail()
|
n.rpc.fail()
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(not PLUGINS, "plugin subsystem requires PLUGINS flag")
|
|
||||||
def test_plugin_dir(node_factory):
|
def test_plugin_dir(node_factory):
|
||||||
"""--plugin-dir works"""
|
"""--plugin-dir works"""
|
||||||
plugin_dir = 'contrib/plugins'
|
plugin_dir = 'contrib/plugins'
|
||||||
node_factory.get_node(options={'plugin-dir': plugin_dir, 'greeting': 'Mars'})
|
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):
|
def test_plugin_disable(node_factory):
|
||||||
"""--disable-plugin works"""
|
"""--disable-plugin works"""
|
||||||
plugin_dir = 'contrib/plugins'
|
plugin_dir = 'contrib/plugins'
|
||||||
@@ -89,7 +83,6 @@ def test_plugin_disable(node_factory):
|
|||||||
n.rpc.hello(name='Sun')
|
n.rpc.hello(name='Sun')
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(not PLUGINS, "plugin subsystem requires PLUGINS flag")
|
|
||||||
def test_plugin_notifications(node_factory):
|
def test_plugin_notifications(node_factory):
|
||||||
l1, l2 = node_factory.get_nodes(2, opts={'plugin': 'contrib/plugins/helloworld.py'})
|
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')
|
l2.daemon.wait_for_log(r'Received disconnect event')
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(not PLUGINS, "plugin subsystem requires PLUGINS flag")
|
|
||||||
def test_failing_plugins():
|
def test_failing_plugins():
|
||||||
fail_plugins = [
|
fail_plugins = [
|
||||||
'contrib/plugins/fail/failtimeout.py',
|
'contrib/plugins/fail/failtimeout.py',
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ EXPERIMENTAL_FEATURES = os.getenv("EXPERIMENTAL_FEATURES", config['EXPERIMENTAL_
|
|||||||
TIMEOUT = int(os.getenv("TIMEOUT", "60"))
|
TIMEOUT = int(os.getenv("TIMEOUT", "60"))
|
||||||
VALGRIND = os.getenv("VALGRIND", config['VALGRIND']) == "1"
|
VALGRIND = os.getenv("VALGRIND", config['VALGRIND']) == "1"
|
||||||
SLOW_MACHINE = os.getenv("SLOW_MACHINE", "0") == "1"
|
SLOW_MACHINE = os.getenv("SLOW_MACHINE", "0") == "1"
|
||||||
PLUGINS = os.getenv("PLUGINS", config['PLUGINS']) == "1"
|
|
||||||
|
|
||||||
|
|
||||||
def wait_for(success, timeout=TIMEOUT):
|
def wait_for(success, timeout=TIMEOUT):
|
||||||
|
|||||||
Reference in New Issue
Block a user