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
.web
import *
43 from hbuild
.output
import ConsolePrinter
45 def create_checkout_task(name
, url
):
46 if url
.startswith("wip://"):
47 return RsyncCheckoutTask(name
, url
[6:])
49 return BzrCheckoutTask(name
, url
)
51 # Command-line options
52 args
= argparse
.ArgumentParser(description
='HelenOS integration build')
53 args
.add_argument('--helenos-repository', default
='bzr://helenos.org/mainline', dest
='helenos_repository',
55 help='HelenOS repository path'
57 args
.add_argument('--coastline-repository', default
='bzr://helenos.org/coastline', dest
='coastline_repository',
59 help='Coastline repository path'
61 args
.add_argument('--build-id', default
='0', dest
='build_id',
63 help='Build id (typically sequence number).',
65 args
.add_argument('--rss-url', default
='', dest
='rss_url',
66 metavar
='URL_WITH_RSS',
67 help='URL of RSS for latest builds.'
69 args
.add_argument('--resource-path', default
=None, dest
='web_resource_path',
70 metavar
='RELATIVE_PATH',
71 help='Path where static web resources are stored (when specified, the resources are NOT copied).'
73 args
.add_argument('--build-directory', default
=os
.path
.abspath('tmp'), dest
='build_directory',
75 help='Where to build (space for temporary files).',
77 args
.add_argument('--artefact-directory', default
=os
.path
.abspath('out/'), dest
='artefact_directory',
79 help='Where to place downloadable files and HTML report.'
81 args
.add_argument('--platforms', default
='ALL', dest
='platforms',
82 metavar
='PLATFORM1[,PLATFORM2[,...]',
83 help='Which platforms to build (defaults to all detected ones; can be either machine specific "ia64/ski" or architecture specific "ia64/*").'
85 args
.add_argument('--harbours', default
='ALL', dest
='harbours',
86 metavar
='HARBOUR1[,HARBOUR2[,...]',
87 help='Which harbours to build (defaults to all detected ones).'
89 args
.add_argument('--tests', default
='ALL', dest
='tests',
90 metavar
='TEST1[,TEST2[,...]]',
91 help='Which tests to run (shell wildcards supported).'
93 args
.add_argument('--vm-memory-size', default
=256, dest
='vm_memory_size',
95 metavar
='RAM_SIZE_IN_MB',
96 help='How much memory to give the virtual machine running the tests.'
98 args
.add_argument('--archive-format', default
='tar.xz', dest
='archive_format',
99 choices
=['tar.xz', 'tar.gz'],
101 help='Format of the archives (tar.gz or tar.xz).'
103 args
.add_argument('--jobs', default
=multiprocessing
.cpu_count(), dest
='jobs',
106 help='Number of concurrent jobs.'
108 args
.add_argument('--no-colors', default
=False, dest
='no_colors',
110 help='Disable colorful output'
112 args
.add_argument('--debug', default
=False, dest
='debug',
114 help='Print debugging messages'
117 config
= args
.parse_args()
118 config
.artefact_directory
= os
.path
.abspath(config
.artefact_directory
)
119 config
.build_directory
= os
.path
.abspath(config
.build_directory
)
120 config
.self_path
= os
.path
.dirname(os
.path
.realpath(sys
.argv
[0]))
122 printer
= ConsolePrinter(config
.no_colors
)
124 if config
.vm_memory_size
< 8:
125 printer
.print_warning("VM memory size too small, upgrading to 8MB.")
126 config
.vm_memory_size
= 8
128 scheduler
= BuildScheduler(
129 max_workers
=config
.jobs
,
130 build
=config
.build_directory
,
131 artefact
=config
.artefact_directory
,
132 build_id
=config
.build_id
,
138 # Check-out both HelenOS and coastline repositories
139 scheduler
.submit("Checking-out HelenOS",
141 create_checkout_task("helenos", config
.helenos_repository
))
142 scheduler
.submit("Checking-out Coastline",
143 "coastline-checkout",
144 create_checkout_task("coastline", config
.coastline_repository
))
147 # HelenOS (mainline): get list of profiles (i.e. supported architectures
148 # and platforms) and build all of them
149 scheduler
.submit("Determininig available profiles",
150 "helenos-get-profiles",
151 HelenOSGetProfilesTask(config
.platforms
.split(',')),
152 ["helenos-checkout"])
155 scheduler
.submit("Schedule HelenOS builds",
157 HelenOSScheduleBuildsTask(scheduler
),
158 ["helenos-get-profiles"])
162 # Coastline: get list of harbours (i.e. ported software) and build all of them
163 # for all HelenOS builds
164 scheduler
.submit("Determining available harbours",
165 "coastline-get-harbours",
166 CoastlineGetHarboursTask(config
.harbours
.split(',')),
167 ["coastline-checkout"])
169 scheduler
.submit("Schedule harbour tarballs fetches",
171 CoastlineScheduleFetchesTask(scheduler
),
172 ["coastline-get-harbours" ])
175 scheduler
.submit("Schedule Coastline builds",
177 CoastlineScheduleBuildsTask(scheduler
, config
.archive_format
),
180 "helenos-get-profiles", "coastline-get-harbours",
182 "helenos-build", "coastline-fetch"
186 extra_builds
= HelenOSExtraBuildsManager(scheduler
)
190 scheduler
.submit("Determine available test scenarios",
192 GetTestListTask(config
.self_path
, config
.tests
.split(',')),
195 scheduler
.submit("Schedule tests",
197 ScheduleTestsTask(scheduler
,
200 [ "--memory={}".format(config
.vm_memory_size
) ]
210 # Wait for all builds (and everything) to complete before creating
211 # the web page with results.
214 scheduler
.close_report()
216 scheduler
.submit("Generate HTML report",
218 MakeHtmlReportTask(config
.self_path
, config
.rss_url
, config
.web_resource_path
))