[keel] Make most of pack build regardless of platform
This commit is contained in:
parent
04cb710d56
commit
6680ffa7a8
@ -2,12 +2,9 @@
|
|||||||
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
* Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OX_BARE_METAL
|
|
||||||
|
|
||||||
#include <ox/claw/read.hpp>
|
|
||||||
#include <ox/fs/fs.hpp>
|
#include <ox/fs/fs.hpp>
|
||||||
#include <ox/model/descwrite.hpp>
|
|
||||||
#include <ox/model/modelvalue.hpp>
|
#include <ox/model/modelvalue.hpp>
|
||||||
|
#include <ox/std/utility.hpp>
|
||||||
|
|
||||||
#include <keel/media.hpp>
|
#include <keel/media.hpp>
|
||||||
|
|
||||||
@ -15,7 +12,8 @@
|
|||||||
|
|
||||||
namespace keel {
|
namespace keel {
|
||||||
|
|
||||||
static ox::Error pathToInode(keel::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept {
|
static ox::Error pathToInode(
|
||||||
|
[[maybe_unused]] keel::Context *ctx, ox::FileSystem *dest, ox::ModelObject *obj) noexcept {
|
||||||
auto &o = *obj;
|
auto &o = *obj;
|
||||||
auto type = static_cast<ox::FileAddressType>(o["type"].get<int8_t>());
|
auto type = static_cast<ox::FileAddressType>(o["type"].get<int8_t>());
|
||||||
auto &data = o["data"].get<ox::ModelUnion>();
|
auto &data = o["data"].get<ox::ModelUnion>();
|
||||||
@ -32,8 +30,12 @@ static ox::Error pathToInode(keel::Context *ctx, ox::FileSystem *dest, ox::Model
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (beginsWith(path, "uuid://")) {
|
if (beginsWith(path, "uuid://")) {
|
||||||
|
#ifndef OX_BARE_METAL
|
||||||
const auto uuid = ox::StringView(path).substr(7);
|
const auto uuid = ox::StringView(path).substr(7);
|
||||||
path = ctx->uuidToPath[uuid];
|
path = ctx->uuidToPath[uuid];
|
||||||
|
#else
|
||||||
|
return OxError(1, "UUID to path conversion not supported on this platform");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
oxRequire(s, dest->stat(path));
|
oxRequire(s, dest->stat(path));
|
||||||
oxReturnError(o["type"].set(static_cast<int8_t>(ox::FileAddressType::Inode)));
|
oxReturnError(o["type"].set(static_cast<int8_t>(ox::FileAddressType::Inode)));
|
||||||
@ -76,7 +78,12 @@ static ox::Error transformFileAddressesObj(keel::Context *ctx, ox::FileSystem *d
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
static ox::Error doTransformations(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest, ox::CRStringView filePath) noexcept {
|
static ox::Error doTransformations(
|
||||||
|
[[maybe_unused]] keel::Context *ctx,
|
||||||
|
[[maybe_unused]] ox::TypeStore *ts,
|
||||||
|
[[maybe_unused]] ox::FileSystem *dest,
|
||||||
|
[[maybe_unused]] ox::CRStringView filePath) noexcept {
|
||||||
|
#ifndef OX_BARE_METAL
|
||||||
// load file
|
// load file
|
||||||
oxRequire(s, dest->stat(filePath));
|
oxRequire(s, dest->stat(filePath));
|
||||||
// do transformations
|
// do transformations
|
||||||
@ -91,6 +98,9 @@ static ox::Error doTransformations(keel::Context *ctx, ox::TypeStore *ts, ox::Fi
|
|||||||
// write file to dest
|
// write file to dest
|
||||||
oxReturnError(dest->write(s.inode, buff.data(), buff.size()));
|
oxReturnError(dest->write(s.inode, buff.data(), buff.size()));
|
||||||
return {};
|
return {};
|
||||||
|
#else
|
||||||
|
return OxError(1, "Transformations not supported on this platform");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// claw file transformations are broken out from copy because path to inode
|
// claw file transformations are broken out from copy because path to inode
|
||||||
@ -122,8 +132,8 @@ struct VerificationPair {
|
|||||||
ox::String path;
|
ox::String path;
|
||||||
ox::Buffer buff;
|
ox::Buffer buff;
|
||||||
VerificationPair(ox::String &&pPath, ox::Buffer &&pBuff) noexcept:
|
VerificationPair(ox::String &&pPath, ox::Buffer &&pBuff) noexcept:
|
||||||
path(std::forward<ox::String>(pPath)),
|
path(ox::forward<ox::String>(pPath)),
|
||||||
buff(std::forward<ox::Buffer>(pBuff)) {
|
buff(ox::forward<ox::Buffer>(pBuff)) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -158,7 +168,7 @@ static ox::Error copyFS(ox::FileSystem *src, ox::FileSystem *dest) noexcept {
|
|||||||
ox::Vector<VerificationPair> verificationPairs;
|
ox::Vector<VerificationPair> verificationPairs;
|
||||||
oxReturnError(copy(src, dest, "/", &verificationPairs));
|
oxReturnError(copy(src, dest, "/", &verificationPairs));
|
||||||
// verify all at once in addition to right after the files are written
|
// verify all at once in addition to right after the files are written
|
||||||
oxOutf("Verifying completed destination\n");
|
oxOut("Verifying completed destination\n");
|
||||||
for (const auto &v : verificationPairs) {
|
for (const auto &v : verificationPairs) {
|
||||||
oxReturnError(verifyFile(dest, v.path, v.buff));
|
oxReturnError(verifyFile(dest, v.path, v.buff));
|
||||||
}
|
}
|
||||||
@ -173,5 +183,3 @@ ox::Error pack(keel::Context *ctx, ox::TypeStore *ts, ox::FileSystem *dest) noex
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user