From 767e28373e9710720efabc0f4f9bb3e51661c1e6 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 28 Dec 2022 17:50:27 +0200 Subject: [PATCH] Convert the remaining tools into actual plugins --- .gitignore | 6 +++--- Build | 30 ++++++++++++----------------- plugins/android/androidplugin.cpp | 24 +++++++++++++++++++++++ plugins/android/androidplugin.h | 14 ++++++++++++++ plugins/datafile/datafileplugin.cpp | 22 +++++++++++++++++++++ plugins/datafile/datafileplugin.h | 14 ++++++++++++++ source/lib/builder.cpp | 6 +----- source/lib/sourcepackage.cpp | 4 ---- 8 files changed, 90 insertions(+), 30 deletions(-) create mode 100644 plugins/android/androidplugin.cpp create mode 100644 plugins/android/androidplugin.h create mode 100644 plugins/datafile/datafileplugin.cpp create mode 100644 plugins/datafile/datafileplugin.h diff --git a/.gitignore b/.gitignore index 6d3eead..a3042ae 100644 --- a/.gitignore +++ b/.gitignore @@ -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 61fd21a..9f94ecb 100644 --- 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 index 0000000..609d5cd --- /dev/null +++ b/plugins/android/androidplugin.cpp @@ -0,0 +1,24 @@ +#include +#include +#include "androidapplicationcomponent.h" +#include "androidplugin.h" +#include "androidtools.h" + +AndroidPlugin::AndroidPlugin(Builder &b): + Plugin(b) +{ + builder.get_component_registry().register_type("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 index 0000000..44c7efd --- /dev/null +++ b/plugins/android/androidplugin.h @@ -0,0 +1,14 @@ +#ifndef ANDROIDPLUGIN_H_ +#define ANDROIDPLUGIN_H_ + +#include + +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 index 0000000..a085724 --- /dev/null +++ b/plugins/datafile/datafileplugin.cpp @@ -0,0 +1,22 @@ +#include +#include "datafileplugin.h" +#include "datapackcomponent.h" +#include "datatool.h" + +DataFilePlugin::DataFilePlugin(Builder &b): + Plugin(b) +{ + builder.get_component_registry().register_type("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 index 0000000..d23ffa8 --- /dev/null +++ b/plugins/datafile/datafileplugin.h @@ -0,0 +1,14 @@ +#ifndef DATAFILEPLUGIN_H_ +#define DATAFILEPLUGIN_H_ + +#include + +class DataFilePlugin: public Plugin +{ +public: + DataFilePlugin(Builder &); + + void add_tools(Toolchain &, const Architecture &) const override; +}; + +#endif diff --git a/source/lib/builder.cpp b/source/lib/builder.cpp index 1535c3e..9cf6266 100644 --- a/source/lib/builder.cpp +++ b/source/lib/builder.cpp @@ -12,15 +12,14 @@ #include #include #include -#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); diff --git a/source/lib/sourcepackage.cpp b/source/lib/sourcepackage.cpp index 6261d2c..1af2aa6 100644 --- a/source/lib/sourcepackage.cpp +++ b/source/lib/sourcepackage.cpp @@ -5,11 +5,9 @@ #include #include #include -#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); add("build_info", &Loader::build_info); - add("datapack", &Loader::component); add("description", &SourcePackage::description); add("feature", &Loader::feature); add("generate", &Loader::generate); -- 2.45.2