MCPcopy Create free account
hub / github.com/crownengine/crown / compile_internal

Method compile_internal

src/resource/data_compiler.cpp:983–1480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

981}
982
983bool DataCompiler::compile_internal(const char *data_dir, const char *platform_name)
984{
985 s64 time_start = time::now();
986
987 Platform::Enum platform = Platform::COUNT;
988 for (u32 ii = 0; ii < countof(platform_info); ++ii) {
989 if (strcmp(platform_info[ii].name, platform_name) == 0)
990 platform = platform_info[ii].type;
991 }
992
993 if (platform == Platform::COUNT) {
994 loge(DATA_COMPILER, "Cannot compile data for unknown platform `%s`", platform_name);
995 return false;
996 }
997
998 if (_options->_server) {
999 // Wait for all pending file changes up to .datafence creation are received.
1000 _datafence_mutex.lock();
1001 _datafence_created = false;
1002 _datafence_mutex.unlock();
1003
1004 DynamicString empty(default_allocator());
1005 _source_fs.set_prefix(hash_map::get(_source_dirs, empty, empty).c_str());
1006 File *fence = _source_fs.open(CROWN_DATAFENCE, FileOpenMode::WRITE);
1007 if (fence == NULL) {
1008 loge(DATA_COMPILER, "Cannot create %s", CROWN_DATAFENCE);
1009 return false;
1010 } else {
1011 _source_fs.close(*fence);
1012 }
1013
1014 u32 wait_ms = 1000;
1015 _datafence_mutex.lock();
1016 while (_datafence_created != true && wait_ms != 0) {
1017 s64 t0 = time::now();
1018 _datafence_condition.wait(_datafence_mutex, wait_ms);
1019 u32 elapsed_ms = u32(time::seconds(time::now() - t0) * 1000.0);
1020 if (wait_ms >= elapsed_ms)
1021 wait_ms -= elapsed_ms;
1022 else
1023 wait_ms = 0;
1024 }
1025
1026 _source_fs.delete_file(CROWN_DATAFENCE);
1027
1028 if (_datafence_created == false) {
1029 loge(DATA_COMPILER, "Fence timeout");
1030 _datafence_mutex.unlock();
1031 return false;
1032 }
1033 _datafence_created = false;
1034 _datafence_mutex.unlock();
1035 }
1036
1037 FilesystemDisk data_fs(default_allocator());
1038 data_fs.set_prefix(data_dir);
1039
1040 // Create the data directory on disk.

Callers

nothing calls this directly

Calls 15

nowFunction · 0.85
strcmpFunction · 0.85
getFunction · 0.85
secondsFunction · 0.85
resource_idFunction · 0.85
destination_pathFunction · 0.85
setClass · 0.85
wildcmpFunction · 0.85
stream_destination_pathFunction · 0.85
write_data_indexFunction · 0.85
write_data_mtimesFunction · 0.85
write_data_dependenciesFunction · 0.85

Tested by

no test coverage detected