more Athena integration

This commit is contained in:
Jack Andersen 2015-06-09 12:57:21 -10:00
parent 84f8c62d28
commit 9de4d3fbe7
12 changed files with 197 additions and 218 deletions

4
hecl/bootstrap.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
git submodule init
git submodule update

View File

@ -1,7 +1,7 @@
#ifndef DUMB_HPP #ifndef DUMB_HPP
#define DUMB_HPP #define DUMB_HPP
#include "HECLDatabase.hpp" #include "HECLRuntime.hpp"
class CDUMBProject : public HECLDatabase::ProjectObjectBase class CDUMBProject : public HECLDatabase::ProjectObjectBase
{ {
@ -20,9 +20,9 @@ class CDUMBProject : public HECLDatabase::ProjectObjectBase
}; };
class CDUMBRuntime : public HECLDatabase::RuntimeObjectBase class CDUMBRuntime : public HECLRuntime::RuntimeObjectBase
{ {
using HECLDatabase::RuntimeObjectBase::RuntimeObjectBase; using HECLRuntime::RuntimeObjectBase::RuntimeObjectBase;
bool _objectFinishedLoading(const void* data, size_t len) bool _objectFinishedLoading(const void* data, size_t len)
{ {

View File

@ -2,6 +2,7 @@
#define HMDL_HPP #define HMDL_HPP
#include "HECLDatabase.hpp" #include "HECLDatabase.hpp"
#include "HECLRuntime.hpp"
class CHMDLProject : public HECLDatabase::ProjectObjectBase class CHMDLProject : public HECLDatabase::ProjectObjectBase
{ {
@ -19,9 +20,9 @@ class CHMDLProject : public HECLDatabase::ProjectObjectBase
} }
}; };
class CHMDLRuntime : public HECLDatabase::RuntimeObjectBase class CHMDLRuntime : public HECLRuntime::RuntimeObjectBase
{ {
using HECLDatabase::RuntimeObjectBase::RuntimeObjectBase; using HECLRuntime::RuntimeObjectBase::RuntimeObjectBase;
bool _objectFinishedLoading(const void* data, size_t len) bool _objectFinishedLoading(const void* data, size_t len)
{ {

View File

@ -2,6 +2,7 @@
#define MATR_HPP #define MATR_HPP
#include "HECLDatabase.hpp" #include "HECLDatabase.hpp"
#include "HECLRuntime.hpp"
class CMATRProject : public HECLDatabase::ProjectObjectBase class CMATRProject : public HECLDatabase::ProjectObjectBase
{ {
@ -19,9 +20,9 @@ class CMATRProject : public HECLDatabase::ProjectObjectBase
} }
}; };
class CMATRRuntime : public HECLDatabase::RuntimeObjectBase class CMATRRuntime : public HECLRuntime::RuntimeObjectBase
{ {
using HECLDatabase::RuntimeObjectBase::RuntimeObjectBase; using HECLRuntime::RuntimeObjectBase::RuntimeObjectBase;
bool _objectFinishedLoading(const void* data, size_t len) bool _objectFinishedLoading(const void* data, size_t len)
{ {

View File

@ -2,6 +2,7 @@
#define STRG_HPP #define STRG_HPP
#include "HECLDatabase.hpp" #include "HECLDatabase.hpp"
#include "HECLRuntime.hpp"
class CSTRGProject : public HECLDatabase::ProjectObjectBase class CSTRGProject : public HECLDatabase::ProjectObjectBase
{ {
@ -19,9 +20,9 @@ class CSTRGProject : public HECLDatabase::ProjectObjectBase
} }
}; };
class CSTRGRuntime : public HECLDatabase::RuntimeObjectBase class CSTRGRuntime : public HECLRuntime::RuntimeObjectBase
{ {
using HECLDatabase::RuntimeObjectBase::RuntimeObjectBase; using HECLRuntime::RuntimeObjectBase::RuntimeObjectBase;
bool _objectFinishedLoading(const void* data, size_t len) bool _objectFinishedLoading(const void* data, size_t len)
{ {

View File

@ -2,6 +2,7 @@
#define TXTR_HPP #define TXTR_HPP
#include "HECLDatabase.hpp" #include "HECLDatabase.hpp"
#include "HECLRuntime.hpp"
#include "helpers.hpp" #include "helpers.hpp"
class CTXTRProject : public HECLDatabase::ProjectObjectBase class CTXTRProject : public HECLDatabase::ProjectObjectBase
@ -30,9 +31,9 @@ public:
} }
}; };
class CTXTRRuntime : public HECLDatabase::RuntimeObjectBase class CTXTRRuntime : public HECLRuntime::RuntimeObjectBase
{ {
using HECLDatabase::RuntimeObjectBase::RuntimeObjectBase; using HECLRuntime::RuntimeObjectBase::RuntimeObjectBase;
bool _objectFinishedLoading(const void* data, size_t len) bool _objectFinishedLoading(const void* data, size_t len)
{ {

View File

@ -6,12 +6,4 @@
#include "STRG.hpp" #include "STRG.hpp"
#include "TXTR.hpp" #include "TXTR.hpp"
const HECLDatabase::RegistryEntry DATASPEC_TYPE_REGISTRY[]
{
REGISTRY_ENTRY("DUMB", CDUMBProject, CDUMBRuntime),
REGISTRY_ENTRY("HMDL", CHMDLProject, CHMDLRuntime),
REGISTRY_ENTRY("MATR", CMATRProject, CMATRRuntime),
REGISTRY_ENTRY("STRG", CSTRGProject, CSTRGRuntime),
REGISTRY_ENTRY("TXTR", CTXTRProject, CTXTRRuntime),
REGISTRY_SENTINEL()
};

View File

@ -9,7 +9,7 @@ unix:LIBS += -std=c++11
clang:QMAKE_CXXFLAGS += -stdlib=libc++ clang:QMAKE_CXXFLAGS += -stdlib=libc++
clang:LIBS += -stdlib=libc++ -lc++abi clang:LIBS += -stdlib=libc++ -lc++abi
INCLUDEPATH += $$PWD ../include ../extern INCLUDEPATH += $$PWD ../include ../extern ../extern/Athena/include
HEADERS += \ HEADERS += \
helpers.hpp \ helpers.hpp \

View File

@ -12,12 +12,13 @@ INCLUDEPATH += ../include
LIBPATH += $$OUT_PWD/../lib \ LIBPATH += $$OUT_PWD/../lib \
$$OUT_PWD/../dataspec \ $$OUT_PWD/../dataspec \
$$OUT_PWD/../blender \ $$OUT_PWD/../blender \
$$OUT_PWD/../extern/sqlite3 \
$$OUT_PWD/../extern/blowfish \ $$OUT_PWD/../extern/blowfish \
$$OUT_PWD/../extern/libpng \ $$OUT_PWD/../extern/libpng
$$OUT_PWD/../extern/zlib
LIBS += -lhecl -lhecl-dataspec -lhecl-blender -lsqlite3 -lblowfish -lpng -lz LIBS += -lhecl -lhecl-dataspec -lhecl-blender -lblowfish -lpng
# Yay!! Athena IO
include(../extern/Athena/AthenaCore.pri)
SOURCES += \ SOURCES += \
$$PWD/main.cpp $$PWD/main.cpp

View File

@ -18,19 +18,16 @@ HEADERS += \
include/HECLRuntime.hpp include/HECLRuntime.hpp
SUBDIRS += \ SUBDIRS += \
extern/sqlite3 \
extern/blowfish \ extern/blowfish \
extern/libpng \ extern/libpng \
extern/zlib \ extern/Athena \
blender \ blender \
lib \ lib \
dataspec \ dataspec \
driver driver
driver.depends = extern/sqlite3
driver.depends = extern/blowfish driver.depends = extern/blowfish
driver.depends = extern/libpng driver.depends = extern/libpng
driver.depends = extern/zlib
driver.depends = blender driver.depends = blender
driver.depends = lib driver.depends = lib
driver.depends = dataspec driver.depends = dataspec

View File

@ -106,8 +106,22 @@ public:
*/ */
class Project class Project
{ {
HECL::SystemString m_rootPath;
public: public:
virtual ~IProject() {} Project(const std::string& rootPath);
class ConfigFile
{
const Project& m_project;
const HECL::SystemString& m_name;
HECL::SystemString m_filepath;
public:
ConfigFile(const Project& project, const HECL::SystemString& name);
std::vector<std::string> readLines();
void addLine(const std::string& line);
void removeLine(const std::string& refLine);
bool checkForLine(const std::string& refLine);
};
/** /**
* @brief Internal packagePath() exception * @brief Internal packagePath() exception
@ -138,7 +152,7 @@ public:
* *
* If this method is never called, all project operations will run silently. * If this method is never called, all project operations will run silently.
*/ */
virtual void registerLogger(HECL::TLogger logger)=0; virtual void registerLogger(HECL::TLogger logger);
/** /**
* @brief Get the path of the project's root-directory * @brief Get the path of the project's root-directory
@ -147,7 +161,7 @@ public:
* *
* Self explanatory * Self explanatory
*/ */
virtual const HECL::ProjectRootPath& getProjectRootPath(bool absolute=false) const=0; virtual const HECL::ProjectRootPath& getProjectRootPath(bool absolute=false) const;
/** /**
* @brief Add given file(s) to the database * @brief Add given file(s) to the database
@ -156,7 +170,7 @@ public:
* *
* This method blocks while object hashing takes place * This method blocks while object hashing takes place
*/ */
virtual bool addPaths(const std::vector<HECL::ProjectPath>& paths)=0; virtual bool addPaths(const std::vector<HECL::ProjectPath>& paths);
/** /**
* @brief Remove a given file or file-pattern from the database * @brief Remove a given file or file-pattern from the database
@ -167,7 +181,7 @@ public:
* This method will not delete actual working files from the project * This method will not delete actual working files from the project
* directory. It will delete associated cooked objects though. * directory. It will delete associated cooked objects though.
*/ */
virtual bool removePaths(const std::vector<HECL::ProjectPath>& paths, bool recursive=false)=0; virtual bool removePaths(const std::vector<HECL::ProjectPath>& paths, bool recursive=false);
/** /**
* @brief Register a working sub-directory as a Dependency Group * @brief Register a working sub-directory as a Dependency Group
@ -183,34 +197,34 @@ public:
* This contiguous storage makes for optimal loading from slow block-devices * This contiguous storage makes for optimal loading from slow block-devices
* like optical drives. * like optical drives.
*/ */
virtual bool addGroup(const HECL::ProjectPath& path)=0; virtual bool addGroup(const HECL::ProjectPath& path);
/** /**
* @brief Unregister a working sub-directory as a dependency group * @brief Unregister a working sub-directory as a dependency group
* @param path directory to unregister as Dependency Group * @param path directory to unregister as Dependency Group
* @return true on success * @return true on success
*/ */
virtual bool removeGroup(const HECL::ProjectPath& path)=0; virtual bool removeGroup(const HECL::ProjectPath& path);
/** /**
* @brief Return map populated with platforms targetable by this project interface * @brief Return map populated with platforms targetable by this project interface
* @return Platform map with name-string keys and enable-status values * @return Platform map with name-string keys and enable-status values
*/ */
virtual const std::map<const std::string, const bool>& listPlatforms()=0; virtual const std::map<const std::string, const bool>& listPlatforms();
/** /**
* @brief Enable persistent user preference for particular platform string(s) * @brief Enable persistent user preference for particular platform string(s)
* @param platforms String(s) representing unique platform(s) from listPlatforms * @param platforms String(s) representing unique platform(s) from listPlatforms
* @return true on success * @return true on success
*/ */
virtual bool enablePlatforms(const std::vector<std::string>& platforms)=0; virtual bool enablePlatforms(const std::vector<std::string>& platforms);
/** /**
* @brief Disable persistent user preference for particular platform string(s) * @brief Disable persistent user preference for particular platform string(s)
* @param platform String(s) representing unique platform(s) from listPlatforms * @param platform String(s) representing unique platform(s) from listPlatforms
* @return true on success * @return true on success
*/ */
virtual bool disablePlatforms(const std::vector<std::string>& platforms)=0; virtual bool disablePlatforms(const std::vector<std::string>& platforms);
/** /**
* @brief Begin cook process for specified directory * @brief Begin cook process for specified directory
@ -225,7 +239,7 @@ public:
*/ */
virtual bool cookPath(const HECL::SystemString& path, virtual bool cookPath(const HECL::SystemString& path,
std::function<void(std::string&, Cost, unsigned)> feedbackCb, std::function<void(std::string&, Cost, unsigned)> feedbackCb,
bool recursive=false)=0; bool recursive=false);
/** /**
* @brief Interrupts a cook in progress (call from SIGINT handler) * @brief Interrupts a cook in progress (call from SIGINT handler)
@ -237,7 +251,7 @@ public:
* Note that this method returns immediately; the resumed cookPath() * Note that this method returns immediately; the resumed cookPath()
* call will return as quickly as possible. * call will return as quickly as possible.
*/ */
virtual void interruptCook()=0; virtual void interruptCook();
/** /**
* @brief Delete cooked objects for directory * @brief Delete cooked objects for directory
@ -248,7 +262,7 @@ public:
* Developers understand how useful 'clean' is. While ideally not required, * Developers understand how useful 'clean' is. While ideally not required,
* it's useful for verifying that a rebuild from ground-up is doable. * it's useful for verifying that a rebuild from ground-up is doable.
*/ */
virtual bool cleanPath(const HECL::SystemString& path, bool recursive=false)=0; virtual bool cleanPath(const HECL::SystemString& path, bool recursive=false);
/** /**
* @brief Nodegraph class for gathering dependency-resolved objects for packaging * @brief Nodegraph class for gathering dependency-resolved objects for packaging
@ -280,21 +294,10 @@ public:
* @param path Subpath of project to root depsgraph at * @param path Subpath of project to root depsgraph at
* @return Populated depsgraph ready to traverse * @return Populated depsgraph ready to traverse
*/ */
virtual PackageDepsgraph buildPackageDepsgraph(const HECL::ProjectPath& path)=0; virtual PackageDepsgraph buildPackageDepsgraph(const HECL::ProjectPath& path);
}; };
/**
* @brief Opens an existing or creates a new project using specified root directory
* @param rootPath Path to project root-directory
* @return New project object
*
* This is the preferred way to open an existing or create a new HECL project.
* All necessary database index files and object directories will be established
* within the specified directory path.
*/
Project* OpenProject(const HECL::ProjectRootPath& rootPath);
/** /**
* @brief Subclassed by dataspec entries to manage per-game aspects of the data pipeline * @brief Subclassed by dataspec entries to manage per-game aspects of the data pipeline
@ -306,7 +309,7 @@ class IDataSpec
{ {
public: public:
virtual packageData(); virtual Project::PackageDepsgraph packageData();
}; };
} }

View File

@ -27,182 +27,160 @@ static inline bool CheckNewLineAdvance(std::string::const_iterator& it)
return false; return false;
} }
class CProject : public IProject Project::ConfigFile::ConfigFile(const Project& project, const HECL::SystemString& name)
: m_project(project), m_name(name)
{ {
HECL::SystemString m_rootPath; m_filepath = project.m_rootPath + _S("/.hecl/config/") + name;
}
class ConfigFile std::vector<std::string> Project::ConfigFile::readLines()
{
FILE* fp = HECL::Fopen(m_filepath.c_str(), _S("r"));
std::string mainString;
char readBuf[1024];
size_t readSz;
while ((readSz = fread(readBuf, 1, 1024, fp)))
mainString += std::string(readBuf, readSz);
fclose(fp);
std::string::const_iterator begin = mainString.begin();
std::string::const_iterator end = mainString.begin();
std::vector<std::string> retval;
while (end != mainString.end())
{ {
const CProject& m_project; std::string::const_iterator origEnd = end;
const HECL::SystemString& m_name; if (*end == '\0')
HECL::SystemString m_filepath; break;
public: else if (CheckNewLineAdvance(end))
ConfigFile(const CProject& project, const HECL::SystemString& name)
: m_project(project), m_name(name)
{ {
m_filepath = project.m_rootPath + _S("/.hecl/config/") + name; if (begin != origEnd)
retval.push_back(std::string(begin, origEnd));
begin = end;
continue;
} }
++end;
}
if (begin != end)
retval.push_back(std::string(begin, end));
std::vector<std::string> readLines() return retval;
}
void Project::ConfigFile::addLine(const std::string& line)
{
std::vector<std::string> curLines = readLines();
FILE* fp = HECL::Fopen(m_filepath.c_str(), _S("w"));
for (std::string& line : curLines)
{
fwrite(line.data(), 1, line.length(), fp);
fwrite("\n", 1, 1, fp);
}
fwrite(line.data(), 1, line.length(), fp);
fwrite("\n", 1, 1, fp);
fclose(fp);
}
void Project::ConfigFile::removeLine(const std::string& refLine)
{
std::vector<std::string> curLines = readLines();
FILE* fp = HECL::Fopen(m_filepath.c_str(), _S("w"));
for (std::string& line : curLines)
{
if (line.compare(refLine))
{ {
FILE* fp = HECL::Fopen(m_filepath.c_str(), _S("r"));
std::string mainString;
char readBuf[1024];
size_t readSz;
while ((readSz = fread(readBuf, 1, 1024, fp)))
mainString += std::string(readBuf, readSz);
fclose(fp);
std::string::const_iterator begin = mainString.begin();
std::string::const_iterator end = mainString.begin();
std::vector<std::string> retval;
while (end != mainString.end())
{
std::string::const_iterator origEnd = end;
if (CheckNewLineAdvance(end))
{
if (begin != origEnd)
retval.push_back(std::string(begin, origEnd));
begin = end;
continue;
}
++end;
}
if (begin != end)
retval.push_back(std::string(begin, end));
return retval;
}
void addLine(const std::string& line)
{
std::vector<std::string> curLines = readLines();
FILE* fp = HECL::Fopen(m_filepath.c_str(), _S("w"));
for (std::string& line : curLines)
{
fwrite(line.data(), 1, line.length(), fp);
fwrite("\n", 1, 1, fp);
}
fwrite(line.data(), 1, line.length(), fp); fwrite(line.data(), 1, line.length(), fp);
fwrite("\n", 1, 1, fp); fwrite("\n", 1, 1, fp);
fclose(fp);
} }
void removeLine(const std::string& refLine)
{
std::vector<std::string> curLines = readLines();
FILE* fp = HECL::Fopen(m_filepath.c_str(), _S("w"));
for (std::string& line : curLines)
{
if (line.compare(refLine))
{
fwrite(line.data(), 1, line.length(), fp);
fwrite("\n", 1, 1, fp);
}
}
fclose(fp);
}
bool checkForLine(const std::string& refLine)
{
std::vector<std::string> curLines = readLines();
for (std::string& line : curLines)
{
if (!line.compare(refLine))
return true;
}
return false;
}
};
public:
CProject(const std::string& rootPath)
: m_rootPath(rootPath)
{
/* Stat for existing project directory (must already exist) */
struct stat myStat;
if (stat(m_rootPath.c_str(), &myStat))
throw std::error_code(errno, std::system_category());
if (!S_ISDIR(myStat.st_mode))
throw std::invalid_argument("provided path must be a directory; '" + m_rootPath + "' isn't");
/* Create project directory structure */
HECL::MakeDir(m_rootPath + "/.hecl");
HECL::MakeDir(m_rootPath + "/.hecl/cooked");
HECL::MakeDir(m_rootPath + "/.hecl/config");
/* Create or open databases */
} }
fclose(fp);
}
~CProject() bool Project::ConfigFile::checkForLine(const std::string& refLine)
{ {
} std::vector<std::string> curLines = readLines();
for (std::string& line : curLines)
void registerLogger(HECL::TLogger logger) {
{ if (!line.compare(refLine))
} return true;
}
const HECL::ProjectRootPath& getProjectRootPath(bool absolute) const return false;
{ }
}
Project::Project(const std::string& rootPath)
bool addPaths(const std::vector<HECL::ProjectPath>& paths) : m_rootPath(rootPath)
{ {
} /* Stat for existing project directory (must already exist) */
struct stat myStat;
bool removePaths(const std::vector<HECL::ProjectPath>& paths, bool recursive) if (stat(m_rootPath.c_str(), &myStat))
{ throw std::error_code(errno, std::system_category());
}
if (!S_ISDIR(myStat.st_mode))
bool addGroup(const std::string& path) throw std::invalid_argument("provided path must be a directory; '" + m_rootPath + "' isn't");
{
} /* Create project directory structure */
HECL::MakeDir(m_rootPath + "/.hecl");
bool removeGroup(const std::string& path) HECL::MakeDir(m_rootPath + "/.hecl/cooked");
{ HECL::MakeDir(m_rootPath + "/.hecl/config");
}
/* Create or open databases */
const std::map<const std::string, const bool>& listPlatforms() }
{
} void Project::registerLogger(HECL::TLogger logger)
{
bool enablePlatforms(const std::vector<std::string>& platforms) }
{
} const HECL::ProjectRootPath& Project::getProjectRootPath(bool absolute) const
{
bool disablePlatforms(const std::vector<std::string>& platforms) }
{
} bool Project::addPaths(const std::vector<HECL::ProjectPath>& paths)
{
bool cookPath(const std::string& path, }
std::function<void(std::string&, Cost, unsigned)> feedbackCb,
bool recursive) bool Project::removePaths(const std::vector<HECL::ProjectPath>& paths, bool recursive)
{ {
} }
void interruptCook() bool Project::addGroup(const HECL::ProjectPath& path)
{ {
} }
bool cleanPath(const std::string& path, bool recursive) bool Project::removeGroup(const HECL::ProjectPath& path)
{ {
} }
bool packagePath(const std::string& path, bool recursive) const std::map<const std::string, const bool>& Project::listPlatforms()
{ {
} }
}; bool Project::enablePlatforms(const std::vector<std::string>& platforms)
{
IProject* OpenProject(const std::string& rootPath) }
bool Project::disablePlatforms(const std::vector<std::string>& platforms)
{
}
bool Project::cookPath(const std::string& path,
std::function<void(std::string&, Cost, unsigned)> feedbackCb,
bool recursive)
{
}
void Project::interruptCook()
{
}
bool Project::cleanPath(const std::string& path, bool recursive)
{
}
Project::PackageDepsgraph Project::buildPackageDepsgraph(const HECL::ProjectPath& path)
{ {
return new CProject(rootPath);
} }
} }