-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbam.lua
176 lines (154 loc) · 5.33 KB
/
bam.lua
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
----------------------------------------------------------------------------
--
-- BAM Manual : https://matricks.github.io/bam/bam.html
--
-- DEBUGGING:
-- require("LuaPanda").start()
-----------------------------------------------------------------------------
--
-- Setup the Muhkuh build system.
--
local atEnv = require 'mbs'
----------------------------------------------------------------------------------------------------------------------
--
-- Create all environments.
--
-- FIXME: The MBS2 system should read this from a setup file.
atEnv.DEFAULT.atVars.PROJECT_VERSION = { "1", "4", "0" }
------------------------------------------------------------------------------
--
-- Build the artifacts of crypto_base, test_crypto_personalisation,
--
-- FIXME: The MBS2 system should read the group and module from a setup file.
-- FIXME: An environment should have something like "PROJECT_VERSION_PRETTY"
-- with a string representation of the project version.
local atArtifacts =
{
strRepositoryPath = 'targets/jonchki/repository',
{
strGroup = 'org.muhkuh.lua',
strModule = 'data_provider_pt',
strArtifact = 'data_provider_pt',
strProject_version = table.concat(atEnv.DEFAULT.atVars.PROJECT_VERSION,'.'),
archive = {
structure = {
['lua'] = {
'lua/data_provider_pt.lua'
},
['lua/data_provider_pt'] = {
'lua/data_provider_pt/download_base.lua',
'lua/data_provider_pt/plugin_base.lua',
'lua/data_provider_pt/sdram_parameter_file.lua'
},
['lua/data_provider_pt/plugins'] = {
'lua/data_provider_pt/plugins/download_firmware_image_v1.lua',
'lua/data_provider_pt/plugins/download_sdram_parameter_v1.lua',
'lua/data_provider_pt/plugins/download_secmem_definition_v1.lua',
'lua/data_provider_pt/plugins/download_spi_macro_v1.lua',
'lua/data_provider_pt/plugins/local_firmware_image_v1.lua',
'lua/data_provider_pt/plugins/local_sdram_parameter_v1.lua',
'lua/data_provider_pt/plugins/local_secmem_definition_v1.lua',
'lua/data_provider_pt/plugins/local_spi_macro_v1.lua'
},
'installer/org.muhkuh.lua-data_provider_pt/install.lua'
},
extensions = {'tar', 'xz'},
format = 'tar',
filter = {'xz'}
},
templates = {
artifact_configuration = 'installer/org.muhkuh.lua-data_provider_pt/data_provider_pt.xml',
pom = 'installer/org.muhkuh.lua-data_provider_pt/pom.xml'
},
tHash_ID = {'md5','sha1','sha224','sha256','sha384','sha512'}
}
}
-----------------------------------------------------------------------------
-- FIXME: Create a builder from the code below.
-- FIXME: Changing the POM template does not trigger a rebuild of the output file.
-- FIXME: Changing the XML template does not trigger a rebuild of the output file.
-- FIXME: The POM file does not need a template file. It can be generated completely in the builder.
local strHash_template = '${ID_UC}:${HASH}\n' -- the builder hash use given Replacements!
local strRepositoryPath = atArtifacts.strRepositoryPath
local atGeneratedFiles = {}
local path = require 'pl.path'
local stringx = require 'pl.stringx'
for _, tArtifactCfg in ipairs(atArtifacts) do
-- Get the artifact ID and version.
local strArtifact = tArtifactCfg.strArtifact
local strProjectVersion = tArtifactCfg.strProject_version
-- Get the list of hash IDs to generate.
local tHashIDs = tArtifactCfg.tHash_ID
-- Get the group as a path.
local strGroupPath = path.join(
table.unpack(
stringx.split(tArtifactCfg.strGroup,'.')
)
)
-- Build the output path for all files.
local strArtifactPath = path.join(
strRepositoryPath,
strGroupPath,
tArtifactCfg.strModule,
tArtifactCfg.strProject_version
)
-- Get a shortcut to the archive settings.
local tArchiveCfg = tArtifactCfg.archive
-- Build the archive
local strArchiveOutputPath = path.join(
strArtifactPath,
string.format(
'%s-%s',
strArtifact,
strProjectVersion
) .. '.' .. table.concat(tArchiveCfg.extensions,'.')
)
local tArtifact = atEnv.DEFAULT:Archive(
strArchiveOutputPath,
tArchiveCfg.format,
tArchiveCfg.filter,
tArchiveCfg.structure
)
table.insert(atGeneratedFiles, tArtifact)
-- Build hash of archive
local tArtifactHash = atEnv.DEFAULT:Hash(
string.format('%s.hash', tArtifact),
tArtifact,
tHashIDs,
strHash_template
)
table.insert(atGeneratedFiles, tArtifactHash)
local strConfigurationOutputPath = path.join(
strArtifactPath,
string.format(
'%s-%s.xml',
strArtifact,
strProjectVersion
)
)
local tConfiguration = atEnv.DEFAULT:VersionTemplate(
strConfigurationOutputPath,
tArtifactCfg.templates.artifact_configuration
)
table.insert(atGeneratedFiles, tConfiguration)
local tConfigurationHash = atEnv.DEFAULT:Hash(
string.format('%s.hash', tConfiguration),
tConfiguration,
tHashIDs,
strHash_template
)
table.insert(atGeneratedFiles, tConfigurationHash)
local strPomOutputPath = path.join(
strArtifactPath,
string.format(
'%s-%s.pom',
strArtifact,
strProjectVersion
)
)
local tArtifactPom = atEnv.DEFAULT:VersionTemplate(
strPomOutputPath,
tArtifactCfg.templates.artifact_configuration
)
table.insert(atGeneratedFiles, tArtifactPom)
end