4 # Copyright (c) 2017 Vojtech Horky
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
11 # - Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # - Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # - The name of the author may not be used to endorse or promote products
17 # derived from this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 import multiprocessing
37 from hbuild
.scheduler
import BuildScheduler
38 from hbuild
.cvs
import *
39 from hbuild
.builders
.helenos
import *
40 from hbuild
.builders
.coastline
import *
41 from hbuild
.builders
.tests
import *
42 from hbuild
.gendoc
import BrowsableSourcesViaGnuGlobalTask
, DoxygenTask
43 from hbuild
.checkers
.sycek
import SycekBuildTask
, SycekCheckTask
44 from hbuild
.web
import *
45 from hbuild
.output
import ConsolePrinter
46 from hbuild
.toolchain
import check_tool
, check_package
65 def create_checkout_task(name
, url
):
66 if url
.startswith("wip://"):
67 return RsyncCheckoutTask(name
, url
[6:])
69 return GitCheckoutTask(name
, url
)
71 # Command-line options
72 args
= argparse
.ArgumentParser(description
='HelenOS integration build')
73 args
.add_argument('--helenos-repository', default
='https://github.com/HelenOS/helenos.git', dest
='helenos_repository',
75 help='HelenOS repository path'
77 args
.add_argument('--coastline-repository', default
='https://github.com/HelenOS/harbours.git', dest
='coastline_repository',
79 help='Coastline repository path'
81 args
.add_argument('--build-id', default
='0', dest
='build_id',
83 help='Build id (typically sequence number).',
85 args
.add_argument('--rss-url', default
='', dest
='rss_url',
86 metavar
='URL_WITH_RSS',
87 help='URL of RSS for latest builds.'
89 args
.add_argument('--resource-path', default
=None, dest
='web_resource_path',
90 metavar
='RELATIVE_PATH',
91 help='Path where static web resources are stored (when specified, the resources are NOT copied).'
93 args
.add_argument('--build-directory', default
=os
.path
.abspath('tmp'), dest
='build_directory',
95 help='Where to build (space for temporary files).',
97 args
.add_argument('--artefact-directory', default
=os
.path
.abspath('out/'), dest
='artefact_directory',
99 help='Where to place downloadable files and HTML report.'
101 args
.add_argument('--platforms', default
='ALL', dest
='platforms',
102 metavar
='PLATFORM1[,PLATFORM2[,...]',
103 help='Which platforms to build (defaults to all detected ones; can be either machine specific "ia64/ski" or architecture specific "ia64/*").'
105 args
.add_argument('--harbours', default
='ALL', dest
='harbours',
106 metavar
='HARBOUR1[,HARBOUR2[,...]',
107 help='Which harbours to build (defaults to all detected ones).'
109 args
.add_argument('--tests', default
='ALL', dest
='tests',
110 metavar
='TEST1[,TEST2[,...]]',
111 help='Which tests to run (shell wildcards supported).'
113 args
.add_argument('--vm-memory-size', default
=256, dest
='vm_memory_size',
115 metavar
='RAM_SIZE_IN_MB',
116 help='How much memory to give the virtual machine running the tests.'
118 args
.add_argument('--inline-log-lines', default
=10, dest
='inline_log_lines',
121 help='How many lines of log to show on the web page.'
123 args
.add_argument('--archive-format', default
='tar.xz', dest
='archive_format',
124 choices
=['tar.xz', 'tar.gz'],
126 help='Format of the archives (tar.gz or tar.xz).'
128 args
.add_argument('--no-source-browser', default
=True, dest
='code_browser',
129 action
='store_false',
130 help='Do not generate source code browser.'
132 args
.add_argument('--no-style-check', default
=True, dest
='style_check',
133 action
='store_false',
134 help='Do not check C style.'
136 args
.add_argument('--no-doxygen', default
=True, dest
='doxygen',
137 action
='store_false',
138 help='Do not run Doxygen.'
140 args
.add_argument('--no-tool-check', default
=True, dest
='tool_check',
141 action
='store_false',
142 help='Do not check that all tools are installed.'
144 args
.add_argument('--jobs', default
=multiprocessing
.cpu_count(), dest
='jobs',
147 help='Number of concurrent jobs.'
149 args
.add_argument('--no-colors', default
=False, dest
='no_colors',
151 help='Disable colorful output'
153 args
.add_argument('--debug', default
=False, dest
='debug',
155 help='Print debugging messages'
158 config
= args
.parse_args()
159 config
.artefact_directory
= os
.path
.abspath(config
.artefact_directory
)
160 config
.build_directory
= os
.path
.abspath(config
.build_directory
)
161 config
.self_path
= os
.path
.dirname(os
.path
.realpath(sys
.argv
[0]))
163 printer
= ConsolePrinter(config
.no_colors
)
165 if config
.tool_check
:
167 for tool
in REQUIRED_TOOLS
:
168 check_tool(tool
, printer
)
169 for pkg
in REQUIRED_PACKAGES
:
170 check_package(pkg
, printer
)
171 except NotImplementedError:
174 if config
.vm_memory_size
< 8:
175 printer
.print_warning("VM memory size too small, upgrading to 8MB.")
176 config
.vm_memory_size
= 8
178 scheduler
= BuildScheduler(
179 max_workers
=config
.jobs
,
180 build
=config
.build_directory
,
181 artefact
=config
.artefact_directory
,
182 build_id
=config
.build_id
,
184 inline_log_lines
=config
.inline_log_lines
,
189 # Check-out both HelenOS and coastline repositories
190 scheduler
.submit("Checking-out HelenOS",
192 create_checkout_task("helenos", config
.helenos_repository
))
193 scheduler
.submit("Checking-out Coastline",
194 "coastline-checkout",
195 create_checkout_task("coastline", config
.coastline_repository
))
198 # Build browsable sources
199 if config
.code_browser
:
200 scheduler
.submit("Browsable sources",
201 "helenos-browsable-sources",
202 BrowsableSourcesViaGnuGlobalTask(),
203 ["helenos-checkout"])
206 scheduler
.submit("Generate Doxygen documentation",
209 ["helenos-checkout"])
213 if config
.style_check
:
214 scheduler
.submit("Build Sycek C style checker",
219 scheduler
.submit("Check C style with Sycek",
220 "helenos-sycek-check",
222 ["helenos-checkout", "sycek-build"])
225 # HelenOS (mainline): get list of profiles (i.e. supported architectures
226 # and platforms) and build all of them
227 scheduler
.submit("Determininig available profiles",
228 "helenos-get-profiles",
229 HelenOSGetProfilesTask(config
.platforms
.split(',')),
230 ["helenos-checkout"])
233 scheduler
.submit("Schedule HelenOS builds",
235 HelenOSScheduleBuildsTask(scheduler
),
236 ["helenos-get-profiles"])
240 # Coastline: get list of harbours (i.e. ported software) and build all of them
241 # for all HelenOS builds
242 scheduler
.submit("Determining available harbours",
243 "coastline-get-harbours",
244 CoastlineGetHarboursTask(config
.harbours
.split(',')),
245 ["coastline-checkout"])
247 scheduler
.submit("Schedule harbour tarballs fetches",
249 CoastlineScheduleFetchesTask(scheduler
),
250 ["coastline-get-harbours" ])
253 scheduler
.submit("Schedule Coastline builds",
255 CoastlineScheduleBuildsTask(scheduler
, config
.archive_format
),
258 "helenos-get-profiles", "coastline-get-harbours",
260 "helenos-build", "coastline-fetch"
264 extra_builds
= HelenOSExtraBuildsManager(scheduler
)
268 scheduler
.submit("Determine available test scenarios",
270 GetTestListTask(config
.self_path
, config
.tests
.split(',')),
273 scheduler
.submit("Schedule tests",
275 ScheduleTestsTask(scheduler
,
278 [ "--memory={}".format(config
.vm_memory_size
) ]
288 # Wait for all builds (and everything) to complete before creating
289 # the web page with results.
292 scheduler
.close_report()
294 scheduler
.submit("Generate HTML report",
296 MakeHtmlReportTask(config
.self_path
, config
.rss_url
, config
.web_resource_path
))