1414#include < type_traits>
1515#include < vector>
1616
17- #ifndef WORKSPACE_ROOT
18- #error "WORKSPACE_ROOT compile definition must be provided"
17+ #ifndef PROJECT_ROOT
18+ #error "PROJECT_ROOT compile definition must be provided"
1919#endif
2020
2121#ifdef _WIN32
3333#include " ozz/base/maths/soa_transform.h"
3434#include " ozz/base/maths/transform.h"
3535
36+
3637namespace fs = std::filesystem;
3738
3839namespace
3940{
4041
41- fs::path WorkspaceRoot ()
42+ fs::path ProjectRoot ()
4243{
43- static const fs::path root = fs::path (WORKSPACE_ROOT );
44+ static const fs::path root = fs::path (PROJECT_ROOT );
4445 return root;
4546}
4647
4748fs::path TestArtifactsDir ()
4849{
49- return WorkspaceRoot () / " asset_tests" / " test_outputs" ;
50+ return ProjectRoot () / " asset_tests" / " test_outputs" ;
5051}
5152
5253fs::path SkeletonInputPath ()
5354{
54- return WorkspaceRoot () / " xray-16 " / " res" / " testdata" / " stalker_hero_1.ogf" ;
55+ return ProjectRoot () / " res" / " testdata" / " stalker_hero_1.ogf" ;
5556}
5657
5758fs::path AnimationInputPath ()
5859{
59- return WorkspaceRoot () / " xray-16 " / " res" / " testdata" / " critical_hit_grup_1.omf" ;
60+ return ProjectRoot () / " res" / " testdata" / " critical_hit_grup_1.omf" ;
6061}
6162
6263fs::path SkeletonOutputPath ()
@@ -69,6 +70,11 @@ fs::path SkeletonCsvPath()
6970 return TestArtifactsDir () / " stalker_hero_bind_pose.csv" ;
7071}
7172
73+ fs::path BaselineDir ()
74+ {
75+ return ProjectRoot () / " src" / " xrAnimation" / " tests" / " baselines" ;
76+ }
77+
7278fs::path AnimationOutputPath ()
7379{
7480 return TestArtifactsDir () / " critical_hit_grup_1.ozz" ;
@@ -240,15 +246,9 @@ std::string QuoteForShell(const std::string& value)
240246#endif
241247}
242248
243- fs::path ResolveConverterBinary ( )
249+ fs::path ResolveBinary ( const std::string& executable_name )
244250{
245- #ifdef _WIN32
246- const std::string executable_name = " xray_to_ozz_converter.exe" ;
247- #else
248- const std::string executable_name = " xray_to_ozz_converter" ;
249- #endif
250-
251- const fs::path build_bin = WorkspaceRoot () / " xray-16" / " ozz_utils" / " bin" ;
251+ const fs::path build_bin = ProjectRoot () / " ozz_utils" / " bin" ;
252252
253253 const std::array<fs::path, 2 > candidates = {
254254 build_bin / " Debug" / executable_name,
@@ -261,19 +261,37 @@ fs::path ResolveConverterBinary()
261261 }
262262
263263 std::ostringstream oss;
264- oss << " Unable to locate xray_to_ozz_converter binary. Checked:" ;
264+ oss << " Unable to locate binary ' " << executable_name << " ' . Checked:" ;
265265 for (const auto & candidate : candidates)
266266 oss << ' \n ' << " " << candidate.string ();
267267 throw std::runtime_error (oss.str ());
268268}
269269
270- std::string BuildCommand ( const std::vector<std::string>& args )
270+ fs::path ResolveConverterBinary ( )
271271{
272- const fs::path converter = ResolveConverterBinary ();
273- const fs::path converter_dir = converter.parent_path ();
272+ #ifdef _WIN32
273+ return ResolveBinary (" xray_to_ozz_converter.exe" );
274+ #else
275+ return ResolveBinary (" xray_to_ozz_converter" );
276+ #endif
277+ }
278+
279+ fs::path ResolveViewerBinary ()
280+ {
281+ #ifdef _WIN32
282+ return ResolveBinary (" ozz_animation_viewer.exe" );
283+ #else
284+ return ResolveBinary (" ozz_animation_viewer" );
285+ #endif
286+ }
287+
288+ std::string BuildCommand (const fs::path& binary,
289+ const std::vector<std::string>& args)
290+ {
291+ const fs::path binary_dir = binary.parent_path ();
274292
275293#ifdef _WIN32
276- std::string command = QuoteForShell (converter .string ());
294+ std::string command = QuoteForShell (binary .string ());
277295 for (const std::string& arg : args)
278296 {
279297 command.push_back (' ' );
@@ -282,9 +300,9 @@ std::string BuildCommand(const std::vector<std::string>& args)
282300 return command;
283301#else
284302 std::string command = " LD_LIBRARY_PATH=" ;
285- command.append (QuoteForShell (converter_dir .string ()));
303+ command.append (QuoteForShell (binary_dir .string ()));
286304 command.push_back (' ' );
287- command.append (QuoteForShell (converter .string ()));
305+ command.append (QuoteForShell (binary .string ()));
288306 for (const std::string& arg : args)
289307 {
290308 command.push_back (' ' );
@@ -294,9 +312,10 @@ std::string BuildCommand(const std::vector<std::string>& args)
294312#endif
295313}
296314
297- int ExecuteCommand (const std::vector<std::string>& args)
315+ int ExecuteCommand (const fs::path& binary,
316+ const std::vector<std::string>& args)
298317{
299- const std::string command = BuildCommand (args);
318+ const std::string command = BuildCommand (binary, args);
300319 const int result = std::system (command.c_str ());
301320 if (result == -1 )
302321 return -1 ;
@@ -312,6 +331,11 @@ int ExecuteCommand(const std::vector<std::string>& args)
312331#endif
313332}
314333
334+ int ExecuteConverterCommand (const std::vector<std::string>& args)
335+ {
336+ return ExecuteCommand (ResolveConverterBinary (), args);
337+ }
338+
315339bool ConvertSkeleton (bool force)
316340{
317341 const fs::path output_dir = TestArtifactsDir ();
@@ -333,7 +357,7 @@ bool ConvertSkeleton(bool force)
333357 " --dump-bind" ,
334358 SkeletonCsvPath ().string ()};
335359
336- const int exit_code = ExecuteCommand (args);
360+ const int exit_code = ExecuteConverterCommand (args);
337361 if (exit_code != 0 )
338362 {
339363 std::cerr << " xray_to_ozz_converter returned exit code " << exit_code << std::endl;
@@ -378,7 +402,7 @@ bool ConvertAnimation(bool force)
378402 " --metadata" ,
379403 AnimationMetadataPath ().string ()};
380404
381- const int exit_code = ExecuteCommand (args);
405+ const int exit_code = ExecuteConverterCommand (args);
382406 if (exit_code != 0 )
383407 {
384408 std::cerr << " animation conversion failed with exit code " << exit_code << std::endl;
@@ -411,7 +435,7 @@ bool ConvertSpecificMotion(const std::string& motion_name, bool force)
411435 " --motion" ,
412436 motion_name};
413437
414- const int exit_code = ExecuteCommand (args);
438+ const int exit_code = ExecuteConverterCommand (args);
415439 if (exit_code != 0 )
416440 {
417441 std::cerr << " animation conversion for motion '" << motion_name
0 commit comments