]> git.tdb.fi Git - builder.git/commitdiff
Convert the remaining tools into actual plugins
authorMikko Rasa <tdb@tdb.fi>
Wed, 28 Dec 2022 15:50:27 +0000 (17:50 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 28 Dec 2022 15:50:27 +0000 (17:50 +0200)
.gitignore
Build
plugins/android/androidplugin.cpp [new file with mode: 0644]
plugins/android/androidplugin.h [new file with mode: 0644]
plugins/datafile/datafileplugin.cpp [new file with mode: 0644]
plugins/datafile/datafileplugin.h [new file with mode: 0644]
source/lib/builder.cpp
source/lib/sourcepackage.cpp

index 6d3eeaded8d5269c39df75f62c57751a706876e2..a3042aecb8fd3be41047a2e0df497e58850916ba 100644 (file)
@@ -1,13 +1,13 @@
 /.config
+/androidtools.dlm
+/basetools.dlm
 /builder
 /builder.pc
 /builder-stage1
-/basetools.dlm
 /clangtools.dlm
+/datatools.dlm
 /gnutools.dlm
 /libbuilder.a
 /libbuilder.so
-/libandroidtools.a
-/libdatatools.a
 /msvctools.dlm
 /temp
diff --git a/Build b/Build
index 61fd21a857c1f8acb957849ce7904bf6eeedd835..9f94ecbdea9593353fd48273e1420998518de13d 100644 (file)
--- a/Build
+++ b/Build
@@ -13,27 +13,9 @@ package "builder"
                standard CXX "c++11";
        };
 
-       library "androidtools"
-       {
-               source "plugins/android";
-               default false;
-       };
-
-       library "datatools"
-       {
-               source "plugins/datafile";
-               default false;
-       };
-
        library "libbuilder"
        {
                source "source/lib";
-               use "androidtools";
-               use "datatools";
-               build_info
-               {
-                       incpath "plugins";
-               };
                if_arch "windows"
                {
                        build_info
@@ -56,12 +38,24 @@ package "builder"
                install true;
        };
 
+       module "androidtools"
+       {
+               source "plugins/android";
+               install true;
+       };
+
        module "basetools"
        {
                source "plugins/base";
                install true;
        };
 
+       module "datatools"
+       {
+               source "plugins/datafile";
+               install true;
+       };
+
        module "gnutools"
        {
                source "plugins/gnu";
diff --git a/plugins/android/androidplugin.cpp b/plugins/android/androidplugin.cpp
new file mode 100644 (file)
index 0000000..609d5cd
--- /dev/null
@@ -0,0 +1,24 @@
+#include <msp/builder/architecture.h>
+#include <msp/builder/builder.h>
+#include "androidapplicationcomponent.h"
+#include "androidplugin.h"
+#include "androidtools.h"
+
+AndroidPlugin::AndroidPlugin(Builder &b):
+       Plugin(b)
+{
+       builder.get_component_registry().register_type<AndroidApplicationComponent>("android_application");
+}
+
+void AndroidPlugin::add_tools(Toolchain &toolchain, const Architecture &arch) const
+{
+       if(arch.get_system()=="android")
+               toolchain.add_toolchain(new AndroidTools(builder, arch));
+}
+
+
+extern "C"
+Plugin *create_plugin(Builder &builder)
+{
+       return new AndroidPlugin(builder);
+}
diff --git a/plugins/android/androidplugin.h b/plugins/android/androidplugin.h
new file mode 100644 (file)
index 0000000..44c7efd
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef ANDROIDPLUGIN_H_
+#define ANDROIDPLUGIN_H_
+
+#include <msp/builder/plugin.h>
+
+class AndroidPlugin: public Plugin
+{
+public:
+       AndroidPlugin(Builder &);
+
+       void add_tools(Toolchain &, const Architecture &) const override;
+};
+
+#endif
diff --git a/plugins/datafile/datafileplugin.cpp b/plugins/datafile/datafileplugin.cpp
new file mode 100644 (file)
index 0000000..a085724
--- /dev/null
@@ -0,0 +1,22 @@
+#include <msp/builder/builder.h>
+#include "datafileplugin.h"
+#include "datapackcomponent.h"
+#include "datatool.h"
+
+DataFilePlugin::DataFilePlugin(Builder &b):
+       Plugin(b)
+{
+       builder.get_component_registry().register_type<DataPackComponent>("datapack");
+}
+
+void DataFilePlugin::add_tools(Toolchain &toolchain, const Architecture &) const
+{
+       toolchain.add_tool(new DataTool(builder));
+}
+
+
+extern "C"
+Plugin *create_plugin(Builder &builder)
+{
+       return new DataFilePlugin(builder);
+}
diff --git a/plugins/datafile/datafileplugin.h b/plugins/datafile/datafileplugin.h
new file mode 100644 (file)
index 0000000..d23ffa8
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef DATAFILEPLUGIN_H_
+#define DATAFILEPLUGIN_H_
+
+#include <msp/builder/plugin.h>
+
+class DataFilePlugin: public Plugin
+{
+public:
+       DataFilePlugin(Builder &);
+
+       void add_tools(Toolchain &, const Architecture &) const override;
+};
+
+#endif
index 1535c3e948bf3a1cd7042649347bd3feb8b5d81f..9cf6266af8fef3d03db31b9d6d81e33310220bfc 100644 (file)
 #include <msp/strings/format.h>
 #include <msp/time/timedelta.h>
 #include <msp/time/utils.h>
-#include "android/androidtools.h"
 #include "binarypackage.h"
 #include "builder.h"
-#include "datafile/datatool.h"
 #include "installedfile.h"
 #include "package.h"
 #include "plugin.h"
 #include "sharedlibrary.h"
 #include "task.h"
+#include "tool.h"
 #include "virtualtarget.h"
 
 using namespace std;
@@ -141,9 +140,6 @@ void Builder::update_auto_prefix()
 
 void Builder::add_default_tools()
 {
-       if(current_arch->get_system()=="android")
-               toolchain.add_toolchain(new AndroidTools(*this, *current_arch));
-       toolchain.add_tool(new DataTool(*this));
        for(const LoadedPlugin &p: plugins)
                p.plugin->add_tools(toolchain, *current_arch);
 
index 6261d2c844ba42fbdb283bf5e56ed8a4ec88cef1..1af2aa693e148831c09f72e327c349f82c0129af 100644 (file)
@@ -5,11 +5,9 @@
 #include <msp/io/print.h>
 #include <msp/strings/lexicalcast.h>
 #include <msp/strings/utils.h>
-#include "android/androidapplicationcomponent.h"
 #include "binarycomponent.h"
 #include "binarypackage.h"
 #include "builder.h"
-#include "datafile/datapackcomponent.h"
 #include "file.h"
 #include "installcomponent.h"
 #include "plugin.h"
@@ -155,9 +153,7 @@ SourcePackage::Loader::Loader(SourcePackage &p, const Config::InputOptions *o):
        FeatureConditional(p, p.name),
        options(o)
 {
-       add("android_application", &Loader::component<AndroidApplicationComponent>);
        add("build_info",  &Loader::build_info);
-       add("datapack",    &Loader::component<DataPackComponent>);
        add("description", &SourcePackage::description);
        add("feature",     &Loader::feature);
        add("generate",    &Loader::generate);