diff options
-rw-r--r-- | .travis.yml | 3 | ||||
-rw-r--r-- | include/modules.h | 23 | ||||
-rwxr-xr-x | make/calcdep.pl | 55 | ||||
-rw-r--r-- | make/template/main.mk | 11 | ||||
-rwxr-xr-x | make/unit-cc.pl | 36 | ||||
-rw-r--r-- | src/coremods/core_info/cmd_modules.cpp | 4 | ||||
-rw-r--r-- | src/modmanager_static.cpp | 148 | ||||
-rw-r--r-- | src/modulemanager.cpp (renamed from src/modmanager_dynamic.cpp) | 4 | ||||
-rwxr-xr-x | tools/test-build | 16 |
9 files changed, 7 insertions, 293 deletions
diff --git a/.travis.yml b/.travis.yml index f5c1fff54..204c5c086 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,6 @@ compiler: - clang - gcc dist: trusty -env: - - TEST_BUILD_DYNAMIC=1 - - TEST_BUILD_STATIC=1 language: cpp notifications: email: false diff --git a/include/modules.h b/include/modules.h index 0cdb73873..44cda7d19 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1198,27 +1198,6 @@ class CoreExport ModuleManager : public fakederef<ModuleManager> #define MODULE_INIT_SYM_FN_2(x,y) MODULE_INIT_SYM_FN_1(x,y) #define MODULE_INIT_SYM_FN_1(x,y) inspircd_module_ ## x ## _ ## y -#ifdef INSPIRCD_STATIC - -struct AllCommandList { - typedef Command* (*fn)(Module*); - AllCommandList(fn cmd); -}; -#define COMMAND_INIT(x) static Command* MK_ ## x(Module* m) { return new x(m); } \ - static const AllCommandList PREP_ ## x(&MK_ ## x); - -struct AllModuleList { - typedef Module* (*fn)(); - fn init; - std::string name; - AllModuleList(fn mod, const std::string& Name); -}; - -#define MODULE_INIT(x) static Module* MK_ ## x() { return new x; } \ - static const AllModuleList PREP_ ## x(&MK_ ## x, MODNAME ".so"); - -#else - /** This definition is used as shorthand for the various classes * and functions needed to make a module loadable by the OS. * It defines the class factory and external init_module function. @@ -1231,5 +1210,3 @@ struct AllModuleList { extern "C" DllExport const char inspircd_src_version[] = INSPIRCD_VERSION; #define COMMAND_INIT(c) MODULE_INIT(CommandModule<c>) - -#endif diff --git a/make/calcdep.pl b/make/calcdep.pl index f3ed04725..5dc0f6878 100755 --- a/make/calcdep.pl +++ b/make/calcdep.pl @@ -59,11 +59,7 @@ sub run() { open MAKE, '>real.mk' or die "Could not write real.mk: $!"; chdir "${\SOURCEPATH}/src"; - if ($ENV{INSPIRCD_STATIC}) { - run_static(); - } else { - run_dynamic(); - } + run_dynamic(); close MAKE; } @@ -133,56 +129,11 @@ modules: $mods END } -sub run_static() { - print MAKE <<END; -# DO NOT EDIT THIS FILE -# It is autogenerated by make/calcdep.pl, and will be overwritten -# every time you rerun make in the main directory -VPATH = \$(SOURCEPATH)/src - -bad-target: - \@echo "This Makefile must be run by a sub-make from the source" - \@echo "in order to set the correct environment variables" - \@exit 1 - -all: inspircd - -END - my(@deps, @srcs); - for my $file (<*.cpp>, <socketengines/*.cpp>, <coremods/*.cpp>, <coremods/core_*/*.cpp>, - <modules/*.cpp>, <modules/m_*/*.cpp>, "threadengines/threadengine_pthread.cpp") { - my $out = find_output $file, 1; - if ($out =~ m#obj/([^/]+)/[^/]+.o$#) { - mkdir "${\BUILDPATH}/obj/$1"; - } - dep_cpp $file, $out, 'gen-o'; - next if $file =~ m#^socketengines/# && $file ne "socketengines/socketengine_$ENV{SOCKETENGINE}.cpp"; - push @deps, $out; - push @srcs, $file; - } - - my $core_mk = join ' ', @deps; - my $core_src = join ' ', @srcs; - print MAKE <<END; - -obj/ld-extra.cmd: $core_src - \@\$(SOURCEPATH)/make/unit-cc.pl gen-ld \$\@ \$^ \$> - -bin/inspircd: $core_mk obj/ld-extra.cmd - \@\$(SOURCEPATH)/make/unit-cc.pl static-ld \$\@ \$^ \$> - -inspircd: bin/inspircd - -.PHONY: all bad-target inspircd - -END -} - sub find_output { - my($file, $static) = @_; + my $file = shift; my($path,$base) = $file =~ m#^((?:.*/)?)([^/]+)\.cpp# or die "Bad file $file"; if ($path eq 'modules/' || $path eq 'coremods/') { - return $static ? "obj/$base.o" : "modules/$base.so"; + return "modules/$base.so"; } elsif ($path eq '' || $path eq 'modes/' || $path =~ /^[a-z]+engines\/$/) { return "obj/$base.o"; } elsif ($path =~ m#modules/(m_.*)/# || $path =~ m#coremods/(core_.*)/#) { diff --git a/make/template/main.mk b/make/template/main.mk index 447d64b3b..071e5da73 100644 --- a/make/template/main.mk +++ b/make/template/main.mk @@ -120,10 +120,6 @@ ifndef INSPIRCD_VERBOSE MAKEFLAGS += --silent endif -ifdef INSPIRCD_STATIC - CORECXXFLAGS += -DINSPIRCD_STATIC -endif - # Append any flags set in the environment after the base flags so # that they can be overridden if necessary. CORECXXFLAGS += $(CPPFLAGS) $(CXXFLAGS) @@ -134,7 +130,6 @@ export BUILDPATH export CORECXXFLAGS export CORELDFLAGS export CXX -export INSPIRCD_STATIC export INSPIRCD_VERBOSE export LDLIBS export PICLDFLAGS @@ -178,10 +173,6 @@ debug-header: @echo "*************************************" mod-header: -ifdef INSPIRCD_STATIC - @echo 'Cannot build specific targets in pure-static build' - @exit 1 -endif @echo 'Building specific targets:' mod-footer: target @@ -227,9 +218,7 @@ install: target @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MODPATH) @-$(INSTALL) -d -m $(INSTMODE_DIR) $(SCRPATH) [ "$(BUILDPATH)/bin/" -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH) -ifndef INSPIRCD_STATIC [ "$(BUILDPATH)/modules/" -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) "$(BUILDPATH)/modules/"*.so $(MODPATH) -endif -$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(SCRPATH) 2>/dev/null -$(INSTALL) -m $(INSTMODE_LIB) .gdbargs $(SCRPATH)/.gdbargs 2>/dev/null ifeq ($(SYSTEM), darwin) diff --git a/make/unit-cc.pl b/make/unit-cc.pl index 1cf6cf866..311c4c260 100755 --- a/make/unit-cc.pl +++ b/make/unit-cc.pl @@ -37,11 +37,7 @@ chdir $ENV{BUILDPATH}; my $type = shift; my $out = shift; -if ($type eq 'gen-ld') { - do_static_find(@ARGV); -} elsif ($type eq 'static-ld') { - do_static_link(@ARGV); -} elsif ($type eq 'core-ld') { +if ($type eq 'core-ld') { do_core_link(@ARGV); } elsif ($type eq 'link-dir') { do_link_dir(@ARGV); @@ -71,36 +67,6 @@ sub rpath($) { return $message; } -sub do_static_find { - my @flags; - for my $file (@ARGV) { - push @flags, rpath(get_directive($file, 'LinkerFlags', '')); - } - open F, '>', $out; - print F join ' ', @flags; - close F; - exit 0; -} - -sub do_static_link { - my $execstr = "$ENV{CXX} -o $out $ENV{CORELDFLAGS}"; - my $link_flags = ''; - for (@ARGV) { - if (/\.cmd$/) { - open F, '<', $_; - my $libs = <F>; - chomp $libs; - $link_flags .= ' '.$libs; - close F; - } else { - $execstr .= ' '.$_; - } - } - $execstr .= ' '.$ENV{LDLIBS}.' '.$link_flags; - message 'LINK', $out, $execstr; - exec $execstr; -} - sub do_core_link { my $execstr = "$ENV{CXX} -o $out $ENV{CORELDFLAGS} @_ $ENV{LDLIBS}"; message 'LINK', $out, $execstr; diff --git a/src/coremods/core_info/cmd_modules.cpp b/src/coremods/core_info/cmd_modules.cpp index 952b6bca2..7212e9525 100644 --- a/src/coremods/core_info/cmd_modules.cpp +++ b/src/coremods/core_info/cmd_modules.cpp @@ -71,12 +71,8 @@ CmdResult CommandModules::Handle(User* user, const Params& parameters) if (!(V.Flags & mult)) flags[pos] = '-'; -#ifdef INSPIRCD_STATIC - user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, INSPIRCD_VERSION, flags, V.description); -#else std::string srcrev = m->ModuleDLLManager->GetVersion(); user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, srcrev.empty() ? "*" : srcrev, flags, V.description); -#endif } else { diff --git a/src/modmanager_static.cpp b/src/modmanager_static.cpp deleted file mode 100644 index 4de111b63..000000000 --- a/src/modmanager_static.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * InspIRCd -- Internet Relay Chat Daemon - * - * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org> - * - * This file is part of InspIRCd. InspIRCd is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - - -#define MODNAME "core_all" - -#include "inspircd.h" -#include "exitcodes.h" -#include <iostream> - -#ifdef INSPIRCD_STATIC - -typedef std::map<std::string, AllModuleList*> modmap; -static std::vector<AllCommandList::fn>* cmdlist = NULL; -static modmap* modlist = NULL; - -AllCommandList::AllCommandList(fn cmd) -{ - if (!cmdlist) - cmdlist = new std::vector<AllCommandList::fn>(); - cmdlist->push_back(cmd); -} - -AllModuleList::AllModuleList(AllModuleList::fn mod, const std::string& Name) : init(mod), name(Name) -{ - if (!modlist) - modlist = new modmap(); - modlist->insert(std::make_pair(Name, this)); -} - -class AllModule : public Module -{ - std::vector<Command*> cmds; - public: - AllModule() - { - if (!cmdlist) - return; - try - { - cmds.reserve(cmdlist->size()); - for(std::vector<AllCommandList::fn>::iterator i = cmdlist->begin(); i != cmdlist->end(); ++i) - { - Command* c = (*i)(this); - cmds.push_back(c); - } - } - catch (...) - { - this->AllModule::~AllModule(); - throw; - } - } - - ~AllModule() - { - stdalgo::delete_all(cmds); - } - - Version GetVersion() CXX11_OVERRIDE - { - return Version("All commands", VF_VENDOR|VF_CORE); - } -}; - -MODULE_INIT(AllModule) - -bool ModuleManager::Load(const std::string& inputname, bool defer) -{ - const std::string name = ExpandModName(inputname); - modmap::iterator it = modlist->find(name); - if (it == modlist->end()) - return false; - Module* mod = NULL; - - ServiceList newservices; - if (!defer) - this->NewServices = &newservices; - - try - { - mod = (*it->second->init)(); - mod->ModuleSourceFile = name; - mod->ModuleDLLManager = NULL; - mod->dying = false; - Modules[name] = mod; - this->NewServices = NULL; - if (defer) - { - ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "New module introduced: %s", name.c_str()); - return true; - } - else - { - ConfigStatus confstatus; - - AttachAll(mod); - AddServices(newservices); - mod->init(); - mod->ReadConfig(confstatus); - } - } - catch (CoreException& modexcept) - { - this->NewServices = NULL; - - if (mod) - DoSafeUnload(mod); - ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Unable to load " + name + ": " + modexcept.GetReason()); - return false; - } - - FOREACH_MOD(OnLoadModule, (mod)); - PrioritizeHooks(); - ServerInstance->ISupport.Build(); - return true; -} - -void ModuleManager::LoadCoreModules(std::map<std::string, ServiceList>& servicemap) -{ - for (modmap::const_iterator i = modlist->begin(); i != modlist->end(); ++i) - { - const std::string modname = i->first; - if (InspIRCd::Match(modname, "core_*.so", ascii_case_insensitive_map)) - { - this->NewServices = &servicemap[modname]; - Load(modname, true); - } - } - this->NewServices = NULL; -} - -#endif diff --git a/src/modmanager_dynamic.cpp b/src/modulemanager.cpp index 644d2140f..eb40c5971 100644 --- a/src/modmanager_dynamic.cpp +++ b/src/modulemanager.cpp @@ -25,8 +25,6 @@ #include <dirent.h> #endif -#ifndef INSPIRCD_STATIC - bool ModuleManager::Load(const std::string& modname, bool defer) { /* Don't allow people to specify paths for modules, it doesn't work as expected */ @@ -157,5 +155,3 @@ void ModuleManager::LoadCoreModules(std::map<std::string, ServiceList>& servicem std::cout << std::endl; } } - -#endif diff --git a/tools/test-build b/tools/test-build index c74dbb4e0..647289569 100755 --- a/tools/test-build +++ b/tools/test-build @@ -58,19 +58,9 @@ foreach my $compiler (@compilers) { say "Failed to configure using the $compiler compiler and the $socketengine socket engine!"; exit 1; } - if (!defined $ENV{TEST_BUILD_DYNAMIC}) { - $ENV{INSPIRCD_STATIC} = 1; - if (system 'make', '--jobs', get_cpu_count, 'install') { - say "Failed to compile with static modules using the $compiler compiler and the $socketengine socket engine!"; - exit 1; - } - } - if (!defined $ENV{TEST_BUILD_STATIC}) { - delete $ENV{INSPIRCD_STATIC}; - if (system 'make', '--jobs', get_cpu_count, 'install') { - say "Failed to compile with dynamic modules using the $compiler compiler and the $socketengine socket engine!"; - exit 1; - } + if (system 'make', '--jobs', get_cpu_count, 'install') { + say "Failed to compile using the $compiler compiler and the $socketengine socket engine!"; + exit 1; } say "Building using the $compiler compiler and the $socketengine socket engine succeeded!"; } |