|
|
@@ -27,6 +27,7 @@
|
|
|
#include "font_resource.h"
|
|
|
#include "level_resource.h"
|
|
|
#include "shader.h"
|
|
|
+#include "config_resource.h"
|
|
|
#include <setjmp.h>
|
|
|
|
|
|
namespace crown
|
|
|
@@ -36,6 +37,7 @@ BundleCompiler::BundleCompiler(const char* source_dir, const char* bundle_dir)
|
|
|
: _source_fs(source_dir)
|
|
|
, _bundle_fs(bundle_dir)
|
|
|
, _compilers(default_allocator())
|
|
|
+ , _files(default_allocator())
|
|
|
{
|
|
|
namespace pcr = physics_config_resource;
|
|
|
namespace phr = physics_resource;
|
|
|
@@ -51,6 +53,7 @@ BundleCompiler::BundleCompiler(const char* source_dir, const char* bundle_dir)
|
|
|
namespace spr = sprite_resource;
|
|
|
namespace shr = shader_resource;
|
|
|
namespace sar = sprite_animation_resource;
|
|
|
+ namespace cor = config_resource;
|
|
|
|
|
|
register_resource_compiler(SCRIPT_TYPE, SCRIPT_VERSION, lur::compile);
|
|
|
register_resource_compiler(TEXTURE_TYPE, TEXTURE_VERSION, txr::compile);
|
|
|
@@ -66,9 +69,15 @@ BundleCompiler::BundleCompiler(const char* source_dir, const char* bundle_dir)
|
|
|
register_resource_compiler(LEVEL_TYPE, LEVEL_VERSION, lvr::compile);
|
|
|
register_resource_compiler(SHADER_TYPE, SHADER_VERSION, shr::compile);
|
|
|
register_resource_compiler(SPRITE_ANIMATION_TYPE, SPRITE_ANIMATION_VERSION, sar::compile);
|
|
|
+ register_resource_compiler(CONFIG_TYPE, CONFIG_VERSION, cor::compile);
|
|
|
|
|
|
DiskFilesystem temp;
|
|
|
temp.create_directory(bundle_dir);
|
|
|
+
|
|
|
+ scan_source_dir("");
|
|
|
+
|
|
|
+ if (!_bundle_fs.exists(CROWN_DATA_DIRECTORY))
|
|
|
+ _bundle_fs.create_directory(CROWN_DATA_DIRECTORY);
|
|
|
}
|
|
|
|
|
|
bool BundleCompiler::compile(const char* type, const char* name, const char* platform)
|
|
|
@@ -120,38 +129,18 @@ bool BundleCompiler::compile(const char* type, const char* name, const char* pla
|
|
|
|
|
|
bool BundleCompiler::compile_all(const char* platform)
|
|
|
{
|
|
|
- Vector<DynamicString> files(default_allocator());
|
|
|
- BundleCompiler::scan("", files);
|
|
|
-
|
|
|
- if (!_source_fs.is_file("crown.config"))
|
|
|
+ for (uint32_t i = 0; i < vector::size(_files); ++i)
|
|
|
{
|
|
|
- CE_LOGD("'crown.config' does not exist.");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- File* src = _source_fs.open("crown.config", FOM_READ);
|
|
|
- File* dst = _bundle_fs.open("crown.config", FOM_WRITE);
|
|
|
- src->copy_to(*dst, src->size());
|
|
|
- _source_fs.close(src);
|
|
|
- _bundle_fs.close(dst);
|
|
|
-
|
|
|
- if (!_bundle_fs.exists(CROWN_DATA_DIRECTORY))
|
|
|
- _bundle_fs.create_directory(CROWN_DATA_DIRECTORY);
|
|
|
-
|
|
|
- // Compile all resources
|
|
|
- for (uint32_t i = 0; i < vector::size(files); i++)
|
|
|
- {
|
|
|
- if (files[i].ends_with(".tga")
|
|
|
- || files[i].ends_with(".dds")
|
|
|
- || files[i].ends_with(".sh")
|
|
|
- || files[i].ends_with(".sc")
|
|
|
- || files[i].starts_with(".")
|
|
|
- || files[i].ends_with(".config")
|
|
|
- || files[i].ends_with(".tmp")
|
|
|
- || files[i].ends_with(".wav"))
|
|
|
+ if (_files[i].ends_with(".tga")
|
|
|
+ || _files[i].ends_with(".dds")
|
|
|
+ || _files[i].ends_with(".sh")
|
|
|
+ || _files[i].ends_with(".sc")
|
|
|
+ || _files[i].starts_with(".")
|
|
|
+ || _files[i].ends_with(".tmp")
|
|
|
+ || _files[i].ends_with(".wav"))
|
|
|
continue;
|
|
|
|
|
|
- const char* filename = files[i].c_str();
|
|
|
+ const char* filename = _files[i].c_str();
|
|
|
const char* type = path::extension(filename);
|
|
|
|
|
|
char name[256];
|
|
|
@@ -193,15 +182,15 @@ uint32_t BundleCompiler::version(StringId64 type)
|
|
|
return sort_map::get(_compilers, type, ResourceTypeData()).version;
|
|
|
}
|
|
|
|
|
|
-void BundleCompiler::scan(const char* cur_dir, Vector<DynamicString>& files)
|
|
|
+void BundleCompiler::scan_source_dir(const char* cur_dir)
|
|
|
{
|
|
|
Vector<DynamicString> my_files(default_allocator());
|
|
|
-
|
|
|
_source_fs.list_files(cur_dir, my_files);
|
|
|
|
|
|
- for (uint32_t i = 0; i < vector::size(my_files); i++)
|
|
|
+ for (uint32_t i = 0; i < vector::size(my_files); ++i)
|
|
|
{
|
|
|
- DynamicString file_i(default_allocator());
|
|
|
+ TempAllocator512 ta;
|
|
|
+ DynamicString file_i(ta);
|
|
|
|
|
|
if (strcmp(cur_dir, "") != 0)
|
|
|
{
|
|
|
@@ -212,11 +201,11 @@ void BundleCompiler::scan(const char* cur_dir, Vector<DynamicString>& files)
|
|
|
|
|
|
if (_source_fs.is_directory(file_i.c_str()))
|
|
|
{
|
|
|
- BundleCompiler::scan(file_i.c_str(), files);
|
|
|
+ BundleCompiler::scan_source_dir(file_i.c_str());
|
|
|
}
|
|
|
else // Assume a regular file
|
|
|
{
|
|
|
- vector::push_back(files, file_i);
|
|
|
+ vector::push_back(_files, file_i);
|
|
|
}
|
|
|
}
|
|
|
}
|