44
55
66def run (
7+ use_oneapi = True ,
78 c_compiler = None ,
89 cxx_compiler = None ,
10+ compiler_root = None ,
911 bin_llvm = None ,
1012 pytest_opts = "" ,
13+ verbose = False ,
1114):
1215 IS_LIN = False
1316
@@ -29,11 +32,10 @@ def run(
2932 sys .executable ,
3033 "setup.py" ,
3134 "develop" ,
32- "-G =Ninja" ,
35+ "--generator =Ninja" ,
3336 "--" ,
3437 "-DCMAKE_C_COMPILER:PATH=" + c_compiler ,
3538 "-DCMAKE_CXX_COMPILER:PATH=" + cxx_compiler ,
36- "-DCMAKE_VERBOSE_MAKEFILE=ON" ,
3739 "-DDPNP_GENERATE_COVERAGE=ON" ,
3840 ]
3941
@@ -47,6 +49,11 @@ def run(
4749 # extend with global enviroment variables
4850 env .update ({k : v for k , v in os .environ .items () if k != "PATH" })
4951
52+ if verbose :
53+ cmake_args += [
54+ "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON" ,
55+ ]
56+
5057 subprocess .check_call (cmake_args , shell = False , cwd = setup_dir , env = env )
5158
5259 env ["LLVM_PROFILE_FILE" ] = "dpnp_pytest.profraw"
@@ -125,25 +132,74 @@ def find_objects():
125132 description = "Driver to build dpnp and generate coverage"
126133 )
127134 driver = parser .add_argument_group (title = "Coverage driver arguments" )
135+ driver .add_argument ("--c-compiler" , help = "Name of C compiler" , default = None )
136+ driver .add_argument (
137+ "--cxx-compiler" , help = "Name of C++ compiler" , default = None
138+ )
139+ driver .add_argument (
140+ "--not-oneapi" ,
141+ help = "Is one-API installation" ,
142+ dest = "oneapi" ,
143+ action = "store_false" ,
144+ )
145+ driver .add_argument (
146+ "--compiler-root" , type = str , help = "Path to compiler home directory"
147+ )
148+ driver .add_argument (
149+ "--bin-llvm" , help = "Path to folder where llvm-cov can be found"
150+ )
128151 driver .add_argument (
129152 "--pytest-opts" ,
130153 help = "Channels through additional pytest options" ,
131154 dest = "pytest_opts" ,
132155 default = "" ,
133156 type = str ,
134157 )
135-
158+ driver .add_argument (
159+ "--verbose" ,
160+ help = "Build using vebose makefile mode" ,
161+ dest = "verbose" ,
162+ action = "store_true" ,
163+ )
136164 args = parser .parse_args ()
137165
138- c_compiler = "icx"
139- cxx_compiler = "icpx"
140- icx_path = subprocess .check_output (["which" , "icx" ])
141- bin_dir = os .path .dirname (os .path .dirname (icx_path ))
142- bin_llvm = os .path .join (bin_dir .decode ("utf-8" ), "bin-llvm" )
166+ if args .oneapi :
167+ args .c_compiler = "icx"
168+ args .cxx_compiler = "icpx"
169+ args .compiler_root = None
170+ icx_path = subprocess .check_output (["which" , "icx" ])
171+ bin_dir = os .path .dirname (icx_path )
172+ compiler_dir = os .path .join (bin_dir .decode ("utf-8" ), "compiler" )
173+ if os .path .exists (compiler_dir ):
174+ args .bin_llvm = os .path .join (bin_dir .decode ("utf-8" ), "compiler" )
175+ else :
176+ bin_dir = os .path .dirname (bin_dir )
177+ args .bin_llvm = os .path .join (bin_dir .decode ("utf-8" ), "bin-llvm" )
178+ assert os .path .exists (args .bin_llvm )
179+ else :
180+ args_to_validate = [
181+ "c_compiler" ,
182+ "cxx_compiler" ,
183+ "compiler_root" ,
184+ "bin_llvm" ,
185+ ]
186+ for p in args_to_validate :
187+ arg = getattr (args , p , None )
188+ if not isinstance (arg , str ):
189+ opt_name = p .replace ("_" , "-" )
190+ raise RuntimeError (
191+ f"Option { opt_name } must be provided is "
192+ "using non-default DPC++ layout"
193+ )
194+ if not os .path .exists (arg ):
195+ raise RuntimeError (f"Path { arg } must exist" )
143196
144197 run (
145- c_compiler = c_compiler ,
146- cxx_compiler = cxx_compiler ,
147- bin_llvm = bin_llvm ,
198+ use_oneapi = args .oneapi ,
199+ c_compiler = args .c_compiler ,
200+ cxx_compiler = args .cxx_compiler ,
201+ compiler_root = args .compiler_root ,
202+ bin_llvm = args .bin_llvm ,
148203 pytest_opts = args .pytest_opts ,
204+ verbose = args .verbose ,
149205 )
0 commit comments