Skip to content

Commit 6b72e50

Browse files
committed
asset pipeline skeleton
1 parent 2df6474 commit 6b72e50

5 files changed

Lines changed: 37 additions & 5 deletions

File tree

grngame/bindings/da_script_engine.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "grngame/dev/logging.h"
44
#include "grngame/platform/directories.h"
55
#include <cstdio>
6+
#include <filesystem>
67

78
DaScriptEngine::DaScriptEngine() : file_access(das::make_smart<das::FsFileAccess>())
89
{
@@ -20,7 +21,14 @@ DaScriptEngine::~DaScriptEngine()
2021

2122
bool DaScriptEngine::CompileScript(const char *script_name)
2223
{
23-
auto program = das::compileDaScript(script_name, file_access, text_printer, module_group, policies);
24+
if (contexts.find(script_name) != contexts.end())
25+
{
26+
LOG_ERROR("Tried to compile script '%s' which was already compiled", script_name);
27+
return false;
28+
}
29+
30+
auto script_path = std::filesystem::path(DirOfExecutable()) / "scripts" / (std::string(script_name) + ".das");
31+
auto program = das::compileDaScript(script_path, file_access, text_printer, module_group, policies);
2432
if (program->failed())
2533
{
2634
LOG_ERROR("Failed to compile daScript file '%s':\n", script_name);
@@ -32,11 +40,13 @@ bool DaScriptEngine::CompileScript(const char *script_name)
3240

3341
if (!program->simulate(*contexts[script_name], text_printer))
3442
{
35-
LOG_ERROR("Failed to simulate script '%s':\n", script_name);
43+
LOG_ERROR("Failed to simulate script '%s':", script_name);
3644
LogErrorsOfProgram(program);
3745
return false;
3846
}
3947

48+
LOG_INFO("Sucesfully compiled script '%s'", script_name);
49+
4050
return true;
4151
}
4252

grngame/core/app.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ void EngineStart(AppInfo* app_info)
7676
AssetManagerLoadFolder(relative_asset_folder);
7777
free(relative_asset_folder);
7878

79-
if (!DaScriptEngineCompileScript(g_app.da_script_engine, "hello.das"))
79+
if (!DaScriptEngineCompileScript(g_app.da_script_engine, "main"))
8080
exit(7);
8181

82-
if (!DaScriptEngineRunScript(g_app.da_script_engine, "hello.das", "main"))
82+
if (!DaScriptEngineRunScript(g_app.da_script_engine, "main", "main"))
8383
exit(8);
8484

8585
MainLoop();

scripts/asset_pipeline.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import sys
2+
import os
3+
import shutil
4+
5+
def bundle_assets(dir_from: str, dir_to: str) -> None:
6+
shutil.copytree(dir_from, dir_to, dirs_exist_ok=True,
7+
copy_function=shutil.copy2)
8+
9+
if __name__ == '__main__':
10+
bundle_assets(sys.argv[1], sys.argv[2])

test_game/scripts/main.das

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[export]
2+
def main()
3+
print("tagazok chouffeworld\n")
4+
print("leo fork of godot > grngame\n")

xmake.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,12 @@ target("Tests")
147147
set_kind("binary")
148148
set_runtimes("MT")
149149
add_files("tests/main.c")
150-
add_deps("GrnGame")
150+
add_deps("GrnGame")
151+
152+
after_build(function(target)
153+
os.execv("python3", {
154+
"scripts/asset_pipeline.py",
155+
"test_game",
156+
target:targetdir()
157+
})
158+
end)

0 commit comments

Comments
 (0)