Skip to content
Permalink
Browse files

Initial working checks.

  • Loading branch information...
egorpugin committed May 11, 2019
1 parent 3fe3afe commit 0dcc05c0863d7ff24abc568b88f5c6b9b19f8a87
@@ -41,12 +41,12 @@ static cl::opt<bool> explain_outdated_full("explain-outdated-full", cl::desc("Ex
namespace sw
{

static ConcurrentCommandStorage &getCommandStorage(const SwContext &swctx, bool local)
static ConcurrentCommandStorage &getCommandStorage(const SwBuilderContext &swctx, bool local)
{
return swctx.getCommandStorage().getStorage(local);
}

CommandStorage::CommandStorage(const SwContext &swctx)
CommandStorage::CommandStorage(const SwBuilderContext &swctx)
: swctx(swctx)
{
load();
@@ -84,12 +84,12 @@ ConcurrentCommandStorage &CommandStorage::getStorage(bool local)
namespace builder
{

Command::Command(const SwContext &swctx)
Command::Command(const SwBuilderContext &swctx)
: swctx(swctx)
{
}

Command::Command(const SwContext &swctx, ::sw::FileStorage &fs)
Command::Command(const SwBuilderContext &swctx, ::sw::FileStorage &fs)
: swctx(swctx), fs(&fs)
{
}
@@ -47,7 +47,7 @@ namespace sw

struct FileStorage;
struct Program;
struct SwContext;
struct SwBuilderContext;

template <class T>
struct CommandData
@@ -124,7 +124,7 @@ struct SW_BUILDER_API Command : Node, std::enable_shared_from_this<Command>,
using Base = primitives::Command;
using Clock = std::chrono::high_resolution_clock;

const SwContext &swctx;
const SwBuilderContext &swctx;
FileStorage *fs = nullptr;

String name;
@@ -178,8 +178,8 @@ struct SW_BUILDER_API Command : Node, std::enable_shared_from_this<Command>,
};
int command_storage = 0;

Command(const SwContext &swctx);
Command(const SwContext &swctx, ::sw::FileStorage &fs);
Command(const SwBuilderContext &swctx);
Command(const SwBuilderContext &swctx, ::sw::FileStorage &fs);
virtual ~Command();

void prepare() override;
@@ -16,16 +16,16 @@ namespace sw
{

using ConcurrentCommandStorage = ConcurrentMapSimple<size_t>;
struct SwContext;
struct SwBuilderContext;

struct SW_BUILDER_API CommandStorage
{
const SwContext &swctx;
const SwBuilderContext &swctx;

ConcurrentCommandStorage commands_local;
ConcurrentCommandStorage commands_global;

CommandStorage(const SwContext &swctx);
CommandStorage(const SwBuilderContext &swctx);
CommandStorage(const CommandStorage &) = delete;
CommandStorage &operator=(const CommandStorage &) = delete;
~CommandStorage();
@@ -36,30 +36,30 @@ static String getCurrentModuleNameHash()
return shorten_hash(blake2b_512(getCurrentModuleName().u8string()), 12);
}

static path getDir(const SwContext &swctx, bool local)
static path getDir(const SwBuilderContext &swctx, bool local)
{
if (local)
return path(SW_BINARY_DIR) / "db";
return swctx.getLocalStorage().storage_dir_tmp / "db";
}

static path getFilesDbFilename(const SwContext &swctx, const String &config, bool local)
static path getFilesDbFilename(const SwBuilderContext &swctx, const String &config, bool local)
{
return getDir(swctx, local) / std::to_string(FILE_DB_FORMAT_VERSION) / config / "files.bin";
}

path getFilesLogFileName(const SwContext &swctx, const String &config, bool local)
path getFilesLogFileName(const SwBuilderContext &swctx, const String &config, bool local)
{
auto cfg = shorten_hash(blake2b_512(getCurrentModuleNameHash() + "_" + config), 12);
return getDir(swctx, local) / std::to_string(FILE_DB_FORMAT_VERSION) / config / ("log_" + cfg + ".bin");
}

static path getCommandsDbFilename(const SwContext &swctx, bool local)
static path getCommandsDbFilename(const SwBuilderContext &swctx, bool local)
{
return getDir(swctx, local) / std::to_string(COMMAND_DB_FORMAT_VERSION) / "commands.bin";
}

path getCommandsLogFileName(const SwContext &swctx, bool local)
path getCommandsLogFileName(const SwBuilderContext &swctx, bool local)
{
auto cfg = shorten_hash(blake2b_512(getCurrentModuleNameHash()), 12);
return getDir(swctx, local) / std::to_string(COMMAND_DB_FORMAT_VERSION) / ("log_" + cfg + ".bin");
@@ -118,7 +118,7 @@ static void load(FileStorage &fs, const path &fn,
}
}

FileDb::FileDb(const SwContext &swctx)
FileDb::FileDb(const SwBuilderContext &swctx)
: swctx(swctx)
{
}
@@ -18,9 +18,9 @@ namespace sw

struct FileDb
{
const SwContext &swctx;
const SwBuilderContext &swctx;

FileDb(const SwContext &swctx);
FileDb(const SwBuilderContext &swctx);

void load(FileStorage &fs, ConcurrentHashMap<path, FileRecord> &files, bool local) const;
void save(FileStorage &fs, ConcurrentHashMap<path, FileRecord> &files, bool local) const;
@@ -140,7 +140,7 @@ struct SW_BUILDER_API FileRecord
//fs::file_time_type updateLwt();
};

path getFilesLogFileName(const struct SwContext &swctx, const String &config, bool local);
path getFilesLogFileName(const struct SwBuilderContext &swctx, const String &config, bool local);

#define EXPLAIN_OUTDATED(subject, outdated, reason, name) \
explainMessage(subject, outdated, reason, name)
@@ -41,7 +41,7 @@ FileStorage::file_holder::~file_holder()
fs::remove(fn, ec);
}

FileStorage::FileStorage(const SwContext &swctx, const String &config)
FileStorage::FileStorage(const SwBuilderContext &swctx, const String &config)
: swctx(swctx), config(config)
{
//if (config.empty())
@@ -56,7 +56,7 @@ FileStorage::file_holder *FileStorage::getFileLog()
return async_file_log_.get();
}

path getCommandsLogFileName(const SwContext &swctx, bool local);
path getCommandsLogFileName(const SwBuilderContext &swctx, bool local);

FileStorage::file_holder *FileStorage::getCommandLog(bool local)
{
@@ -21,7 +21,7 @@ class FileMonitor;
namespace sw
{

struct SwContext;
struct SwBuilderContext;

struct SW_BUILDER_API FileStorage
{
@@ -34,12 +34,12 @@ struct SW_BUILDER_API FileStorage
~file_holder();
};

const SwContext &swctx;
const SwBuilderContext &swctx;
String config;
bool fs_local;
ConcurrentHashMap<path, FileRecord> files;

FileStorage(const SwContext &swctx, const String &config);
FileStorage(const SwBuilderContext &swctx, const String &config);
FileStorage(FileStorage &&) = default;
FileStorage &operator=(FileStorage &&) = default;
~FileStorage();
@@ -22,7 +22,7 @@
namespace sw
{

Program::Program(const SwContext &swctx)
Program::Program(const SwBuilderContext &swctx)
: swctx(swctx)
{
}
@@ -31,13 +31,13 @@
namespace sw
{

struct SwContext;
struct SwBuilderContext;

struct SW_BUILDER_API Program : File, detail::Executable
{
const SwContext &swctx;
const SwBuilderContext &swctx;

Program(const SwContext &swctx);
Program(const SwBuilderContext &swctx);
Program(const Program &);
//Program &operator=(const Program &);
virtual ~Program() = default;
@@ -18,7 +18,7 @@
namespace sw
{

SwContext::SwContext(const path &local_storage_root_dir)
SwBuilderContext::SwBuilderContext(const path &local_storage_root_dir)
: SwManagerContext(local_storage_root_dir)
{
HostOS = getHostOS();
@@ -37,14 +37,14 @@ SwContext::SwContext(const path &local_storage_root_dir)
pvs = std::make_unique<ProgramVersionStorage>(getServiceFileStorage(), getLocalStorage().storage_dir_tmp / "db" / "program_versions.txt");
}

SwContext::~SwContext() = default;
SwBuilderContext::~SwBuilderContext() = default;

Executor &SwContext::getFileStorageExecutor() const
Executor &SwBuilderContext::getFileStorageExecutor() const
{
return *file_storage_executor;
}

FileStorage &SwContext::getFileStorage(const String &config, bool local) const
FileStorage &SwBuilderContext::getFileStorage(const String &config, bool local) const
{
auto i = file_storages.find({ local, config });
if (i != file_storages.end())
@@ -54,32 +54,32 @@ FileStorage &SwContext::getFileStorage(const String &config, bool local) const
return *file_storages[{ local, config }];
}

FileStorage &SwContext::getServiceFileStorage() const
FileStorage &SwBuilderContext::getServiceFileStorage() const
{
return getFileStorage("service", true);
}

SwContext::FileDataHashMap &SwContext::getFileData() const
SwBuilderContext::FileDataHashMap &SwBuilderContext::getFileData() const
{
return *fshm;
}

FileDb &SwContext::getDb() const
FileDb &SwBuilderContext::getDb() const
{
return *db;
}

CommandStorage &SwContext::getCommandStorage() const
CommandStorage &SwBuilderContext::getCommandStorage() const
{
return *cs;
}

ProgramVersionStorage &SwContext::getVersionStorage() const
ProgramVersionStorage &SwBuilderContext::getVersionStorage() const
{
return *pvs;
}

void SwContext::clearFileStorages()
void SwBuilderContext::clearFileStorages()
{
file_storages.clear();
}
@@ -22,14 +22,14 @@ struct FileDb;
struct FileStorage;
struct ProgramVersionStorage;

struct SW_BUILDER_API SwContext : SwManagerContext
struct SW_BUILDER_API SwBuilderContext : SwManagerContext
{
using FileDataHashMap = ConcurrentHashMap<path, FileData>;

OS HostOS;

SwContext(const path &local_storage_root_dir);
virtual ~SwContext();
SwBuilderContext(const path &local_storage_root_dir);
virtual ~SwBuilderContext();

ProgramVersionStorage &getVersionStorage() const;
FileStorage &getFileStorage(const String &config, bool local) const;
@@ -10,10 +10,10 @@

//#include <resolver.h>
#include <sw/builder/file.h>
#include <sw/builder/sw_context.h>
#include <sw/driver/command.h>
#include <sw/driver/jumppad.h>
#include <sw/driver/build.h>
#include <sw/driver/sw_context.h>
#include <sw/manager/api.h>
#include <sw/manager/database.h>
#include <sw/manager/package_data.h>
Oops, something went wrong.

0 comments on commit 0dcc05c

Please sign in to comment.
You can’t perform that action at this time.