From 62240b34a076033bd8cb9cf979f3492b4c0cc5e5 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 28 Dec 2022 15:17:14 +0200 Subject: [PATCH] Convert the simpler toolchains into plugins These have no references to them from the main library and were the easiest to convert. --- .gitignore | 6 +++--- Build | 39 ++++++++++++++++------------------- plugins/clang/clangplugin.cpp | 14 +++++++++++++ plugins/clang/clangplugin.h | 14 +++++++++++++ plugins/gnu/gnuplugin.cpp | 14 +++++++++++++ plugins/gnu/gnuplugin.h | 14 +++++++++++++ plugins/msvc/msvcplugin.cpp | 16 ++++++++++++++ plugins/msvc/msvcplugin.h | 14 +++++++++++++ source/lib/builder.cpp | 7 ------- 9 files changed, 107 insertions(+), 31 deletions(-) create mode 100644 plugins/clang/clangplugin.cpp create mode 100644 plugins/clang/clangplugin.h create mode 100644 plugins/gnu/gnuplugin.cpp create mode 100644 plugins/gnu/gnuplugin.h create mode 100644 plugins/msvc/msvcplugin.cpp create mode 100644 plugins/msvc/msvcplugin.h diff --git a/.gitignore b/.gitignore index e45ec7e..6bfc7f6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,12 +2,12 @@ /builder /builder.pc /builder-stage1 +/clangtools.dlm +/gnutools.dlm /libbuilder.a /libbuilder.so /libandroidtools.a /libbuiltintools.a -/libclangtools.a /libdatatools.a -/libgnutools.a -/libmsvctools.a +/msvctools.dlm /temp diff --git a/Build b/Build index 6f93cb0..794c3f3 100644 --- a/Build +++ b/Build @@ -19,24 +19,6 @@ package "builder" default false; }; - library "gnutools" - { - source "plugins/gnu"; - default false; - }; - - library "clangtools" - { - source "plugins/clang"; - default false; - }; - - library "msvctools" - { - source "plugins/msvc"; - default false; - }; - library "androidtools" { source "plugins/android"; @@ -53,9 +35,6 @@ package "builder" { source "source/lib"; use "builtintools"; - use "gnutools"; - use "clangtools"; - use "msvctools"; use "androidtools"; use "datatools"; build_info @@ -84,6 +63,24 @@ package "builder" install true; }; + module "gnutools" + { + source "plugins/gnu"; + install true; + }; + + module "clangtools" + { + source "plugins/clang"; + install true; + }; + + module "msvctools" + { + source "plugins/msvc"; + install true; + }; + source_archive { source "bootstrap.sh"; diff --git a/plugins/clang/clangplugin.cpp b/plugins/clang/clangplugin.cpp new file mode 100644 index 0000000..a6b3bbb --- /dev/null +++ b/plugins/clang/clangplugin.cpp @@ -0,0 +1,14 @@ +#include "clangplugin.h" +#include "clangtools.h" + +void ClangPlugin::add_tools(Toolchain &toolchain, const Architecture &arch) const +{ + toolchain.add_toolchain(new ClangTools(builder, arch)); +} + + +extern "C" +Plugin *create_plugin(Builder &builder) +{ + return new ClangPlugin(builder); +} diff --git a/plugins/clang/clangplugin.h b/plugins/clang/clangplugin.h new file mode 100644 index 0000000..678d7b5 --- /dev/null +++ b/plugins/clang/clangplugin.h @@ -0,0 +1,14 @@ +#ifndef CLANGPLUGIN_H_ +#define CLANGPLUGIN_H_ + +#include + +class ClangPlugin: public Plugin +{ +public: + ClangPlugin(Builder &b): Plugin(b) { } + + void add_tools(Toolchain &, const Architecture &) const override; +}; + +#endif diff --git a/plugins/gnu/gnuplugin.cpp b/plugins/gnu/gnuplugin.cpp new file mode 100644 index 0000000..a758b9a --- /dev/null +++ b/plugins/gnu/gnuplugin.cpp @@ -0,0 +1,14 @@ +#include "gnuplugin.h" +#include "gnutools.h" + +void GnuPlugin::add_tools(Toolchain &toolchain, const Architecture &arch) const +{ + toolchain.add_toolchain(new GnuTools(builder, arch)); +} + + +extern "C" +Plugin *create_plugin(Builder &builder) +{ + return new GnuPlugin(builder); +} diff --git a/plugins/gnu/gnuplugin.h b/plugins/gnu/gnuplugin.h new file mode 100644 index 0000000..80d520d --- /dev/null +++ b/plugins/gnu/gnuplugin.h @@ -0,0 +1,14 @@ +#ifndef GNUPLUGIN_H_ +#define GNUPLUGIN_H_ + +#include + +class GnuPlugin: public Plugin +{ +public: + GnuPlugin(Builder &b): Plugin(b) { } + + void add_tools(Toolchain &, const Architecture &) const override; +}; + +#endif diff --git a/plugins/msvc/msvcplugin.cpp b/plugins/msvc/msvcplugin.cpp new file mode 100644 index 0000000..1a4fe7b --- /dev/null +++ b/plugins/msvc/msvcplugin.cpp @@ -0,0 +1,16 @@ +#include +#include "microsofttools.h" +#include "msvcplugin.h" + +void MsvcPlugin::add_tools(Toolchain &toolchain, const Architecture &arch) const +{ + if(arch.get_system()=="windows") + toolchain.add_toolchain(new MicrosoftTools(builder, arch)); +} + + +extern "C" +Plugin *create_plugin(Builder &builder) +{ + return new MsvcPlugin(builder); +} diff --git a/plugins/msvc/msvcplugin.h b/plugins/msvc/msvcplugin.h new file mode 100644 index 0000000..78190d3 --- /dev/null +++ b/plugins/msvc/msvcplugin.h @@ -0,0 +1,14 @@ +#ifndef MSVCPLUGIN_H_ +#define MSVCPLUGIN_H_ + +#include + +class MsvcPlugin: public Plugin +{ +public: + MsvcPlugin(Builder &b): Plugin(b) { } + + void add_tools(Toolchain &, const Architecture &) const override; +}; + +#endif diff --git a/source/lib/builder.cpp b/source/lib/builder.cpp index 72ee524..77d0872 100644 --- a/source/lib/builder.cpp +++ b/source/lib/builder.cpp @@ -16,11 +16,8 @@ #include "binarypackage.h" #include "builder.h" #include "builtin/builtintools.h" -#include "clang/clangtools.h" #include "datafile/datatool.h" -#include "gnu/gnutools.h" #include "installedfile.h" -#include "msvc/microsofttools.h" #include "package.h" #include "plugin.h" #include "sharedlibrary.h" @@ -146,12 +143,8 @@ void Builder::update_auto_prefix() void Builder::add_default_tools() { - toolchain.add_toolchain(new GnuTools(*this, *current_arch)); - toolchain.add_toolchain(new ClangTools(*this, *current_arch)); if(current_arch->get_system()=="android") toolchain.add_toolchain(new AndroidTools(*this, *current_arch)); - if(current_arch->get_system()=="windows") - toolchain.add_toolchain(new MicrosoftTools(*this, *current_arch)); toolchain.add_toolchain(new BuiltinTools(*this)); toolchain.add_tool(new DataTool(*this)); for(const LoadedPlugin &p: plugins) -- 2.45.2