@@ -329,6 +329,7 @@ def getTestFile(self):
329329class BootstrapToolchainLauncherProject (mx .Project ): # pylint: disable=too-many-ancestors
330330 def __init__ (self , suite , name , deps , workingSets , theLicense , ** kwArgs ):
331331 super (BootstrapToolchainLauncherProject , self ).__init__ (suite , name , srcDirs = [], deps = deps , workingSets = workingSets , d = suite .dir , theLicense = theLicense , ** kwArgs )
332+ self .buildDependencies += ['mx:GCC_NINJA_TOOLCHAIN' ]
332333
333334 def launchers (self ):
334335 for tool in self .suite .toolchain ._supported_tools ():
@@ -338,9 +339,16 @@ def launchers(self):
338339 result = os .path .join (self .get_output_root (), exe )
339340 yield result , tool , exe
340341
342+ def ninja_toolchain_path (self ):
343+ return os .path .join (self .get_output_root (), 'toolchain.ninja' )
344+
341345 def getArchivableResults (self , use_relpath = True , single = False ):
346+ if single :
347+ raise ValueError ("Cannot produce single result for BootstrapToolchainLauncherProject" )
342348 for result , _ , exe in self .launchers ():
343349 yield result , os .path .join ('bin' , exe )
350+ toolchain_path = self .ninja_toolchain_path ()
351+ yield toolchain_path , os .path .basename (toolchain_path )
344352
345353 def getBuildTask (self , args ):
346354 return BootstrapToolchainLauncherBuildTask (self , args , 1 )
@@ -388,6 +396,8 @@ def build(self):
388396 with open (result , "w" ) as f :
389397 f .write (self .contents (tool , exe ))
390398 os .chmod (result , 0o755 )
399+ with open (self .subject .ninja_toolchain_path (), "w" ) as f :
400+ f .write (self .ninja_toolchain_contents ())
391401
392402 def clean (self , forBuild = False ):
393403 if os .path .exists (self .subject .get_output_root ()):
@@ -415,6 +425,20 @@ def contents(self, tool, exe):
415425 else :
416426 return "#!/usr/bin/env bash\n " + "exec " + " " .join (command ) + "\n "
417427
428+ def ninja_toolchain_contents (self ):
429+ gcc_ninja_toolchain = mx .distribution ('mx:GCC_NINJA_TOOLCHAIN' )
430+ assert isinstance (gcc_ninja_toolchain , mx .AbstractDistribution ) and gcc_ninja_toolchain .get_output ()
431+ return """# Ninja rules for the LLVM toolchain
432+ include {gcc_toolchain}
433+ CC = {CC}
434+ CXX = {CXX}
435+ AR = {AR}
436+
437+ """ .format (gcc_toolchain = os .path .join (gcc_ninja_toolchain .get_output (), 'toolchain.ninja' ),
438+ CC = self .subject .suite .toolchain .get_toolchain_tool ('CC' ),
439+ CXX = self .subject .suite .toolchain .get_toolchain_tool ('CXX' ),
440+ AR = self .subject .suite .toolchain .get_toolchain_tool ('AR' ))
441+
418442
419443class AbstractSulongNativeProject (mx .NativeProject ): # pylint: disable=too-many-ancestors
420444 def __init__ (self , suite , name , deps , workingSets , subDir , results = None , output = None , ** args ):
0 commit comments