diff --git a/.github/workflows/termuxpkg.yml b/.github/workflows/termuxpkg.yml new file mode 100644 index 00000000..f46915e8 --- /dev/null +++ b/.github/workflows/termuxpkg.yml @@ -0,0 +1,94 @@ +on: + push: + branches: + - master + pull_request: +name: Build Irssi Termux package +jobs: + termux-package: + runs-on: ubuntu-latest + steps: + - name: checkout termux-packages + uses: actions/checkout@main + with: + repository: termux/termux-packages + - name: checkout irssi + uses: actions/checkout@main + with: + path: src.irssi.git + - name: download termux docker container + uses: docker://termux/package-builder:latest + - name: build perl package + run: | + ./scripts/run-docker.sh ./build-package.sh -i perl + - name: create irssi build receipe + run: | + mkdir packages/irssi-an + cat << 'BUILD_SH' > packages/irssi-an/build.sh + TERMUX_PKG_HOMEPAGE=https://ailin-nemui.github.io/irssi/ + TERMUX_PKG_DESCRIPTION="Terminal based IRC client" + TERMUX_PKG_LICENSE="GPL-2.0" + TERMUX_PKG_MAINTAINER="@ailin-nemui" + TERMUX_PKG_VERSION=@VERSION@ + TERMUX_PKG_REVISION=@REVISION@ + TERMUX_PKG_SRCURL=file:///home/builder/termux-packages/src.irssi.git + TERMUX_PKG_AUTO_UPDATE=true + TERMUX_PKG_DEPENDS="glib, libandroid-glob, libiconv, libotr, ncurses, openssl, perl, utf8proc" + TERMUX_PKG_BREAKS="irssi" + TERMUX_PKG_REPLACES="irssi" + TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" + -Denable-true-color=yes + -Dfhs-prefix=$TERMUX_PREFIX + " + + termux_step_configure_meson() { + termux_setup_meson + + local perl_version=$(. $TERMUX_SCRIPTDIR/packages/perl/build.sh; echo $TERMUX_PKG_VERSION) + local perl_srcdir=$TERMUX_TOPDIR/perl/src + + sed -i "/\\[binaries\\]/a\\ + perl = ['$perl_srcdir/miniperl', '-I$TERMUX_PREFIX/lib/perl5/$perl_version/${TERMUX_ARCH}-android', '-I$TERMUX_PREFIX/lib/perl5/$perl_version']" \ + $TERMUX_MESON_CROSSFILE + + CC=gcc CXX=g++ CFLAGS= CXXFLAGS= CPPFLAGS= LDFLAGS= $TERMUX_MESON \ + $TERMUX_PKG_SRCDIR \ + $TERMUX_PKG_BUILDDIR \ + --cross-file $TERMUX_MESON_CROSSFILE \ + --prefix $TERMUX_PREFIX \ + --libdir lib \ + --buildtype minsize \ + --strip \ + $TERMUX_PKG_EXTRA_CONFIGURE_ARGS + } + + termux_step_post_configure() { + sed -i "s:-I$TERMUX_PREFIX/:-isystem$TERMUX_PREFIX/:g" $TERMUX_PKG_BUILDDIR/build.ninja + } + + + termux_step_pre_configure() { + LDFLAGS+=" -landroid-glob" + + # Make build log less noisy. + CFLAGS+=" -Wno-compound-token-split-by-macro" + + # Make sure that perl stuff is reinstalled. + rm -rf $TERMUX_PREFIX/lib/irssi/perl + } + + BUILD_SH + version=$(awk '/^v/ { $0=$1; gsub(/^v/,""); gsub(/-head/,"dev"); gsub(/-/,""); print; exit }' src.irssi.git/NEWS) + version=$version+g$(git -C src.irssi.git rev-parse --short HEAD) + sed -i \ + -e "s:@VERSION@:$version:" \ + -e "s:@REVISION@:$GITHUB_RUN_NUMBER:" \ + packages/irssi-an/build.sh + git -C src.irssi.git tag v$version + - name: build irssi package + run: | + ./scripts/run-docker.sh ./build-package.sh -I irssi-an + - uses: actions/upload-artifact@v2 + with: + name: irssi-termux-pkg + path: output/irssi-an*.deb diff --git a/src/common.h b/src/common.h index 7f8604f3..ad5c88bb 100644 --- a/src/common.h +++ b/src/common.h @@ -6,7 +6,7 @@ #define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */ #define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */ -#define IRSSI_ABI_VERSION 44 +#define IRSSI_ABI_VERSION 45 #define DEFAULT_SERVER_ADD_PORT 6667 #define DEFAULT_SERVER_ADD_TLS_PORT 6697 diff --git a/src/core/channels-setup.c b/src/core/channels-setup.c index c72f057c..5e2930ad 100644 --- a/src/core/channels-setup.c +++ b/src/core/channels-setup.c @@ -227,8 +227,7 @@ void channels_setup_init(void) setupchannels = NULL; source_host_ok = FALSE; - signal_add("setup reread", (SIGNAL_FUNC) channels_read_config); - signal_add("irssi init read settings", (SIGNAL_FUNC) channels_read_config); + signal_add("setup reread channels", (SIGNAL_FUNC) channels_read_config); } void channels_setup_deinit(void) @@ -236,6 +235,5 @@ void channels_setup_deinit(void) while (setupchannels != NULL) channel_setup_destroy(setupchannels->data); - signal_remove("setup reread", (SIGNAL_FUNC) channels_read_config); - signal_remove("irssi init read settings", (SIGNAL_FUNC) channels_read_config); + signal_remove("setup reread channels", (SIGNAL_FUNC) channels_read_config); } diff --git a/src/core/chat-protocols.c b/src/core/chat-protocols.c index c53b01b3..1a6ecbb3 100644 --- a/src/core/chat-protocols.c +++ b/src/core/chat-protocols.c @@ -47,7 +47,7 @@ int chat_protocol_lookup(const char *name) g_return_val_if_fail(name != NULL, -1); rec = chat_protocol_find(name); - return rec == NULL ? -1 : rec->id; + return rec == NULL ? -1 : rec->not_initialized ? CHAT_PROTOCOL_NOT_INITIALIZED : rec->id; } CHAT_PROTOCOL_REC *chat_protocol_find(const char *name) @@ -99,6 +99,22 @@ CHAT_PROTOCOL_REC *chat_protocol_find_net(GHashTable *optlist) return NULL; } +static void chat_protocol_destroy(CHAT_PROTOCOL_REC *rec) +{ + g_return_if_fail(rec != NULL); + + chat_protocols = g_slist_remove(chat_protocols, rec); + + if (default_proto == rec) { + chat_protocol_set_default(chat_protocols == NULL ? NULL : chat_protocols->data); + } + + signal_emit("chat protocol destroyed", 1, rec); + + g_free(rec->name); + g_free(rec); +} + /* Register new chat protocol. */ CHAT_PROTOCOL_REC *chat_protocol_register(CHAT_PROTOCOL_REC *rec) { @@ -108,7 +124,11 @@ CHAT_PROTOCOL_REC *chat_protocol_register(CHAT_PROTOCOL_REC *rec) g_return_val_if_fail(rec != NULL, NULL); newrec = chat_protocol_find(rec->name); - created = newrec == NULL; + if (newrec != NULL && newrec->not_initialized) { + chat_protocol_destroy(newrec); + newrec = NULL; + } + created = newrec == NULL; if (newrec == NULL) { newrec = g_new0(CHAT_PROTOCOL_REC, 1); chat_protocols = g_slist_append(chat_protocols, newrec); @@ -131,23 +151,6 @@ CHAT_PROTOCOL_REC *chat_protocol_register(CHAT_PROTOCOL_REC *rec) return newrec; } -static void chat_protocol_destroy(CHAT_PROTOCOL_REC *rec) -{ - g_return_if_fail(rec != NULL); - - chat_protocols = g_slist_remove(chat_protocols, rec); - - if (default_proto == rec) { - chat_protocol_set_default(chat_protocols == NULL ? NULL : - chat_protocols->data); - } - - signal_emit("chat protocol destroyed", 1, rec); - - g_free(rec->name); - g_free(rec); -} - /* Unregister chat protocol. */ void chat_protocol_unregister(const char *name) { @@ -191,15 +194,6 @@ static CHANNEL_SETUP_REC *create_channel_setup(void) return g_new0(CHANNEL_SETUP_REC, 1); } -static SERVER_CONNECT_REC *create_server_connect(void) -{ - return g_new0(SERVER_CONNECT_REC, 1); -} - -static void destroy_server_connect(SERVER_CONNECT_REC *conn) -{ -} - /* Return "unknown chat protocol" record. Used when protocol name is specified but it isn't registered yet. */ CHAT_PROTOCOL_REC *chat_protocol_get_unknown(const char *name) @@ -218,8 +212,10 @@ CHAT_PROTOCOL_REC *chat_protocol_get_unknown(const char *name) rec->create_chatnet = create_chatnet; rec->create_server_setup = create_server_setup; rec->create_channel_setup = create_channel_setup; + /* rec->create_server_connect = create_server_connect; rec->destroy_server_connect = destroy_server_connect; + */ newrec = chat_protocol_register(rec); g_free(rec); diff --git a/src/core/chat-protocols.h b/src/core/chat-protocols.h index ab7327bd..2a51c8c4 100644 --- a/src/core/chat-protocols.h +++ b/src/core/chat-protocols.h @@ -35,6 +35,8 @@ void *chat_protocol_check_cast(void *object, int type_pos, const char *id); ((object) == NULL ? chat_protocol_get_default() : \ chat_protocol_find_id((object)->chat_type)) +#define CHAT_PROTOCOL_NOT_INITIALIZED -2 + /* Register new chat protocol. */ CHAT_PROTOCOL_REC *chat_protocol_register(CHAT_PROTOCOL_REC *rec); diff --git a/src/core/chatnets.c b/src/core/chatnets.c index 2d49a6df..770c7595 100644 --- a/src/core/chatnets.c +++ b/src/core/chatnets.c @@ -24,12 +24,13 @@ #include #include #include +#include #include #include #include -GSList *chatnets; /* list of available chat networks */ +GSList *chatnets, *chatnets_unavailable; /* list of available chat networks */ static void chatnet_config_save(CHATNET_REC *chatnet) { @@ -60,8 +61,9 @@ static void chatnet_config_remove(CHATNET_REC *chatnet) void chatnet_create(CHATNET_REC *chatnet) { g_return_if_fail(chatnet != NULL); + g_return_if_fail(!CHAT_PROTOCOL(chatnet)->not_initialized); - chatnet->type = module_get_uniq_id("CHATNET", 0); + chatnet->type = module_get_uniq_id("CHATNET", 0); if (g_slist_find(chatnets, chatnet) == NULL) chatnets = g_slist_append(chatnets, chatnet); @@ -112,6 +114,21 @@ CHATNET_REC *chatnet_find(const char *name) return NULL; } +gboolean chatnet_find_unavailable(const char *name) +{ + CHAT_PROTOCOL_REC *proto; + + if (i_slist_find_icase_string(chatnets_unavailable, name) != NULL) + return TRUE; + + proto = CHAT_PROTOCOL(chatnet_find(name)); + + if (proto == NULL || proto->not_initialized) + return TRUE; + + return FALSE; +} + static void sig_connected(SERVER_REC *server) { CHATNET_REC *rec; @@ -136,14 +153,22 @@ static void chatnet_read(CONFIG_NODE *node) return; type = config_node_get_str(node, "type", NULL); - proto = type == NULL ? NULL : chat_protocol_find(type); - if (proto == NULL) { - proto = type == NULL ? chat_protocol_get_default() : - chat_protocol_get_unknown(type); + if (type == NULL) { + proto = chat_protocol_get_default(); + } else { + proto = chat_protocol_find(type); } - if (type == NULL) + if (proto == NULL) { + /* protocol not loaded */ + if (i_slist_find_icase_string(chatnets_unavailable, node->key) == NULL) + chatnets_unavailable = + g_slist_append(chatnets_unavailable, g_strdup(node->key)); + + return; + } else if (type == NULL) { iconfig_node_set_str(node, "type", proto->name); + } rec = proto->create_chatnet(); rec->type = module_get_uniq_id("CHATNET", 0); @@ -167,6 +192,12 @@ static void read_chatnets(void) while (chatnets != NULL) chatnet_destroy(chatnets->data); + while (chatnets_unavailable != NULL) { + char *name = chatnets_unavailable->data; + chatnets_unavailable = g_slist_remove(chatnets_unavailable, name); + g_free(name); + } + node = iconfig_node_traverse("chatnets", FALSE); if (node != NULL) { tmp = config_node_first(node->value); @@ -180,8 +211,7 @@ void chatnets_init(void) chatnets = NULL; signal_add_first("event connected", (SIGNAL_FUNC) sig_connected); - signal_add("setup reread", (SIGNAL_FUNC) read_chatnets); - signal_add_first("irssi init read settings", (SIGNAL_FUNC) read_chatnets); + signal_add("setup reread chatnets", (SIGNAL_FUNC) read_chatnets); } void chatnets_deinit(void) @@ -189,6 +219,5 @@ void chatnets_deinit(void) module_uniq_destroy("CHATNET"); signal_remove("event connected", (SIGNAL_FUNC) sig_connected); - signal_remove("setup reread", (SIGNAL_FUNC) read_chatnets); - signal_remove("irssi init read settings", (SIGNAL_FUNC) read_chatnets); + signal_remove("setup reread chatnets", (SIGNAL_FUNC) read_chatnets); } diff --git a/src/core/chatnets.h b/src/core/chatnets.h index 6f36fe33..accdd0ad 100644 --- a/src/core/chatnets.h +++ b/src/core/chatnets.h @@ -25,6 +25,8 @@ void chatnet_destroy(CHATNET_REC *chatnet); /* Find the chat network by name */ CHATNET_REC *chatnet_find(const char *name); +/* Check if this chatnet is unavailable because the protocol is not loaded */ +gboolean chatnet_find_unavailable(const char *name); void chatnets_init(void); void chatnets_deinit(void); diff --git a/src/core/core.c b/src/core/core.c index cbe3eb7c..e9af84f7 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -223,6 +223,13 @@ static void sig_irssi_init_finished(void) irssi_init_finished = TRUE; } +static void reread_setup(void) +{ + signal_emit("setup reread chatnets", 0); + signal_emit("setup reread servers", 0); + signal_emit("setup reread channels", 0); +} + void core_init(void) { dialog_type_queue = NULL; @@ -269,13 +276,16 @@ void core_init(void) settings_add_str("misc", "ignore_signals", ""); settings_add_bool("misc", "override_coredump_limit", FALSE); settings_add_bool("misc", "quit_on_hup", FALSE); - settings_add_str("misc", "autoload_modules", "perl otr"); + settings_add_str("misc", "autoload_modules", "irc dcc flood notifylist perl otr"); #ifdef HAVE_SYS_RESOURCE_H getrlimit(RLIMIT_CORE, &orig_core_rlimit); #endif read_settings(); signal_add("setup changed", (SIGNAL_FUNC) read_settings); + signal_add("setup reread", (SIGNAL_FUNC) reread_setup); + signal_add("irssi init read settings", (SIGNAL_FUNC) reread_setup); + signal_add_last("chat protocol created", (SIGNAL_FUNC) reread_setup); signal_add("irssi init finished", (SIGNAL_FUNC) sig_irssi_init_finished); settings_check(); @@ -288,6 +298,9 @@ void core_deinit(void) module_uniq_destroy("WINDOW ITEM TYPE"); signal_remove("setup changed", (SIGNAL_FUNC) read_settings); + signal_remove("setup reread", (SIGNAL_FUNC) reread_setup); + signal_remove("irssi init read settings", (SIGNAL_FUNC) reread_setup); + signal_remove("chat protocol created", (SIGNAL_FUNC) reread_setup); signal_remove("irssi init finished", (SIGNAL_FUNC) sig_irssi_init_finished); wcwidth_wrapper_deinit(); diff --git a/src/core/servers-setup.c b/src/core/servers-setup.c index 82e5f6be..5fbad79e 100644 --- a/src/core/servers-setup.c +++ b/src/core/servers-setup.c @@ -305,6 +305,8 @@ static SERVER_CONNECT_REC *create_addr_conn(int chat_type, const char *address, proto = chat_type >= 0 ? chat_protocol_find_id(chat_type) : chat_protocol_get_default(); + g_return_val_if_fail(proto != NULL, NULL); + conn = proto->create_server_connect(); server_connect_ref(conn); @@ -469,6 +471,10 @@ static SERVER_SETUP_REC *server_setup_read(CONFIG_NODE *node) chatnetrec = chatnet == NULL ? NULL : chatnet_find(chatnet); if (chatnetrec == NULL && chatnet != NULL) { /* chat network not found, create it. */ + if (chatnet_find_unavailable(chatnet)) { + /* no protocols loaded, skip loading servers */ + return NULL; + } chatnetrec = chat_protocol_get_default()->create_chatnet(); chatnetrec->chat_type = chat_protocol_get_default()->id; chatnetrec->name = g_strdup(chatnet); @@ -759,8 +765,7 @@ void servers_setup_init(void) read_settings(); signal_add("setup changed", (SIGNAL_FUNC) read_settings); - signal_add("setup reread", (SIGNAL_FUNC) read_servers); - signal_add("irssi init read settings", (SIGNAL_FUNC) read_servers); + signal_add("setup reread servers", (SIGNAL_FUNC) read_servers); } void servers_setup_deinit(void) @@ -773,8 +778,7 @@ void servers_setup_deinit(void) server_setup_destroy(setupservers->data); signal_remove("setup changed", (SIGNAL_FUNC) read_settings); - signal_remove("setup reread", (SIGNAL_FUNC) read_servers); - signal_remove("irssi init read settings", (SIGNAL_FUNC) read_servers); + signal_remove("setup reread servers", (SIGNAL_FUNC) read_servers); module_uniq_destroy("SERVER SETUP"); } diff --git a/src/fe-common/irc/dcc/meson.build b/src/fe-common/irc/dcc/meson.build index 296b1d61..50806e81 100644 --- a/src/fe-common/irc/dcc/meson.build +++ b/src/fe-common/irc/dcc/meson.build @@ -17,6 +17,11 @@ libfe_irc_dcc_a = static_library('fe_irc_dcc', def_sysconfdir, ], dependencies : dep) +shared_module('fe_irc_dcc', + install : true, + install_dir : moduledir, + link_with : dl_cross_irc_dcc, + link_whole : libfe_irc_dcc_a) install_headers( files( diff --git a/src/fe-common/irc/fe-common-irc.c b/src/fe-common/irc/fe-common-irc.c index a36d3caa..4658970b 100644 --- a/src/fe-common/irc/fe-common-irc.c +++ b/src/fe-common/irc/fe-common-irc.c @@ -30,8 +30,10 @@ #include #include +#ifdef HAVE_STATIC_IRC void fe_irc_modules_init(void); void fe_irc_modules_deinit(void); +#endif void fe_irc_queries_init(void); void fe_irc_queries_deinit(void); @@ -104,12 +106,16 @@ void fe_common_irc_init(void) settings_check(); module_register("irc", "fe-common"); +#ifdef HAVE_STATIC_IRC fe_irc_modules_init(); +#endif } void fe_common_irc_deinit(void) { +#ifdef HAVE_STATIC_IRC fe_irc_modules_deinit(); +#endif fe_irc_channels_deinit(); fe_irc_queries_deinit(); diff --git a/src/fe-common/irc/irc-modules.c b/src/fe-common/irc/irc-modules.c index 3bf1f327..b8c17d3b 100644 --- a/src/fe-common/irc/irc-modules.c +++ b/src/fe-common/irc/irc-modules.c @@ -1,4 +1,6 @@ +#ifdef HAVE_STATIC_IRC void fe_irc_dcc_init(void);void fe_irc_notifylist_init(void); void fe_irc_notifylist_deinit(void);void fe_irc_dcc_deinit(void); void fe_irc_modules_init(void) { fe_irc_dcc_init(); fe_irc_notifylist_init(); } void fe_irc_modules_deinit(void) { fe_irc_notifylist_deinit(); fe_irc_dcc_deinit(); } +#endif diff --git a/src/fe-common/irc/meson.build b/src/fe-common/irc/meson.build index 1789133c..aff70f71 100644 --- a/src/fe-common/irc/meson.build +++ b/src/fe-common/irc/meson.build @@ -30,6 +30,11 @@ libfe_common_irc_a = static_library('fe_common_irc', def_themesdir, ], dependencies : dep) +shared_module('fe_common_irc', + install : true, + install_dir : moduledir, + link_with : dl_cross_irc_core, + link_whole : libfe_common_irc_a) install_headers( files( diff --git a/src/fe-common/irc/notifylist/meson.build b/src/fe-common/irc/notifylist/meson.build index 2e66c786..1d42e147 100644 --- a/src/fe-common/irc/notifylist/meson.build +++ b/src/fe-common/irc/notifylist/meson.build @@ -12,6 +12,11 @@ libfe_irc_notifylist_a = static_library('fe_irc_notifylist', def_sysconfdir, ], dependencies : dep) +shared_module('fe_irc_notifylist', + install : true, + install_dir : moduledir, + link_with : dl_cross_irc_notifylist, + link_whole : libfe_irc_notifylist_a) install_headers( files( diff --git a/src/fe-fuzz/irc/core/meson.build b/src/fe-fuzz/irc/core/meson.build index 6a47e07d..730c9240 100644 --- a/src/fe-fuzz/irc/core/meson.build +++ b/src/fe-fuzz/irc/core/meson.build @@ -9,7 +9,7 @@ executable('event-get-params-fuzz', link_with : [ libconfig_a, libcore_a, - libirc_a, + libirc_core_a, libfuzzer_fe_common_core_a, ], link_args : [fuzzer_lib], diff --git a/src/fe-fuzz/meson.build b/src/fe-fuzz/meson.build index 7fac025d..5ab19651 100644 --- a/src/fe-fuzz/meson.build +++ b/src/fe-fuzz/meson.build @@ -32,7 +32,7 @@ executable('server-fuzz', libconfig_a, libcore_a, libfuzzer_fe_common_core_a, - libirc_a, + libirc_core_a, libfe_common_irc_a, libfe_irc_dcc_a, libfe_irc_notifylist_a, diff --git a/src/fe-fuzz/server.c b/src/fe-fuzz/server.c index b74a29b9..c91a5bcd 100644 --- a/src/fe-fuzz/server.c +++ b/src/fe-fuzz/server.c @@ -43,9 +43,9 @@ #include #include -/* irc.c */ -void irc_init(void); -void irc_deinit(void); +/* irc-core.c */ +void irc_core_init(void); +void irc_core_deinit(void); /* irc-session.c */ void irc_session_init(void); @@ -153,7 +153,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) { core_preinit((*argv)[0]); core_init(); irssi_ssl_init(); - irc_init(); + irc_core_init(); fe_common_core_init(); fe_common_irc_init(); signal_add("event 001", (SIGNAL_FUNC) event_connected); diff --git a/src/fe-none/irssi.c b/src/fe-none/irssi.c index 6a02ff6a..b33a4c5c 100644 --- a/src/fe-none/irssi.c +++ b/src/fe-none/irssi.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #ifdef HAVE_STATIC_PERL @@ -30,8 +31,10 @@ void perl_core_init(void); void perl_core_deinit(void); #endif +#ifdef HAVE_STATIC_IRC void irc_init(void); void irc_deinit(void); +#endif static GMainLoop *main_loop; static char *autoload_module; @@ -47,13 +50,32 @@ static void sig_reload(void) reload = TRUE; } +static void autoload_modules(void) +{ + char **list, **module; + list = g_strsplit_set(settings_get_str("autoload_modules"), " ,", -1); + for (module = list; *module != NULL; module++) { + char *tmp; + if ((tmp = strchr(*module, ':')) != NULL) { + *tmp = '\0'; + tmp++; + module_load_sub(*module, tmp, NULL); + } else { + module_load(*module, NULL); + } + } + g_strfreev(list); +} + void noui_init(void) { srand(time(NULL)); irssi_gui = IRSSI_GUI_NONE; core_init(); +#ifdef HAVE_STATIC_IRC irc_init(); +#endif module_register("core", "fe-none"); @@ -64,6 +86,8 @@ void noui_init(void) perl_core_init(); #endif + autoload_modules(); + signal_emit("irssi init finished", 0); } @@ -75,7 +99,9 @@ void noui_deinit(void) signal_remove("reload", (SIGNAL_FUNC) sig_reload); signal_remove("gui exit", (SIGNAL_FUNC) sig_exit); +#ifdef HAVE_STATIC_IRC irc_deinit(); +#endif core_deinit(); } diff --git a/src/fe-none/meson.build b/src/fe-none/meson.build index 58df15f6..8f6b797d 100644 --- a/src/fe-none/meson.build +++ b/src/fe-none/meson.build @@ -10,7 +10,6 @@ executable('botti', link_with : [ libconfig_a, libcore_a, - libirc_a, ], install : true, dependencies : dep diff --git a/src/fe-text/irssi.c b/src/fe-text/irssi.c index fbaa303a..34341c9b 100644 --- a/src/fe-text/irssi.c +++ b/src/fe-text/irssi.c @@ -59,11 +59,13 @@ void otr_core_init(void); void otr_core_deinit(void); #endif +#ifdef HAVE_STATIC_IRC void irc_init(void); void irc_deinit(void); void fe_common_irc_init(void); void fe_common_irc_deinit(void); +#endif void gui_expandos_init(void); void gui_expandos_deinit(void); @@ -168,9 +170,13 @@ static void textui_init(void) irssi_gui = IRSSI_GUI_TEXT; core_init(); +#ifdef HAVE_STATIC_IRC irc_init(); +#endif fe_common_core_init(); +#ifdef HAVE_STATIC_IRC fe_common_irc_init(); +#endif theme_register(gui_text_formats); signal_add("settings userinfo changed", (SIGNAL_FUNC) sig_settings_userinfo_changed); @@ -301,9 +307,13 @@ static void textui_deinit(void) theme_unregister(); +#ifdef HAVE_STATIC_IRC fe_common_irc_deinit(); +#endif fe_common_core_deinit(); +#ifdef HAVE_STATIC_IRC irc_deinit(); +#endif core_deinit(); } diff --git a/src/fe-text/meson.build b/src/fe-text/meson.build index 4da98809..24a86ca3 100644 --- a/src/fe-text/meson.build +++ b/src/fe-text/meson.build @@ -35,10 +35,6 @@ executable('irssi', libconfig_a, libcore_a, libfe_common_core_a, - libirc_a, - libfe_common_irc_a, - libfe_irc_dcc_a, - libfe_irc_notifylist_a, ], install : true, install_rpath : get_option('prefix') / get_option('libdir'), diff --git a/src/irc/core/irc-core.c b/src/irc/core/irc-core.c index d1a0f72e..725ae28a 100644 --- a/src/irc/core/irc-core.c +++ b/src/irc/core/irc-core.c @@ -106,9 +106,6 @@ void irc_core_init(void) (QUERY_REC *(*) (const char *, const char *, int)) irc_query_create; - chat_protocol_register(rec); - g_free(rec); - irc_session_init(); irc_chatnets_init(); irc_servers_init(); @@ -125,6 +122,10 @@ void irc_core_init(void) sasl_init(); settings_check(); + + chat_protocol_register(rec); + g_free(rec); + module_register("irc", "core"); } diff --git a/src/irc/core/meson.build b/src/irc/core/meson.build index e6cc89c7..b8c1bad9 100644 --- a/src/irc/core/meson.build +++ b/src/irc/core/meson.build @@ -38,6 +38,15 @@ libirc_core_a = static_library('irc_core', def_sysconfdir, ], dependencies : dep) +libirc_core_sm = shared_module('irc_core', + install : true, + install_dir : moduledir, + link_whole : libirc_core_a) + +dl_cross_irc_core = [] +if need_dl_cross_link + dl_cross_irc_core += libirc_core_sm +endif install_headers( files( diff --git a/src/irc/dcc/meson.build b/src/irc/dcc/meson.build index 0c3d706a..9c7e33d5 100644 --- a/src/irc/dcc/meson.build +++ b/src/irc/dcc/meson.build @@ -1,6 +1,6 @@ # this file is part of irssi -libirc_dcc_a = static_library('irc_dcc', +libirc_dcc_sm = shared_module('irc_dcc', files( 'dcc-autoget.c', 'dcc-chat.c', @@ -13,8 +13,16 @@ libirc_dcc_a = static_library('irc_dcc', ), include_directories : rootinc, implicit_include_directories : false, + install : true, + install_dir : moduledir, + link_with : dl_cross_irc_core, dependencies : dep) +dl_cross_irc_dcc = [] +if need_dl_cross_link + dl_cross_irc_dcc += libirc_dcc_sm +endif + install_headers( files( 'dcc-chat.h', diff --git a/src/irc/flood/meson.build b/src/irc/flood/meson.build index 75107db1..3c763beb 100644 --- a/src/irc/flood/meson.build +++ b/src/irc/flood/meson.build @@ -8,6 +8,11 @@ libirc_flood_a = static_library('irc_flood', include_directories : rootinc, implicit_include_directories : false, dependencies : dep) +shared_module('irc_flood', + install : true, + install_dir : moduledir, + link_with : dl_cross_irc_core, + link_whole : libirc_flood_a) install_headers( files('module.h'), diff --git a/src/irc/irc.c b/src/irc/irc.c index 250a6fb4..5780a965 100644 --- a/src/irc/irc.c +++ b/src/irc/irc.c @@ -1,5 +1,7 @@ +#ifdef HAVE_STATIC_IRC void irc_core_init(void); void irc_core_deinit(void); void irc_dcc_init(void);void irc_flood_init(void);void irc_notifylist_init(void); void irc_notifylist_deinit(void);void irc_flood_deinit(void);void irc_dcc_deinit(void); void irc_init(void) { irc_core_init(); irc_dcc_init(); irc_flood_init(); irc_notifylist_init(); } void irc_deinit(void) { irc_notifylist_deinit(); irc_flood_deinit(); irc_dcc_deinit(); irc_core_deinit(); } +#endif diff --git a/src/irc/meson.build b/src/irc/meson.build index 72abc3ce..13bfc493 100644 --- a/src/irc/meson.build +++ b/src/irc/meson.build @@ -5,20 +5,6 @@ subdir('dcc') subdir('flood') subdir('notifylist') -libirc_a = static_library('irc', - files( - 'irc.c', - ), - link_with : [ - libirc_core_a, - libirc_dcc_a, - libirc_flood_a, - libirc_notifylist_a, - ], - include_directories : rootinc, - implicit_include_directories : false, -) - if want_proxy subdir('proxy') endif diff --git a/src/irc/notifylist/meson.build b/src/irc/notifylist/meson.build index f00ea321..ab664d16 100644 --- a/src/irc/notifylist/meson.build +++ b/src/irc/notifylist/meson.build @@ -1,6 +1,6 @@ # this file is part of irssi -libirc_notifylist_a = static_library('irc_notifylist', +libirc_notifylist_sm = shared_module('irc_notifylist', files( 'notify-commands.c', 'notify-ison.c', @@ -10,8 +10,16 @@ libirc_notifylist_a = static_library('irc_notifylist', ), include_directories : rootinc, implicit_include_directories : false, + install : true, + install_dir : moduledir, + link_with : dl_cross_irc_core, dependencies : dep) +dl_cross_irc_notifylist = [] +if need_dl_cross_link + dl_cross_irc_notifylist += libirc_notifylist_sm +endif + install_headers( files( 'module.h', diff --git a/src/perl/common/meson.build b/src/perl/common/meson.build index f2a69bc9..d3c98a88 100644 --- a/src/perl/common/meson.build +++ b/src/perl/common/meson.build @@ -1,5 +1,5 @@ -libperl_Irssi_a = shared_module('Irssi', +shared_module('Irssi', [ xsubpp.process( files( 'Channel.xs', diff --git a/src/perl/irc/meson.build b/src/perl/irc/meson.build index 0a8fd9f9..b65856ff 100644 --- a/src/perl/irc/meson.build +++ b/src/perl/irc/meson.build @@ -1,4 +1,4 @@ -libperl_Irssi_Irc_a = shared_module('Irc', +shared_module('Irc', [ xsubpp.process( files( 'Channel.xs', @@ -26,7 +26,7 @@ libperl_Irssi_Irc_a = shared_module('Irc', include_directories : rootinc, implicit_include_directories : true, dependencies : dep + [ perl_dep ], - link_with : dl_cross_perl_core, + link_with : dl_cross_perl_core + dl_cross_irc_dcc + dl_cross_irc_notifylist, ) install_headers( diff --git a/src/perl/meson.build b/src/perl/meson.build index d81173d9..f685fb0d 100644 --- a/src/perl/meson.build +++ b/src/perl/meson.build @@ -17,7 +17,7 @@ irssi_core_pl_h = custom_target('irssi-core.pl.h', # required as of Meson 0.58.0 generated_files_inc = include_directories('.') -libperl_core_a = shared_module('perl_core', +libperl_core_sm = shared_module('perl_core', files( 'perl-common.c', 'perl-core.c', @@ -44,10 +44,10 @@ libperl_core_a = shared_module('perl_core', dl_cross_perl_core = [] if need_dl_cross_link - dl_cross_perl_core += libperl_core_a + dl_cross_perl_core += libperl_core_sm endif -libfe_perl_a = shared_module('fe_perl', +shared_module('fe_perl', files( 'module-formats.c', 'perl-fe.c', diff --git a/src/perl/perl-common.c b/src/perl/perl-common.c index 7eaab8eb..d9d00035 100644 --- a/src/perl/perl-common.c +++ b/src/perl/perl-common.c @@ -583,6 +583,10 @@ static void perl_register_protocol(CHAT_PROTOCOL_REC *rec) SV *sv; chat_type = chat_protocol_lookup(rec->name); + if (chat_type == CHAT_PROTOCOL_NOT_INITIALIZED) { + return; + } + g_return_if_fail(chat_type >= 0); name = g_ascii_strdown(rec->name,-1); diff --git a/src/perl/textui/meson.build b/src/perl/textui/meson.build index 1705fa36..e0b83dd3 100644 --- a/src/perl/textui/meson.build +++ b/src/perl/textui/meson.build @@ -1,4 +1,4 @@ -libperl_Irssi_TextUI_a = shared_module('TextUI', +shared_module('TextUI', [ xsubpp.process( files( 'Statusbar.xs', diff --git a/src/perl/ui/meson.build b/src/perl/ui/meson.build index 14bc7699..f9b8b41c 100644 --- a/src/perl/ui/meson.build +++ b/src/perl/ui/meson.build @@ -1,4 +1,4 @@ -libperl_Irssi_UI_a = shared_module('UI', +shared_module('UI', [ xsubpp.process( files( 'Formats.xs', diff --git a/tests/irc/flood/meson.build b/tests/irc/flood/meson.build index e9d0a2bc..78556331 100644 --- a/tests/irc/flood/meson.build +++ b/tests/irc/flood/meson.build @@ -6,7 +6,8 @@ test_test_796 = executable('test-796', libconfig_a, libcore_a, libfe_common_core_a, - libirc_a, + libirc_core_a, + libirc_flood_a, libfe_common_irc_a, libfe_irc_dcc_a, libfe_irc_notifylist_a,