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
#define DUMB_HPP
#include "HECLDatabase.hpp"
#include "HECLRuntime.hpp"
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)
{

View File

@ -2,6 +2,7 @@
#define HMDL_HPP
#include "HECLDatabase.hpp"
#include "HECLRuntime.hpp"
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)
{

View File

@ -2,6 +2,7 @@
#define MATR_HPP
#include "HECLDatabase.hpp"
#include "HECLRuntime.hpp"
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)
{

View File

@ -2,6 +2,7 @@
#define STRG_HPP
#include "HECLDatabase.hpp"
#include "HECLRuntime.hpp"
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)
{

View File

@ -2,6 +2,7 @@
#define TXTR_HPP
#include "HECLDatabase.hpp"
#include "HECLRuntime.hpp"
#include "helpers.hpp"
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)
{

View File

@ -6,12 +6,4 @@
#include "STRG.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:LIBS += -stdlib=libc++ -lc++abi
INCLUDEPATH += $$PWD ../include ../extern
INCLUDEPATH += $$PWD ../include ../extern ../extern/Athena/include
HEADERS += \
helpers.hpp \

View File

@ -12,12 +12,13 @@ INCLUDEPATH += ../include
LIBPATH += $$OUT_PWD/../lib \
$$OUT_PWD/../dataspec \
$$OUT_PWD/../blender \
$$OUT_PWD/../extern/sqlite3 \
$$OUT_PWD/../extern/blowfish \
$$OUT_PWD/../extern/libpng \
$$OUT_PWD/../extern/zlib
$$OUT_PWD/../extern/libpng
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 += \
$$PWD/main.cpp

View File

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

View File

@ -106,8 +106,22 @@ public:
*/
class Project
{
HECL::SystemString m_rootPath;
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
@ -138,7 +152,7 @@ public:
*
* 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
@ -147,7 +161,7 @@ public:
*
* 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
@ -156,7 +170,7 @@ public:
*
* 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
@ -167,7 +181,7 @@ public:
* This method will not delete actual working files from the project
* 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
@ -183,34 +197,34 @@ public:
* This contiguous storage makes for optimal loading from slow block-devices
* 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
* @param path directory to unregister as Dependency Group
* @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
* @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)
* @param platforms String(s) representing unique platform(s) from listPlatforms
* @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)
* @param platform String(s) representing unique platform(s) from listPlatforms
* @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
@ -225,7 +239,7 @@ public:
*/
virtual bool cookPath(const HECL::SystemString& path,
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)
@ -237,7 +251,7 @@ public:
* Note that this method returns immediately; the resumed cookPath()
* call will return as quickly as possible.
*/
virtual void interruptCook()=0;
virtual void interruptCook();
/**
* @brief Delete cooked objects for directory
@ -248,7 +262,7 @@ public:
* Developers understand how useful 'clean' is. While ideally not required,
* 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
@ -280,21 +294,10 @@ public:
* @param path Subpath of project to root depsgraph at
* @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
@ -306,7 +309,7 @@ class IDataSpec
{
public:
virtual packageData();
virtual Project::PackageDepsgraph packageData();
};
}

View File

@ -27,182 +27,160 @@ static inline bool CheckNewLineAdvance(std::string::const_iterator& it)
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;
const HECL::SystemString& m_name;
HECL::SystemString m_filepath;
public:
ConfigFile(const CProject& project, const HECL::SystemString& name)
: m_project(project), m_name(name)
std::string::const_iterator origEnd = end;
if (*end == '\0')
break;
else if (CheckNewLineAdvance(end))
{
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("\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()
{
}
void registerLogger(HECL::TLogger logger)
{
}
const HECL::ProjectRootPath& getProjectRootPath(bool absolute) const
{
}
bool addPaths(const std::vector<HECL::ProjectPath>& paths)
{
}
bool removePaths(const std::vector<HECL::ProjectPath>& paths, bool recursive)
{
}
bool addGroup(const std::string& path)
{
}
bool removeGroup(const std::string& path)
{
}
const std::map<const std::string, const bool>& listPlatforms()
{
}
bool enablePlatforms(const std::vector<std::string>& platforms)
{
}
bool disablePlatforms(const std::vector<std::string>& platforms)
{
}
bool cookPath(const std::string& path,
std::function<void(std::string&, Cost, unsigned)> feedbackCb,
bool recursive)
{
}
void interruptCook()
{
}
bool cleanPath(const std::string& path, bool recursive)
{
}
bool packagePath(const std::string& path, bool recursive)
{
}
};
IProject* OpenProject(const std::string& rootPath)
bool Project::ConfigFile::checkForLine(const std::string& refLine)
{
std::vector<std::string> curLines = readLines();
for (std::string& line : curLines)
{
if (!line.compare(refLine))
return true;
}
return false;
}
Project::Project(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 */
}
void Project::registerLogger(HECL::TLogger logger)
{
}
const HECL::ProjectRootPath& Project::getProjectRootPath(bool absolute) const
{
}
bool Project::addPaths(const std::vector<HECL::ProjectPath>& paths)
{
}
bool Project::removePaths(const std::vector<HECL::ProjectPath>& paths, bool recursive)
{
}
bool Project::addGroup(const HECL::ProjectPath& path)
{
}
bool Project::removeGroup(const HECL::ProjectPath& path)
{
}
const std::map<const std::string, const bool>& Project::listPlatforms()
{
}
bool Project::enablePlatforms(const std::vector<std::string>& platforms)
{
}
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);
}
}