From 019a69ace95d13e6198be13c7bc7aee681cd8f62 Mon Sep 17 00:00:00 2001 From: wrenge Date: Fri, 3 Feb 2023 11:28:54 +0300 Subject: [PATCH] Added meta manual generation --- composer.json | 3 ++- src/codegen.inc.php | 31 +++++++++++++++++++---------- tpl/codegen_ecs_authoring_meta.twig | 0 3 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 tpl/codegen_ecs_authoring_meta.twig diff --git a/composer.json b/composer.json index 96878bd..df61f9c 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,8 @@ "twig/twig" : "v3.4.3", "bit/metagen" : "^v2.0.2", "bit/metagen_cs" : "^v1.0.5", - "bit/taskman_helpers" : "^v1.0.6" + "bit/taskman_helpers" : "^v1.0.6", + "ramsey/uuid" : "^v3" }, "autoload": { "files": [ diff --git a/src/codegen.inc.php b/src/codegen.inc.php index 44e723c..f3ef85c 100644 --- a/src/codegen.inc.php +++ b/src/codegen.inc.php @@ -1,6 +1,8 @@ object->getName(); $filePath = str_replace(".", "/", $unit_name); $file = "$gen_root/{$filePath}AuthoringComponent.cs"; + $fileMeta = "$gen_root/{$filePath}AuthoringComponent.cs.meta"; $name_components = explode('.', $unit_name); $class_name = end($name_components); if($class_name != $unit_name) @@ -105,17 +108,23 @@ function generate_ecs_components(\mtgMetaInfo $meta) if(empty($namespace)) $namespace = "ecs"; - if($unit->object->hasToken('ecs_gen_authoring')) - { - \taskman\ensure_write_if_differs( - $file, - $twig->render('codegen_ecs_authoring.twig', [ - 'namespace' => $namespace, - 'class_name' => $class_name, - 'obj' => $unit->object - ]) - ); - } + \taskman\ensure_write_if_differs( + $file, + $twig->render('codegen_ecs_authoring.twig', [ + 'namespace' => $namespace, + 'class_name' => $class_name, + 'obj' => $unit->object + ]) + ); + + $uuid = Uuid::uuid3(Uuid::NAMESPACE_URL, $file); + $guid = bin2hex($uuid->getBytes()); + \taskman\ensure_write_if_differs( + $fileMeta, + $twig->render('codegen_ecs_authoring_meta.twig', [ + 'guid' => $guid, + ]) + ); } } diff --git a/tpl/codegen_ecs_authoring_meta.twig b/tpl/codegen_ecs_authoring_meta.twig new file mode 100644 index 0000000..e69de29