123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- tuple MachineExecutionEnvironment =
- IncludeDir_: String
- LibDir_: String
- LibMetal_: Path
- LibMetalGloss_: Path
- ConfigOptions: FreedomMetalConfigureOptions
- AllOutputs_: List Path
- global def getMachineExecutionEnvironmentLibMetal = getMachineExecutionEnvironmentLibMetal_
- global def getMachineExecutionEnvironmentLibMetalGloss = getMachineExecutionEnvironmentLibMetalGloss_
- global def getMachineExecutionEnvironmentIncludeDir = getMachineExecutionEnvironmentIncludeDir_
- global def getMachineExecutionEnvironmentLibDir = getMachineExecutionEnvironmentLibDir_
- global def getMachineExecutionEnvironmentAllOutputs = getMachineExecutionEnvironmentAllOutputs_
- global def getMachineExecutionEnvironmentRISCV_ARCH = _.getMachineExecutionEnvironmentConfigOptions.getFreedomMetalConfigureOptionsRISCV_ARCH
- global def getMachineExecutionEnvironmentRISCV_ABI = _.getMachineExecutionEnvironmentConfigOptions.getFreedomMetalConfigureOptionsRISCV_ABI
- global def getMachineExecutionEnvironmentRISCV_CMODEL = _.getMachineExecutionEnvironmentConfigOptions.getFreedomMetalConfigureOptionsRISCV_CMODEL
- global def getMachineExecutionEnvironmentHost = _.getMachineExecutionEnvironmentConfigOptions.getFreedomMetalConfigureOptionsHost
- global def getMachineExecutionEnvironmentPrefix = _.getMachineExecutionEnvironmentConfigOptions.getFreedomMetalConfigureOptionsOutputDir
- global def getMachineExecutionEnvironmentName = _.getMachineExecutionEnvironmentConfigOptions.getFreedomMetalConfigureOptionsMachineName
- global def getMachineExecutionEnvironmentHeader = _.getMachineExecutionEnvironmentConfigOptions.getFreedomMetalConfigureOptionsMachineHeader
- global def getMachineExecutionEnvironmentLdScript = _.getMachineExecutionEnvironmentConfigOptions.getFreedomMetalConfigureOptionsMachineLdScript
- def dir / subDir = "{dir.getPathName}/{subDir}"
- tuple FreedomMetalConfigureOptions =
- global Resources: List String
- global RISCV_ARCH: String
- global RISCV_ABI: String
- global RISCV_CMODEL: String
- global Host: String
- global OutputDir: String
- global MachineName: String
- global MachineHeader: Path
- global MachineInlineHeader: Path
- global PlatformHeader: Path
- global MachineLdScript: Path
- global def defaultSiFiveRISCVResources = "riscv-tools/2019.05.0", Nil
- global def makeFreedomMetalConfigureOptions arch abi cmodel host outputDir name header inlineHeader platformHeader ldScript =
- def resources = defaultSiFiveRISCVResources
- FreedomMetalConfigureOptions resources arch abi cmodel host outputDir name header inlineHeader platformHeader ldScript
- global tuple MakeElfOptions =
- global MEE: MachineExecutionEnvironment
- global ProgramSrcs: List Path
- global CFlags: List String
- global LFlags: List String
- global IncludeDirs: List String
- global ElfFile: String
- global def runFreedomMetalInstall options =
- def outputDir = options.getFreedomMetalConfigureOptionsOutputDir
- def meeHeader = options.getFreedomMetalConfigureOptionsMachineHeader
- def meeInline = options.getFreedomMetalConfigureOptionsMachineInlineHeader
- def platformHeader = options.getFreedomMetalConfigureOptionsPlatformHeader
- def meeLdScript = options.getFreedomMetalConfigureOptionsMachineLdScript
- def machineName = options.getFreedomMetalConfigureOptionsMachineName
- def wrapperScript = source "{here}/scripts/autoconf_wrapper"
- def metalInstallDir = outputDir
- def installedFreedomMetal =
- def inputs =
- sources "freedom-metal" `.*`
- | filter (!matches `freedom-metal/doc/.*` _.getPathName)
- def cmdline =
- "rsync",
- "-r",
- "--exclude", "freedom-metal/doc",
- "--exclude", "freedom-metal/.git",
- "--exclude", "*.wake",
- "freedom-metal",
- outputDir,
- Nil
- def fnOutputs _ =
- files "freedom-metal" `.*`
- | filter (!matches `freedom-metal/(\.git|doc)/.*` _)
- | filter (!matches `.*\.(in|am|m4|wake)` _) # exclude these because autoconf modfies them
- | filter (!matches `(.*/)?(configure)` _)
- | map ("{metalInstallDir}/{_}")
- makePlan cmdline inputs
- | setPlanFnOutputs fnOutputs
- | setPlanLocalOnly True
- | runJob
- | getJobOutputs
- def runDir = "{metalInstallDir}/freedom-metal"
- def cmdline =
- relative runDir wrapperScript.getPathName,
- options.getFreedomMetalConfigureOptionsHost,
- machineName,
- relative runDir meeHeader.getPathName,
- relative runDir meeInline.getPathName,
- relative runDir platformHeader.getPathName,
- relative runDir meeLdScript.getPathName,
- relative runDir outputDir,
- Nil
- def inputs = mkdir outputDir, wrapperScript, meeHeader, meeLdScript, installedFreedomMetal
- def foutputs _ =
- files "{outputDir}/include" `.*`
- ++ files "{outputDir}/lib" `.*`
- def withCFlags =
- def march = options.getFreedomMetalConfigureOptionsRISCV_ARCH
- def mabi = options.getFreedomMetalConfigureOptionsRISCV_ABI
- def cmodel = options.getFreedomMetalConfigureOptionsRISCV_CMODEL
- "CFLAGS=-march={march} -mabi={mabi} -g -mcmodel={cmodel}", _
- def makeOutputs =
- makePlan cmdline inputs
- | setPlanLocalOnly True
- | setPlanFnOutputs foutputs
- | setPlanDirectory runDir
- | setPlanResources options.getFreedomMetalConfigureOptionsResources
- | editPlanEnvironment withCFlags
- | runJob
- | getJobOutputs
- def getFile f msg =
- filter (simplify f ==~ _.getPathName) makeOutputs
- | head
- | getOrElse msg.makeError.makeBadPath
- def libmetal =
- def machineName = options.getFreedomMetalConfigureOptionsMachineName
- def fileName = "{outputDir}/lib/libriscv__mmachine__{machineName}.a"
- getFile fileName "Failed to compile libmetal: {fileName}"
- def libmetalGloss =
- def fileName = "{outputDir}/lib/libriscv__menv__metal.a"
- getFile fileName "Failed to compile libGloss: {fileName}"
- def includeDir = "{outputDir}/include"
- def libDir = "{outputDir}/lib"
- MachineExecutionEnvironment includeDir libDir libmetal libmetalGloss options makeOutputs
|