forked from sifive/freedom-metal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.wake
139 lines (120 loc) · 5.99 KB
/
build.wake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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