@@ -12,35 +12,47 @@ Import("env")
1212env .add_source_files (env .core_sources , "*.cpp" )
1313
1414
15- def get_profiler_and_path_from_path (path : pathlib .Path ) -> tuple [ str , pathlib .Path ] :
15+ def find_perfetto_path (path : pathlib .Path ) -> pathlib .Path :
1616 if not path .is_dir ():
1717 print ("profiler_path must be empty or point to a directory." )
1818 Exit (255 )
1919
2020 if (path / "sdk" / "perfetto.cc" ).is_file ():
2121 # perfetto root directory.
22- return "perfetto" , path / "sdk"
22+ return path / "sdk"
2323 if (path / "perfetto.cc" ).is_file ():
2424 # perfetto sdk directory.
25- return "perfetto" , path
25+ return path
26+
27+ print ("Invalid profiler_path. Unable to find perfetto.cc." )
28+ Exit (255 )
29+
30+
31+ def find_tracy_path (path : pathlib .Path ) -> pathlib .Path :
32+ if not path .is_dir ():
33+ print ("profiler_path must point to a directory." )
34+ Exit (255 )
2635
2736 if (path / "public" / "TracyClient.cpp" ).is_file ():
2837 # tracy root directory
29- return "tracy" , path / "public"
38+ return path / "public"
3039 if (path / "TracyClient.cpp" ).is_file ():
3140 # tracy public directory
32- return "tracy" , path
41+ return path
3342
34- print ("Unrecognized profiler_path option. Please set a path to either tracy or perfetto ." )
43+ print ("Invalid profiler_path. Unable to find TracyClient.cpp ." )
3544 Exit (255 )
3645
3746
38- env ["profiler" ] = None
39- if env ["profiler_path" ]:
40- profiler_name , profiler_path = get_profiler_and_path_from_path (pathlib .Path (env ["profiler_path" ]))
41- env ["profiler" ] = profiler_name
42-
43- if profiler_name == "tracy" :
47+ if env ["profiler" ]:
48+ if env ["profiler" ] == "instruments" :
49+ # Nothing else to do for Instruments.
50+ pass
51+ elif env ["profiler" ] == "tracy" :
52+ if not env ["profiler_path" ]:
53+ print ("profiler_path must be set when using the tracy profiler. Aborting." )
54+ Exit (255 )
55+ profiler_path = find_tracy_path (pathlib .Path (env ["profiler_path" ]))
4456 env .Prepend (CPPPATH = [str (profiler_path .absolute ())])
4557
4658 env_tracy = env .Clone ()
@@ -55,7 +67,11 @@ if env["profiler_path"]:
5567 env_tracy .Append (CPPDEFINES = [("TRACY_CALLSTACK" , 62 )])
5668 env_tracy .disable_warnings ()
5769 env_tracy .add_source_files (env .core_sources , str ((profiler_path / "TracyClient.cpp" ).absolute ()))
58- elif profiler_name == "perfetto" :
70+ elif env ["profiler" ] == "perfetto" :
71+ if not env ["profiler_path" ]:
72+ print ("profiler_path must be set when using the perfetto profiler. Aborting." )
73+ Exit (255 )
74+ profiler_path = find_perfetto_path (pathlib .Path (env ["profiler_path" ]))
5975 env .Prepend (CPPPATH = [str (profiler_path .absolute ())])
6076
6177 env_perfetto = env .Clone ()
@@ -65,6 +81,8 @@ if env["profiler_path"]:
6581 env_perfetto .disable_warnings ()
6682 env_perfetto .Prepend (CPPPATH = [str (profiler_path .absolute ())])
6783 env_perfetto .add_source_files (env .core_sources , str ((profiler_path / "perfetto.cc" ).absolute ()))
68-
84+ elif env ["profiler_path" ]:
85+ print ("profiler is required if profiler_path is set. Aborting." )
86+ Exit (255 )
6987
7088env .CommandNoCache ("profiling.gen.h" , [env .Value (env ["profiler" ])], env .Run (profiling_builders .profiler_gen_builder ))
0 commit comments