Refinements to avoid bad level linkages

This commit is contained in:
Jack Andersen 2016-09-18 13:46:49 -10:00
parent a0470a3ef5
commit 6de25c1d1d
24 changed files with 137 additions and 44 deletions

View File

@ -22,10 +22,7 @@ add_custom_command(OUTPUT hecl.zip DEPENDS ${PY_SOURCES}
bintoc(hecl_addon.c "${CMAKE_CURRENT_BINARY_DIR}/hecl.zip" HECL_ADDON) bintoc(hecl_addon.c "${CMAKE_CURRENT_BINARY_DIR}/hecl.zip" HECL_ADDON)
bintoc(hecl_startup.c hecl_startup.blend HECL_STARTUP) bintoc(hecl_startup.c hecl_startup.blend HECL_STARTUP)
add_library(hecl-blender add_library(hecl-blender-addon
BlenderConnection.cpp
BlenderConnection.hpp
HMDL.cpp
hecl_blendershell.py hecl_blendershell.py
hecl_blendershell.c hecl_blendershell.c
zip_package.py zip_package.py

View File

@ -24,6 +24,6 @@ endif()
target_link_libraries(hecl target_link_libraries(hecl
${DATA_SPEC_LIBS} ${DATA_SPEC_LIBS}
hecl-database hecl-backend hecl-frontend hecl-blender hecl-common athena-core nod hecl-common hecl-blender-addon athena-core nod
logvisor athena-libyaml ${PNG_LIB} squish xxhash zeus boo logvisor athena-libyaml ${PNG_LIB} squish xxhash zeus boo
${ZLIB_LIBRARIES} ${LZO_LIB} ${PLAT_LIBS} ${BOO_SYS_LIBS}) ${ZLIB_LIBRARIES} ${LZO_LIB} ${PLAT_LIBS} ${BOO_SYS_LIBS})

View File

@ -15,7 +15,7 @@
#include <regex> #include <regex>
#include <list> #include <list>
#include "hecl/Database.hpp" #include "hecl/Database.hpp"
#include "../blender/BlenderConnection.hpp" #include "hecl/Blender/BlenderConnection.hpp"
#include "logvisor/logvisor.hpp" #include "logvisor/logvisor.hpp"
logvisor::Module LogModule("HECLDriver"); logvisor::Module LogModule("HECLDriver");

2
hecl/extern/athena vendored

@ -1 +1 @@
Subproject commit 8d2fbad26521955b2b29a1af1ab70d649c87eb0b Subproject commit d4d1bdabc680399123c19209d0162278764bda64

2
hecl/extern/boo vendored

@ -1 +1 @@
Subproject commit fa61f2acaea97d651c57b5d5f9bdcf4172bb11e4 Subproject commit 46b1b84cfc6cfa4d7ae27fe7b2b0e8dfb398e866

View File

@ -3,7 +3,7 @@
#include "hecl.hpp" #include "hecl.hpp"
#include "Database.hpp" #include "Database.hpp"
#include "BlenderConnection.hpp" #include "hecl/Blender/BlenderConnection.hpp"
#include <list> #include <list>
#include <thread> #include <thread>
#include <mutex> #include <mutex>

View File

@ -337,14 +337,7 @@ public:
* *
* The cooked path matches the directory layout of the working directory * The cooked path matches the directory layout of the working directory
*/ */
const ProjectPath& getProjectCookedPath(const DataSpecEntry& spec) const const ProjectPath& getProjectCookedPath(const DataSpecEntry& spec) const;
{
for (const ProjectDataSpec& sp : m_compiledSpecs)
if (&sp.spec == &spec)
return sp.cookedPath;
LogModule.report(logvisor::Fatal, "Unable to find spec '%s'", spec.m_name);
return m_cookedRoot;
}
/** /**
* @brief Add given file(s) to the database * @brief Add given file(s) to the database

View File

@ -1111,6 +1111,43 @@ public:
*/ */
Type getPathType() const; Type getPathType() const;
/**
* @brief Test if nothing exists at path
* @return True if nothing exists at path
*/
bool isNone() const
{
return getPathType() == Type::None;
}
/**
* @brief Test if regular file exists at path
* @return True if regular file exists at path
*/
bool isFile() const
{
return getPathType() == Type::File;
}
/**
* @brief Test if directory exists at path
* @return True if directory exists at path
*/
bool isDirectory() const
{
return getPathType() == Type::Directory;
}
/**
* @brief Certain singular resource targets are cooked based on this test
* @return True if file or glob
*/
bool isFileOrGlob() const
{
Type type = getPathType();
return (type == Type::File || type == Type::Glob);
}
/** /**
* @brief Get time of last modification with special behaviors for directories and glob-paths * @brief Get time of last modification with special behaviors for directories and glob-paths
* @return Time object representing entity's time of last modification * @return Time object representing entity's time of last modification
@ -1220,6 +1257,24 @@ public:
return false; return false;
return !StrCmp(&*(str.end() - len), test); return !StrCmp(&*(str.end() - len), test);
} }
#if HECL_UCS2
static bool BeginsWith(const std::string& str, const char* test)
{
size_t len = strlen(test);
if (len > str.size())
return false;
return !strcmp(str.data(), test);
}
static bool EndsWith(const std::string& str, const char* test)
{
size_t len = strlen(test);
if (len > str.size())
return false;
return !strcmp(&*(str.end() - len), test);
}
#endif
}; };
/** /**

View File

@ -5,8 +5,10 @@ if(APPLE)
set(PLAT_SRCS Metal.cpp) set(PLAT_SRCS Metal.cpp)
endif() endif()
add_library(hecl-backend set(BACKEND_SOURCES
GX.cpp GX.cpp
ProgrammableCommon.cpp ProgrammableCommon.cpp
GLSL.cpp GLSL.cpp
${PLAT_SRCS}) ${PLAT_SRCS})
hecl_add_list(Backend BACKEND_SOURCES)

View File

@ -14,7 +14,7 @@
#include <hecl/hecl.hpp> #include <hecl/hecl.hpp>
#include <hecl/Database.hpp> #include <hecl/Database.hpp>
#include "logvisor/logvisor.hpp" #include "logvisor/logvisor.hpp"
#include "BlenderConnection.hpp" #include "hecl/Blender/BlenderConnection.hpp"
#if _WIN32 #if _WIN32
#include <io.h> #include <io.h>

View File

@ -0,0 +1,5 @@
set(BLENDER_SOURCES
BlenderConnection.cpp
HMDL.cpp)
hecl_add_list(Blender BLENDER_SOURCES)

View File

@ -1,4 +1,4 @@
#include "BlenderConnection.hpp" #include "hecl/Blender/BlenderConnection.hpp"
#include <cmath> #include <cmath>
#include <float.h> #include <float.h>

View File

@ -1,5 +1,13 @@
macro(hecl_add_list rel_path a_list)
unset(tmp_list)
foreach(path IN LISTS ${a_list})
list(APPEND tmp_list "${rel_path}/${path}")
endforeach(path)
set(${a_list} "${tmp_list}" PARENT_SCOPE)
endmacro(hecl_add_list)
add_subdirectory(Blender)
add_subdirectory(Backend) add_subdirectory(Backend)
add_subdirectory(Database)
add_subdirectory(Frontend) add_subdirectory(Frontend)
add_subdirectory(Runtime) add_subdirectory(Runtime)
@ -13,7 +21,12 @@ atdna(atdna_Runtime.cpp ../include/hecl/Runtime.hpp)
atdna(atdna_CVar.cpp ../include/hecl/CVar.hpp) atdna(atdna_CVar.cpp ../include/hecl/CVar.hpp)
add_library(hecl-common add_library(hecl-common
${BLENDER_SOURCES}
${BACKEND_SOURCES}
${FRONTEND_SOURCES}
${RUNTIME_SOURCES}
hecl.cpp hecl.cpp
Project.cpp
ProjectPath.cpp ProjectPath.cpp
WideStringConvert.cpp WideStringConvert.cpp
HumanizeNumber.cpp HumanizeNumber.cpp
@ -29,6 +42,7 @@ add_library(hecl-common
../include/hecl/Backend/GLSL.hpp ../include/hecl/Backend/GLSL.hpp
../include/hecl/Backend/HLSL.hpp ../include/hecl/Backend/HLSL.hpp
../include/hecl/Backend/Metal.hpp ../include/hecl/Backend/Metal.hpp
../include/hecl/Blender/BlenderConnection.hpp
../include/hecl/Frontend.hpp ../include/hecl/Frontend.hpp
../include/hecl/Database.hpp ../include/hecl/Database.hpp
../include/hecl/Runtime.hpp ../include/hecl/Runtime.hpp

View File

@ -1,7 +1,7 @@
#include "hecl/ClientProcess.hpp" #include "hecl/ClientProcess.hpp"
#include "hecl/Database.hpp" #include "hecl/Database.hpp"
#include "athena/FileReader.hpp" #include "athena/FileReader.hpp"
#include "BlenderConnection.hpp" #include "hecl/Blender/BlenderConnection.hpp"
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN

View File

@ -1,3 +0,0 @@
add_library(hecl-database
Project.cpp)

View File

@ -1,4 +1,6 @@
add_library(hecl-frontend set(FRONTEND_SOURCES
Parser.cpp Parser.cpp
Lexer.cpp Lexer.cpp
Diagnostics.cpp) Diagnostics.cpp)
hecl_add_list(Frontend FRONTEND_SOURCES)

View File

@ -10,7 +10,7 @@
#endif #endif
#include "hecl/Database.hpp" #include "hecl/Database.hpp"
#include "BlenderConnection.hpp" #include "hecl/Blender/BlenderConnection.hpp"
namespace hecl namespace hecl
{ {
@ -252,6 +252,15 @@ Project::Project(const ProjectRootPath& rootPath)
m_valid = true; m_valid = true;
} }
const ProjectPath& Project::getProjectCookedPath(const DataSpecEntry& spec) const
{
for (const ProjectDataSpec& sp : m_compiledSpecs)
if (&sp.spec == &spec)
return sp.cookedPath;
LogModule.report(logvisor::Fatal, "Unable to find spec '%s'", spec.m_name);
return m_cookedRoot;
}
bool Project::addPaths(const std::vector<ProjectPath>& paths) bool Project::addPaths(const std::vector<ProjectPath>& paths)
{ {
m_paths.lockAndRead(); m_paths.lockAndRead();

View File

@ -134,7 +134,11 @@ ProjectPath ProjectPath::getCookedPath(const Database::DataSpecEntry& spec) cons
ProjectPath::Type ProjectPath::getPathType() const ProjectPath::Type ProjectPath::getPathType() const
{ {
if (std::regex_search(m_absPath, regGLOB)) if (std::regex_search(m_absPath, regGLOB))
return Type::Glob; {
std::vector<ProjectPath> globResults;
getGlobResults(globResults);
return globResults.size() ? Type::Glob : Type::None;
}
Sstat theStat; Sstat theStat;
if (hecl::Stat(m_absPath.c_str(), &theStat)) if (hecl::Stat(m_absPath.c_str(), &theStat))
return Type::None; return Type::None;

View File

@ -1,4 +1,6 @@
add_library(hecl-runtime set(RUNTIME_SOURCES
FileStoreManager.cpp FileStoreManager.cpp
ShaderCacheManager.cpp) ShaderCacheManager.cpp
add_library(hecl-hmdl HMDL.cpp) HMDL_RT.cpp)
hecl_add_list(Runtime RUNTIME_SOURCES)

View File

@ -23,7 +23,7 @@ namespace hecl
{ {
unsigned VerbosityLevel = 0; unsigned VerbosityLevel = 0;
logvisor::Module LogModule("hecl"); logvisor::Module LogModule("hecl");
static const std::string Illegals {"<>?*\"|"}; static const std::string Illegals {"<>?\"|"};
void SanitizePath(std::string& path) void SanitizePath(std::string& path)
{ {
@ -139,10 +139,16 @@ bool IsPathPNG(const hecl::ProjectPath& path)
bool IsPathBlend(const hecl::ProjectPath& path) bool IsPathBlend(const hecl::ProjectPath& path)
{ {
const SystemChar* lastCompExt = path.getLastComponentExt(); hecl::ProjectPath usePath;
if (path.getPathType() == hecl::ProjectPath::Type::Glob)
usePath = path.getWithExtension(_S(".blend"), true);
else
usePath = path;
const SystemChar* lastCompExt = usePath.getLastComponentExt();
if (!lastCompExt || hecl::StrCmp(lastCompExt, _S("blend"))) if (!lastCompExt || hecl::StrCmp(lastCompExt, _S("blend")))
return false; return false;
FILE* fp = hecl::Fopen(path.getAbsolutePath().c_str(), _S("rb")); FILE* fp = hecl::Fopen(usePath.getAbsolutePath().c_str(), _S("rb"));
if (!fp) if (!fp)
return false; return false;
uint32_t buf; uint32_t buf;

View File

@ -1,5 +1,4 @@
add_executable(heclTest WIN32 main.cpp) add_executable(heclTest WIN32 main.cpp)
target_link_libraries(heclTest target_link_libraries(heclTest
hecl-database hecl-runtime hecl-backend hecl-frontend hecl-common hecl-blender-addon athena-core xxhash
hecl-hmdl hecl-blender hecl-common athena-core xxhash
logvisor boo ${ZLIB_LIBRARIES} ${BOO_SYS_LIBS}) logvisor boo ${ZLIB_LIBRARIES} ${BOO_SYS_LIBS})

View File

@ -9,6 +9,14 @@
#include <mutex> #include <mutex>
#include <condition_variable> #include <condition_variable>
namespace hecl
{
namespace Database
{
std::vector<const struct DataSpecEntry*> DATA_SPEC_REGISTRY;
}
}
struct HECLWindowCallback : boo::IWindowCallback struct HECLWindowCallback : boo::IWindowCallback
{ {
bool m_sizeDirty = false; bool m_sizeDirty = false;