summaryrefslogtreecommitdiff
path: root/image/backends
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-04-02 05:08:04 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-04-02 05:08:04 -0500
commitc6b0e5fc81d905f57688c696f80e480712f612ab (patch)
tree9b08fec4059ed05becfe85e426ff316cb7a5d381 /image/backends
parent94fc4d46c3f2ebc179b768525a4aad73a655e083 (diff)
downloadhorizon-c6b0e5fc81d905f57688c696f80e480712f612ab.tar.gz
horizon-c6b0e5fc81d905f57688c696f80e480712f612ab.tar.bz2
horizon-c6b0e5fc81d905f57688c696f80e480712f612ab.tar.xz
horizon-c6b0e5fc81d905f57688c696f80e480712f612ab.zip
image: Significantly refactor how backends are registered
Diffstat (limited to 'image/backends')
-rw-r--r--image/backends/backends.hh33
-rw-r--r--image/backends/basic.cc5
-rw-r--r--image/backends/basic.hh13
3 files changed, 17 insertions, 34 deletions
diff --git a/image/backends/backends.hh b/image/backends/backends.hh
deleted file mode 100644
index 3199ee0..0000000
--- a/image/backends/backends.hh
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * backends.hh - Horizon Image Creation backend table
- * image, the image processing utilities for
- * Project Horizon
- *
- * Copyright (c) 2020 Adélie Linux and contributors. All rights reserved.
- * This code is licensed under the AGPL 3.0 license, as noted in the
- * LICENSE-code file in the root directory of this repository.
- *
- * SPDX-License-Identifier: AGPL-3.0-only
- */
-
-#pragma once
-
-#include <functional>
-#include <string>
-#include <vector>
-
-namespace Horizon {
-namespace Image {
-
-class BasicBackend;
-
-struct BackendDescriptor {
- std::string type_code;
- std::string description;
- std::function<BasicBackend *(std::string, std::string)> creation_fn;
-};
-
-extern std::vector<BackendDescriptor> known_backends;
-
-}
-}
diff --git a/image/backends/basic.cc b/image/backends/basic.cc
index 908f1d9..dbe387c 100644
--- a/image/backends/basic.cc
+++ b/image/backends/basic.cc
@@ -11,7 +11,6 @@
*/
#include "basic.hh"
-#include "backends.hh"
namespace Horizon {
namespace Image {
@@ -21,6 +20,10 @@ std::vector<BackendDescriptor> known_backends = {
{"squashfs", "Create a SquashFS image (.squashfs)", [](std::string, std::string){ return nullptr; } }
};
+const std::vector<BackendDescriptor> BasicBackend::available_backends() {
+ return known_backends;
+}
+
int BasicBackend::prepare() {
/* The default implementation returns success immediately;
* no preparation is required. */
diff --git a/image/backends/basic.hh b/image/backends/basic.hh
index d39c57e..3181f69 100644
--- a/image/backends/basic.hh
+++ b/image/backends/basic.hh
@@ -12,11 +12,21 @@
#pragma once
+#include <functional>
#include <string>
+#include <vector>
namespace Horizon {
namespace Image {
+class BasicBackend;
+
+struct BackendDescriptor {
+ std::string type_code;
+ std::string description;
+ std::function<BasicBackend *(std::string, std::string)> creation_fn;
+};
+
class BasicBackend {
public:
/*! Create the backend object.
@@ -43,6 +53,9 @@ public:
*/
virtual int finalise();
+ /*! Returns a list of available backends. */
+ static const std::vector<BackendDescriptor> available_backends();
+
/*! The intermediate directory which contains the sysroot the image
* should contain. */
const std::string &ir_dir;