Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tools/build_config/history.py
169674 views
1
#!/usr/bin/env python
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2011-2025 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file history.py
15
# @author Michael Behrisch
16
# @date 2014-06-21
17
18
"""
19
This script builds all sumo versions in a certain revision range
20
and tries to eliminate duplicates afterwards.
21
"""
22
from __future__ import absolute_import
23
24
import subprocess
25
import shutil
26
import os
27
import sys
28
import traceback
29
30
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
31
import sumolib # noqa
32
33
34
arg_parser = sumolib.options.ArgumentParser()
35
arg_parser.add_argument("-b", "--begin", default="v1_3_0", help="first revision to build")
36
arg_parser.add_argument("-e", "--end", default="HEAD", help="last revision to build")
37
arg_parser.add_argument("-d", "--destination", default="..", help="where to put build results")
38
arg_parser.add_argument("-t", "--tags-only", action="store_true", default=False,
39
help="only build tagged revisions")
40
options = arg_parser.parse_args()
41
42
LOCK = "../history.lock"
43
if os.path.exists(LOCK):
44
sys.exit("History building is still locked!")
45
open(LOCK, 'w').close()
46
try:
47
subprocess.call(["git", "checkout", "-q", "main"])
48
subprocess.call(["git", "pull"])
49
commits = {}
50
if options.tags_only:
51
active = False
52
for tag in subprocess.check_output(["git", "tag", "--sort=taggerdate"], universal_newlines=True).splitlines():
53
if tag == options.begin:
54
active = True
55
if active:
56
commits[tag] = tag
57
if tag == options.end:
58
active = False
59
else:
60
for line in subprocess.check_output(["git", "log", "%s..%s" % (options.begin, options.end)]).splitlines():
61
if line.startswith("commit "):
62
h = line.split()[1]
63
commits[h] = sumolib.version.gitDescribe(h)
64
haveBuild = False
65
for h, desc in sorted(commits.items(), key=lambda x: x[1]):
66
dest = os.path.join(options.destination, 'bin%s' % desc)
67
if not os.path.exists(dest):
68
ret = subprocess.call(["git", "checkout", "-q", h])
69
if ret != 0:
70
continue
71
os.chdir("build/cmake-build")
72
subprocess.call('make clean; make -j32', shell=True)
73
os.chdir("../..")
74
haveBuild = True
75
shutil.copytree('bin', dest, ignore=shutil.ignore_patterns('*.fmu', '*.bat', '*.jar'))
76
subprocess.call('strip -R .note.gnu.build-id %s/*' % dest, shell=True)
77
subprocess.call("sed -i 's/%s/%s/' %s" % (desc, len(desc) * "0", dest), shell=True)
78
if haveBuild:
79
for line in subprocess.check_output('fdupes -1 -q %s/binv*' % options.destination, shell=True).splitlines():
80
dups = line.split()
81
for d in dups[1:]:
82
subprocess.call('ln -sf %s %s' % (dups[0], d), shell=True)
83
subprocess.call(["git", "checkout", "-q", "main"])
84
except Exception:
85
traceback.print_exc()
86
os.remove(LOCK)
87
88