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).')
92 args
.add_argument('--jobs', default
=multiprocessing
.cpu_count(), dest
='jobs',
95 help='Number of concurrent jobs.'
97 args
.add_argument('--no-colors', default
=False, dest
='no_colors',
99 help='Disable colorful output'
101 args
.add_argument('--debug', default
=False, dest
='debug',
103 help='Print debugging messages'
106 config
= args
.parse_args()
107 config
.artefact_directory
= os
.path
.abspath(config
.artefact_directory
)
108 config
.build_directory
= os
.path
.abspath(config
.build_directory
)
109 config
.self_path
= os
.path
.dirname(os
.path
.realpath(sys
.argv
[0]))
111 printer
= ConsolePrinter(config
.no_colors
)
113 scheduler
= BuildScheduler(
114 max_workers
=config
.jobs
,
115 build
=config
.build_directory
,
116 artefact
=config
.artefact_directory
,
117 build_id
=config
.build_id
,
123 # Check-out both HelenOS and coastline repositories
124 scheduler
.submit("Checking-out HelenOS",
126 create_checkout_task("helenos", config
.helenos_repository
))
127 scheduler
.submit("Checking-out Coastline",
128 "coastline-checkout",
129 create_checkout_task("coastline", config
.coastline_repository
))
132 # HelenOS (mainline): get list of profiles (i.e. supported architectures
133 # and platforms) and build all of them
134 scheduler
.submit("Determininig available profiles",
135 "helenos-get-profiles",
136 HelenOSGetProfilesTask(config
.platforms
.split(',')),
137 ["helenos-checkout"])
140 scheduler
.submit("Schedule HelenOS builds",
142 HelenOSScheduleBuildsTask(scheduler
),
143 ["helenos-get-profiles"])
147 # Coastline: get list of harbours (i.e. ported software) and build all of them
148 # for all HelenOS builds
149 scheduler
.submit("Determining available harbours",
150 "coastline-get-harbours",
151 CoastlineGetHarboursTask(config
.harbours
.split(',')),
152 ["coastline-checkout"])
154 scheduler
.submit("Schedule harbour tarballs fetches",
156 CoastlineScheduleFetchesTask(scheduler
),
157 ["coastline-get-harbours" ])
160 scheduler
.submit("Schedule Coastline builds",
162 CoastlineScheduleBuildsTask(scheduler
),
165 "helenos-get-profiles", "coastline-get-harbours",
167 "helenos-build", "coastline-fetch"
171 extra_builds
= HelenOSExtraBuildsManager(scheduler
)
175 scheduler
.submit("Determine available test scenarios",
177 GetTestListTask(config
.self_path
, config
.tests
.split(',')),
180 scheduler
.submit("Schedule tests",
182 ScheduleTestsTask(scheduler
, extra_builds
, config
.self_path
),
191 # Wait for all builds (and everything) to complete before creating
192 # the web page with results.
195 scheduler
.close_report()
197 scheduler
.submit("Generate HTML report",
199 MakeHtmlReportTask(config
.self_path
, config
.rss_url
, config
.web_resource_path
))