]> git.tdb.fi Git - builder.git/commitdiff
Convert the simpler toolchains into plugins
authorMikko Rasa <tdb@tdb.fi>
Wed, 28 Dec 2022 13:17:14 +0000 (15:17 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 28 Dec 2022 15:38:27 +0000 (17:38 +0200)
These have no references to them from the main library and were the
easiest to convert.

.gitignore
Build
plugins/clang/clangplugin.cpp [new file with mode: 0644]
plugins/clang/clangplugin.h [new file with mode: 0644]
plugins/gnu/gnuplugin.cpp [new file with mode: 0644]
plugins/gnu/gnuplugin.h [new file with mode: 0644]
plugins/msvc/msvcplugin.cpp [new file with mode: 0644]
plugins/msvc/msvcplugin.h [new file with mode: 0644]
source/lib/builder.cpp

index e45ec7e2d8dc9618406cae2ebe343a93bd197bb8..6bfc7f62198046d5478a22b62eb826c01dfbe2d0 100644 (file)
@@ -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 6f93cb026ca4dadcb97d8c19ffa3f587a886252b..794c3f30167577f157c399bc127d6ad86d74116b 100644 (file)
--- 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 (file)
index 0000000..a6b3bbb
--- /dev/null
@@ -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 (file)
index 0000000..678d7b5
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef CLANGPLUGIN_H_
+#define CLANGPLUGIN_H_
+
+#include <msp/builder/plugin.h>
+
+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 (file)
index 0000000..a758b9a
--- /dev/null
@@ -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 (file)
index 0000000..80d520d
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef GNUPLUGIN_H_
+#define GNUPLUGIN_H_
+
+#include <msp/builder/plugin.h>
+
+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 (file)
index 0000000..1a4fe7b
--- /dev/null
@@ -0,0 +1,16 @@
+#include <msp/builder/architecture.h>
+#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 (file)
index 0000000..78190d3
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef MSVCPLUGIN_H_
+#define MSVCPLUGIN_H_
+
+#include <msp/builder/plugin.h>
+
+class MsvcPlugin: public Plugin
+{
+public:
+       MsvcPlugin(Builder &b): Plugin(b) { }
+
+       void add_tools(Toolchain &, const Architecture &) const override;
+};
+
+#endif
index 72ee524dffe41fc22111863953d1549e5ad22a67..77d08724d3cab317fb5d6cc7bf27f0a6dd511578 100644 (file)
 #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)