@@ -264,10 +264,10 @@ class Make(BuildSystem):
264264 def emit_build_commands (self , environ ):
265265 cmd_parts = ['make' ]
266266 if self .makefile :
267- cmd_parts += ['-f %s' % self .makefile ]
267+ cmd_parts += [f '-f { self .makefile } ' ]
268268
269269 if self .srcdir :
270- cmd_parts += ['-C %s' % self .srcdir ]
270+ cmd_parts += [f '-C { self .srcdir } ' ]
271271
272272 cmd_parts += ['-j' ]
273273 if self .max_concurrency is not None :
@@ -283,31 +283,36 @@ def emit_build_commands(self, environ):
283283 fflags = self ._fflags (environ )
284284 ldflags = self ._ldflags (environ )
285285 if cc :
286- cmd_parts += ['CC="%s"' % cc ]
286+ cmd_parts += [f 'CC="{ cc } "' ]
287287
288288 if cxx :
289- cmd_parts += ['CXX="%s"' % cxx ]
289+ cmd_parts += [f 'CXX="{ cxx } "' ]
290290
291291 if ftn :
292- cmd_parts += ['FC="%s"' % ftn ]
292+ cmd_parts += [f 'FC="{ ftn } "' ]
293293
294294 if nvcc :
295- cmd_parts += ['NVCC="%s"' % nvcc ]
295+ cmd_parts += [f 'NVCC="{ nvcc } "' ]
296296
297297 if cppflags :
298- cmd_parts += ['CPPFLAGS="%s"' % ' ' .join (cppflags )]
298+ flags = ' ' .join (cppflags )
299+ cmd_parts += [f'CPPFLAGS="{ flags } "' ]
299300
300301 if cflags :
301- cmd_parts += ['CFLAGS="%s"' % ' ' .join (cflags )]
302+ flags = ' ' .join (cflags )
303+ cmd_parts += [f'CFLAGS="{ flags } "' ]
302304
303305 if cxxflags :
304- cmd_parts += ['CXXFLAGS="%s"' % ' ' .join (cxxflags )]
306+ flags = ' ' .join (cxxflags )
307+ cmd_parts += [f'CXXFLAGS="{ flags } "' ]
305308
306309 if fflags :
307- cmd_parts += ['FCFLAGS="%s"' % ' ' .join (fflags )]
310+ flags = ' ' .join (fflags )
311+ cmd_parts += [f'FCFLAGS="{ flags } "' ]
308312
309313 if ldflags :
310- cmd_parts += ['LDFLAGS="%s"' % ' ' .join (ldflags )]
314+ flags = ' ' .join (ldflags )
315+ cmd_parts += [f'LDFLAGS="{ flags } "' ]
311316
312317 if self .options :
313318 cmd_parts += self .options
@@ -384,13 +389,13 @@ class SingleSource(BuildSystem):
384389 lang = variable (str , type (None ), value = None )
385390
386391 def _auto_exec_name (self ):
387- return '%s.x' % os .path .splitext (self .srcfile )[0 ]
392+ return os .path .splitext (self .srcfile )[0 ] + '.x'
388393
389394 def emit_build_commands (self , environ ):
390395 if not self .srcfile :
391- raise BuildSystemError (
392- 'a source file is required when using the %s build system' %
393- type ( self ). __name__ )
396+ bname = type ( self ). __name__
397+ raise BuildSystemError ( f 'a source file is required when using '
398+ f'the { bname !r } build system' )
394399
395400 cc = self ._cc (environ )
396401 cxx = self ._cxx (environ )
@@ -527,11 +532,11 @@ def _combine_flags(self, cppflags, xflags):
527532 def emit_build_commands (self , environ ):
528533 prepare_cmd = []
529534 if self .srcdir :
530- prepare_cmd += ['cd %s' % self .srcdir ]
535+ prepare_cmd += [f 'cd { self .srcdir } ' ]
531536
532537 if self .builddir :
533- prepare_cmd += ['mkdir -p %s' % self .builddir ,
534- 'cd %s' % self .builddir ]
538+ prepare_cmd += [f 'mkdir -p { self .builddir } ' ,
539+ f 'cd { self .builddir } ' ]
535540
536541 cmake_cmd = ['cmake' ]
537542 cc = self ._cc (environ )
@@ -544,28 +549,32 @@ def emit_build_commands(self, environ):
544549 fflags = self ._combine_flags (cppflags , self ._fflags (environ ))
545550 ldflags = self ._ldflags (environ )
546551 if cc :
547- cmake_cmd += ['-DCMAKE_C_COMPILER="%s"' % cc ]
552+ cmake_cmd += [f '-DCMAKE_C_COMPILER="{ cc } "' ]
548553
549554 if cxx :
550- cmake_cmd += ['-DCMAKE_CXX_COMPILER="%s"' % cxx ]
555+ cmake_cmd += [f '-DCMAKE_CXX_COMPILER="{ cxx } "' ]
551556
552557 if ftn :
553- cmake_cmd += ['-DCMAKE_Fortran_COMPILER="%s"' % ftn ]
558+ cmake_cmd += [f '-DCMAKE_Fortran_COMPILER="{ ftn } "' ]
554559
555560 if nvcc :
556- cmake_cmd += ['-DCMAKE_CUDA_COMPILER="%s"' % nvcc ]
561+ cmake_cmd += [f '-DCMAKE_CUDA_COMPILER="{ nvcc } "' ]
557562
558563 if cflags :
559- cmake_cmd += ['-DCMAKE_C_FLAGS="%s"' % ' ' .join (cflags )]
564+ flags = ' ' .join (cflags )
565+ cmake_cmd += [f'-DCMAKE_C_FLAGS="{ flags } "' ]
560566
561567 if cxxflags :
562- cmake_cmd += ['-DCMAKE_CXX_FLAGS="%s"' % ' ' .join (cxxflags )]
568+ flags = ' ' .join (cxxflags )
569+ cmake_cmd += [f'-DCMAKE_CXX_FLAGS="{ flags } "' ]
563570
564571 if fflags :
565- cmake_cmd += ['-DCMAKE_Fortran_FLAGS="%s"' % ' ' .join (fflags )]
572+ flags = ' ' .join (fflags )
573+ cmake_cmd += [f'-DCMAKE_Fortran_FLAGS="{ flags } "' ]
566574
567575 if ldflags :
568- cmake_cmd += ['-DCMAKE_EXE_LINKER_FLAGS="%s"' % ' ' .join (ldflags )]
576+ flags = ' ' .join (ldflags )
577+ cmake_cmd += [f'-DCMAKE_EXE_LINKER_FLAGS="{ flags } "' ]
569578
570579 if self .config_opts :
571580 cmake_cmd += self .config_opts
@@ -609,11 +618,11 @@ class Autotools(ConfigureBasedBuildSystem):
609618 def emit_build_commands (self , environ ):
610619 prepare_cmd = []
611620 if self .srcdir :
612- prepare_cmd += ['cd %s' % self .srcdir ]
621+ prepare_cmd += [f 'cd { self .srcdir } ' ]
613622
614623 if self .builddir :
615- prepare_cmd += ['mkdir -p %s' % self .builddir ,
616- 'cd %s' % self .builddir ]
624+ prepare_cmd += [f 'mkdir -p { self .builddir } ' ,
625+ f 'cd { self .builddir } ' ]
617626
618627 if self .builddir :
619628 configure_cmd = [os .path .join (
@@ -631,28 +640,33 @@ def emit_build_commands(self, environ):
631640 fflags = self ._fflags (environ )
632641 ldflags = self ._ldflags (environ )
633642 if cc :
634- configure_cmd += ['CC="%s"' % cc ]
643+ configure_cmd += [f 'CC="{ cc } "' ]
635644
636645 if cxx :
637- configure_cmd += ['CXX="%s"' % cxx ]
646+ configure_cmd += [f 'CXX="{ cxx } "' ]
638647
639648 if ftn :
640- configure_cmd += ['FC="%s"' % ftn ]
649+ configure_cmd += [f 'FC="{ ftn } "' ]
641650
642651 if cppflags :
643- configure_cmd += ['CPPFLAGS="%s"' % ' ' .join (cppflags )]
652+ flags = ' ' .join (cppflags )
653+ configure_cmd += [f'CPPFLAGS="{ flags } "' ]
644654
645655 if cflags :
646- configure_cmd += ['CFLAGS="%s"' % ' ' .join (cflags )]
656+ flags = ' ' .join (cflags )
657+ configure_cmd += [f'CFLAGS="{ flags } "' ]
647658
648659 if cxxflags :
649- configure_cmd += ['CXXFLAGS="%s"' % ' ' .join (cxxflags )]
660+ flags = ' ' .join (cxxflags )
661+ configure_cmd += [f'CXXFLAGS="{ flags } "' ]
650662
651663 if fflags :
652- configure_cmd += ['FCFLAGS="%s"' % ' ' .join (fflags )]
664+ flags = ' ' .join (fflags )
665+ configure_cmd += [f'FCFLAGS="{ flags } "' ]
653666
654667 if ldflags :
655- configure_cmd += ['LDFLAGS="%s"' % ' ' .join (ldflags )]
668+ flags = ' ' .join (ldflags )
669+ configure_cmd += [f'LDFLAGS="{ flags } "' ]
656670
657671 if self .config_opts :
658672 configure_cmd += self .config_opts
@@ -897,6 +911,29 @@ def prepare_cmds(self):
897911 return cmds
898912
899913
914+ class CustomBuild (BuildSystem ):
915+ '''Custom build system.
916+
917+ This build system backend allows users to use custom build scripts to
918+ build the test code. It does not do any interpretation of the current test
919+ environment and it simply runs the supplied :attr:`commands`.
920+
921+ Users should use this build system with caution, because environment
922+ management, reproducibility and any potential side effects are all
923+ controlled by the user's custom build system.
924+
925+ .. versionadded:: 3.11.0
926+ '''
927+
928+ #: The commands to run for building the test code.
929+ #:
930+ #: :type: :class:`List[str]`
931+ commands = variable (typ .List [str ])
932+
933+ def emit_build_commands (self , environ ):
934+ return self .commands
935+
936+
900937class BuildSystemField (fields .TypedField ):
901938 def __init__ (self , fieldname , * other_types ):
902939 super ().__init__ (fieldname , BuildSystem , * other_types )
@@ -906,6 +943,6 @@ def __set__(self, obj, value):
906943 try :
907944 value = globals ()[value ]()
908945 except KeyError :
909- raise ValueError ('unknown build system: %s' % value ) from None
946+ raise ValueError (f 'unknown build system: { value } ' ) from None
910947
911948 super ().__set__ (obj , value )
0 commit comments