2012-09-18 07:48:26 +00:00
|
|
|
# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
2011-10-05 05:34:19 +00:00
|
|
|
# for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
# BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
# This file contains a set of utilities functions used by other Python-based
|
|
|
|
# scripts.
|
|
|
|
|
2020-06-30 13:22:30 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2017-02-14 15:34:31 +00:00
|
|
|
import contextlib
|
2015-05-28 09:20:36 +00:00
|
|
|
import datetime
|
2023-02-17 11:20:20 +00:00
|
|
|
from functools import total_ordering
|
2017-01-19 16:25:39 +00:00
|
|
|
import glob
|
2023-12-12 18:19:35 +00:00
|
|
|
import importlib.util
|
|
|
|
import importlib.machinery
|
2015-05-28 09:20:36 +00:00
|
|
|
import json
|
2011-10-05 05:34:19 +00:00
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import re
|
2013-07-17 11:40:49 +00:00
|
|
|
import shutil
|
2011-10-05 05:34:19 +00:00
|
|
|
import subprocess
|
2017-01-19 15:17:23 +00:00
|
|
|
import sys
|
2017-01-19 16:25:39 +00:00
|
|
|
import tarfile
|
|
|
|
import tempfile
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
try:
|
2019-08-05 20:34:31 +00:00
|
|
|
# Not available on Windows.
|
|
|
|
import resource
|
2017-01-19 16:25:39 +00:00
|
|
|
except:
|
2019-08-05 20:34:31 +00:00
|
|
|
pass
|
2017-01-19 16:25:39 +00:00
|
|
|
|
2023-02-17 11:20:20 +00:00
|
|
|
SEMANTIC_VERSION_PATTERN = r'^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
|
|
|
|
|
2020-06-29 15:05:23 +00:00
|
|
|
|
|
|
|
# To eliminate clashing with older archived builds on bleeding edge we add
|
|
|
|
# a base number bigger the largest svn revision (this also gives us an easy
|
|
|
|
# way of seeing if an archive comes from git based or svn based commits).
|
|
|
|
GIT_NUMBER_BASE = 100000
|
|
|
|
|
|
|
|
# Mapping table between build mode and build configuration.
|
|
|
|
BUILD_MODES = {
|
|
|
|
'debug': 'Debug',
|
|
|
|
'release': 'Release',
|
|
|
|
'product': 'Product',
|
|
|
|
}
|
|
|
|
|
|
|
|
# Mapping table between build mode and build configuration.
|
|
|
|
BUILD_SANITIZERS = {
|
|
|
|
None: '',
|
|
|
|
'none': '',
|
|
|
|
'asan': 'ASAN',
|
|
|
|
'lsan': 'LSAN',
|
|
|
|
'msan': 'MSAN',
|
|
|
|
'tsan': 'TSAN',
|
|
|
|
'ubsan': 'UBSAN',
|
|
|
|
}
|
|
|
|
|
|
|
|
# Mapping table between OS and build output location.
|
|
|
|
BUILD_ROOT = {
|
2020-06-30 13:22:30 +00:00
|
|
|
'win32': 'out',
|
|
|
|
'linux': 'out',
|
|
|
|
'freebsd': 'out',
|
|
|
|
'macos': 'xcodebuild',
|
2020-06-29 15:05:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Note: gn expects these to be lower case.
|
|
|
|
ARCH_FAMILY = {
|
|
|
|
'ia32': 'ia32',
|
|
|
|
'x64': 'ia32',
|
|
|
|
'arm': 'arm',
|
|
|
|
'arm64': 'arm',
|
|
|
|
'arm_x64': 'arm',
|
2022-05-10 16:11:53 +00:00
|
|
|
'arm_arm64': 'arm',
|
2020-06-29 15:05:23 +00:00
|
|
|
'simarm': 'ia32',
|
|
|
|
'simarm64': 'ia32',
|
|
|
|
'simarm_x64': 'ia32',
|
2022-05-10 16:11:53 +00:00
|
|
|
'simarm_arm64': 'arm',
|
2021-02-04 17:44:37 +00:00
|
|
|
'x64c': 'ia32',
|
|
|
|
'arm64c': 'arm',
|
|
|
|
'simarm64c': 'ia32',
|
[vm] Support RISC-V.
Implements a backend targeting RV32GC and RV64GC, based on Linux standardizing around GC. The assembler is written to make it easy to disable usage of C, but because the sizes of some instruction sequences are compile-time constants, an additional build configuration would need to be defined to make use of it.
The assembler and disassembler cover every RV32/64GC instruction. The simulator covers all instructions except accessing CSRs and the floating point state accessible through such, include accrued exceptions and dynamic rounding mode.
Quirks:
- RISC-V is a compare-and-branch architecture, but some existing "architecture-independent" parts of the Dart compiler assume a condition code architecture. To avoid rewriting these parts, we use a peephole in the assembler to map to compare-and-branch. See Assembler::BranchIf. Luckily nothing depended on taking multiple branches on the same condition code set.
- There are no hardware overflow checks, so we must use Hacker's Delight style software checks. Often these are very cheap: if the sign of one operand is known, a single branch is needed.
- The ranges of RISC-V branches and jumps are such that we use 3 levels of generation for forward branches, instead of the 2 levels of near and far branches used on ARM[64]. Nearly all code is handled by the first two levels with 20-bits of range, with enormous regex matchers triggering the third level that uses aupic+jalr to get 32-bits of range.
- For PC-relative calls in AOT, we always generate auipc+jalr pairs with 32-bits of range, so we never generate trampolines.
- Only a subset of registers are available in some compressed instructions, so we assign the most popular uses to these registers. In particular, THR, TMP[2], CODE and PP. This has the effect of assigning CODE and PP to volatile registers in the C calling convention, whereas they are assigned preserved registers on the other architectures. As on ARM64, PP is untagged; this is so short indices can be accessed with a compressed instruction.
- There are no push or pop instructions, so combining pushes and pops is preferred so we can update SP once.
- The C calling convention has a strongly aligned stack, but unlike on ARM64 we don't need to use an alternate stack pointer. The author ensured language was added to the RISC-V psABI making the OS responsible for realigning the stack pointer for signal handlers, allowing Dart to leave the stack pointer misaligned from the C calling convention's point of view until a foreign call.
- We don't bother with the link register tracking done on ARM[64]. Instead we make use of an alternate link register to avoid inline spilling in the write barrier.
Unimplemented:
- non-trivial FFI cases
- Compressed pointers - No intention to implement.
- Unboxed SIMD - We might make use of the V extension registers when the V extension is ratified.
- BigInt intrinsics
TEST=existing tests for IL level, new tests for assembler/disassembler/simulator
Bug: https://github.com/dart-lang/sdk/issues/38587
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I991d1df4be5bf55efec5371b767b332d37dfa3e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217289
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-20 00:57:57 +00:00
|
|
|
'simriscv32': 'ia32',
|
|
|
|
'simriscv64': 'ia32',
|
2022-07-29 18:11:01 +00:00
|
|
|
'simx64': 'arm',
|
|
|
|
'simx64c': 'arm',
|
[vm] Support RISC-V.
Implements a backend targeting RV32GC and RV64GC, based on Linux standardizing around GC. The assembler is written to make it easy to disable usage of C, but because the sizes of some instruction sequences are compile-time constants, an additional build configuration would need to be defined to make use of it.
The assembler and disassembler cover every RV32/64GC instruction. The simulator covers all instructions except accessing CSRs and the floating point state accessible through such, include accrued exceptions and dynamic rounding mode.
Quirks:
- RISC-V is a compare-and-branch architecture, but some existing "architecture-independent" parts of the Dart compiler assume a condition code architecture. To avoid rewriting these parts, we use a peephole in the assembler to map to compare-and-branch. See Assembler::BranchIf. Luckily nothing depended on taking multiple branches on the same condition code set.
- There are no hardware overflow checks, so we must use Hacker's Delight style software checks. Often these are very cheap: if the sign of one operand is known, a single branch is needed.
- The ranges of RISC-V branches and jumps are such that we use 3 levels of generation for forward branches, instead of the 2 levels of near and far branches used on ARM[64]. Nearly all code is handled by the first two levels with 20-bits of range, with enormous regex matchers triggering the third level that uses aupic+jalr to get 32-bits of range.
- For PC-relative calls in AOT, we always generate auipc+jalr pairs with 32-bits of range, so we never generate trampolines.
- Only a subset of registers are available in some compressed instructions, so we assign the most popular uses to these registers. In particular, THR, TMP[2], CODE and PP. This has the effect of assigning CODE and PP to volatile registers in the C calling convention, whereas they are assigned preserved registers on the other architectures. As on ARM64, PP is untagged; this is so short indices can be accessed with a compressed instruction.
- There are no push or pop instructions, so combining pushes and pops is preferred so we can update SP once.
- The C calling convention has a strongly aligned stack, but unlike on ARM64 we don't need to use an alternate stack pointer. The author ensured language was added to the RISC-V psABI making the OS responsible for realigning the stack pointer for signal handlers, allowing Dart to leave the stack pointer misaligned from the C calling convention's point of view until a foreign call.
- We don't bother with the link register tracking done on ARM[64]. Instead we make use of an alternate link register to avoid inline spilling in the write barrier.
Unimplemented:
- non-trivial FFI cases
- Compressed pointers - No intention to implement.
- Unboxed SIMD - We might make use of the V extension registers when the V extension is ratified.
- BigInt intrinsics
TEST=existing tests for IL level, new tests for assembler/disassembler/simulator
Bug: https://github.com/dart-lang/sdk/issues/38587
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I991d1df4be5bf55efec5371b767b332d37dfa3e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217289
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-01-20 00:57:57 +00:00
|
|
|
'riscv32': 'riscv',
|
|
|
|
'riscv64': 'riscv',
|
2020-06-29 15:05:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BASE_DIR = os.path.abspath(os.path.join(os.curdir, '..'))
|
|
|
|
DART_DIR = os.path.abspath(os.path.join(__file__, '..', '..'))
|
|
|
|
VERSION_FILE = os.path.join(DART_DIR, 'tools', 'VERSION')
|
|
|
|
|
|
|
|
|
|
|
|
def GetArchFamily(arch):
|
|
|
|
return ARCH_FAMILY[arch]
|
|
|
|
|
|
|
|
|
|
|
|
def GetBuildDir(host_os):
|
|
|
|
return BUILD_ROOT[host_os]
|
|
|
|
|
|
|
|
|
|
|
|
def GetBuildMode(mode):
|
|
|
|
return BUILD_MODES[mode]
|
|
|
|
|
|
|
|
|
|
|
|
def GetBuildSanitizer(sanitizer):
|
|
|
|
return BUILD_SANITIZERS[sanitizer]
|
|
|
|
|
|
|
|
|
|
|
|
def GetBaseDir():
|
|
|
|
return BASE_DIR
|
2017-01-19 16:25:39 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2023-12-12 18:19:35 +00:00
|
|
|
def load_source(modname, filename):
|
|
|
|
loader = importlib.machinery.SourceFileLoader(modname, filename)
|
|
|
|
spec = importlib.util.spec_from_file_location(modname,
|
|
|
|
filename,
|
|
|
|
loader=loader)
|
|
|
|
module = importlib.util.module_from_spec(spec)
|
|
|
|
# The module is always executed and not cached in sys.modules.
|
|
|
|
# Uncomment the following line to cache the module.
|
|
|
|
# sys.modules[module.__name__] = module
|
|
|
|
loader.exec_module(module)
|
|
|
|
return module
|
|
|
|
|
|
|
|
|
2020-06-30 13:22:30 +00:00
|
|
|
def GetBotUtils(repo_path=DART_DIR):
|
2019-08-05 20:34:31 +00:00
|
|
|
'''Dynamically load the tools/bots/bot_utils.py python module.'''
|
2023-12-12 18:19:35 +00:00
|
|
|
return load_source('bot_utils',
|
|
|
|
os.path.join(repo_path, 'tools', 'bots', 'bot_utils.py'))
|
2011-10-05 05:34:19 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2020-06-30 13:22:30 +00:00
|
|
|
def GetMinidumpUtils(repo_path=DART_DIR):
|
2019-08-05 20:34:31 +00:00
|
|
|
'''Dynamically load the tools/minidump.py python module.'''
|
2023-12-12 18:19:35 +00:00
|
|
|
return load_source('minidump',
|
|
|
|
os.path.join(repo_path, 'tools', 'minidump.py'))
|
2018-10-24 13:30:16 +00:00
|
|
|
|
|
|
|
|
2023-02-17 11:20:20 +00:00
|
|
|
@total_ordering
|
2013-12-06 17:23:49 +00:00
|
|
|
class Version(object):
|
2019-08-05 20:34:31 +00:00
|
|
|
|
2023-02-17 11:20:20 +00:00
|
|
|
def __init__(self,
|
|
|
|
channel=None,
|
|
|
|
major=None,
|
|
|
|
minor=None,
|
|
|
|
patch=None,
|
|
|
|
prerelease=None,
|
|
|
|
prerelease_patch=None,
|
|
|
|
version=None):
|
2019-08-05 20:34:31 +00:00
|
|
|
self.channel = channel
|
|
|
|
self.major = major
|
|
|
|
self.minor = minor
|
|
|
|
self.patch = patch
|
|
|
|
self.prerelease = prerelease
|
|
|
|
self.prerelease_patch = prerelease_patch
|
2023-02-17 11:20:20 +00:00
|
|
|
if version:
|
|
|
|
self.set_version(version)
|
|
|
|
|
|
|
|
def set_version(self, version):
|
|
|
|
match = re.match(SEMANTIC_VERSION_PATTERN, version)
|
|
|
|
assert match, '%s must be a valid version' % version
|
|
|
|
self.channel = 'stable'
|
|
|
|
self.major = match['major']
|
|
|
|
self.minor = match['minor']
|
|
|
|
self.patch = match['patch']
|
|
|
|
self.prerelease = '0'
|
|
|
|
self.prerelease_patch = '0'
|
|
|
|
if match['prerelease']:
|
|
|
|
subversions = match['prerelease'].split('.')
|
|
|
|
self.prerelease = subversions[0]
|
|
|
|
self.prerelease_patch = subversions[1]
|
|
|
|
self.channel = subversions[2]
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
result = '%s.%s.%s' % (self.major, self.minor, self.patch)
|
|
|
|
if self.channel != 'stable':
|
|
|
|
result += '-%s.%s.%s' % (self.prerelease, self.prerelease_patch,
|
|
|
|
self.channel)
|
|
|
|
return result
|
|
|
|
|
|
|
|
def __eq__(self, other):
|
|
|
|
return self.channel == other.channel and \
|
|
|
|
self.major == other.major and \
|
|
|
|
self.minor == other.minor and \
|
|
|
|
self.patch == other.patch and \
|
|
|
|
self.prerelease == other.prerelease and \
|
|
|
|
self.prerelease_patch == other.prerelease_patch
|
|
|
|
|
|
|
|
def __lt__(self, other):
|
|
|
|
if int(self.major) < int(other.major):
|
|
|
|
return True
|
|
|
|
if int(self.major) > int(other.major):
|
|
|
|
return False
|
|
|
|
if int(self.minor) < int(other.minor):
|
|
|
|
return True
|
|
|
|
if int(self.minor) > int(other.minor):
|
|
|
|
return False
|
|
|
|
if int(self.patch) < int(other.patch):
|
|
|
|
return True
|
|
|
|
if int(self.patch) > int(other.patch):
|
|
|
|
return False
|
|
|
|
# The stable channel is ahead of the other channels on the same triplet.
|
|
|
|
if self.channel != 'stable' and other.channel == 'stable':
|
|
|
|
return True
|
|
|
|
if self.channel == 'stable' and other.channel != 'stable':
|
|
|
|
return False
|
2023-09-27 14:27:40 +00:00
|
|
|
# The main channel is ahead of the other channels on the same triplet.
|
|
|
|
if self.channel != 'main' and other.channel == 'main':
|
|
|
|
return True
|
|
|
|
if self.channel == 'main' and other.channel != 'main':
|
|
|
|
return False
|
|
|
|
# The be channel existed before it was renamed to main.
|
2023-02-17 11:20:20 +00:00
|
|
|
if self.channel != 'be' and other.channel == 'be':
|
|
|
|
return True
|
|
|
|
if self.channel == 'be' and other.channel != 'be':
|
|
|
|
return False
|
|
|
|
if int(self.prerelease) < int(other.prerelease):
|
|
|
|
return True
|
|
|
|
if int(self.prerelease) > int(other.prerelease):
|
|
|
|
return False
|
2023-04-14 12:27:01 +00:00
|
|
|
if int(self.prerelease_patch) < int(other.prerelease_patch):
|
|
|
|
return True
|
|
|
|
if int(self.prerelease_patch) > int(other.prerelease_patch):
|
|
|
|
return False
|
2023-02-17 11:20:20 +00:00
|
|
|
return False
|
2011-10-05 05:34:19 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2011-10-05 05:34:19 +00:00
|
|
|
# Try to guess the host operating system.
|
|
|
|
def GuessOS():
|
2019-08-05 20:34:31 +00:00
|
|
|
os_id = platform.system()
|
2020-06-30 13:22:30 +00:00
|
|
|
if os_id == 'Linux':
|
|
|
|
return 'linux'
|
|
|
|
elif os_id == 'Darwin':
|
|
|
|
return 'macos'
|
|
|
|
elif os_id == 'Windows' or os_id == 'Microsoft':
|
|
|
|
# On Windows Vista platform.system() can return 'Microsoft' with some
|
2019-08-05 20:34:31 +00:00
|
|
|
# versions of Python, see http://bugs.python.org/issue1082 for details.
|
2020-06-30 13:22:30 +00:00
|
|
|
return 'win32'
|
2019-08-05 20:34:31 +00:00
|
|
|
elif os_id == 'FreeBSD':
|
|
|
|
return 'freebsd'
|
|
|
|
elif os_id == 'OpenBSD':
|
|
|
|
return 'openbsd'
|
|
|
|
elif os_id == 'SunOS':
|
|
|
|
return 'solaris'
|
2020-06-30 13:22:30 +00:00
|
|
|
|
|
|
|
return None
|
2011-10-05 05:34:19 +00:00
|
|
|
|
|
|
|
|
2022-05-10 16:11:53 +00:00
|
|
|
# Runs true if the currently executing python interpreter is running under
|
|
|
|
# Rosetta. I.e., python3 is an x64 executable and we're on an arm64 Mac.
|
|
|
|
def IsRosetta():
|
|
|
|
if platform.system() == 'Darwin':
|
|
|
|
p = subprocess.Popen(['sysctl', '-in', 'sysctl.proc_translated'],
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.STDOUT)
|
|
|
|
output, _ = p.communicate()
|
|
|
|
return output.decode('utf-8').strip() == '1'
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
# Returns the architectures that can run on the current machine.
|
|
|
|
def HostArchitectures():
|
|
|
|
m = platform.machine()
|
|
|
|
if platform.system() == 'Darwin':
|
|
|
|
if m == 'arm64' or IsRosetta():
|
|
|
|
# ARM64 Macs also support X64.
|
|
|
|
return ['arm64', 'x64']
|
|
|
|
if m == 'x86_64':
|
|
|
|
# X64 Macs no longer support IA32.
|
|
|
|
return ['x64']
|
2023-06-02 18:18:09 +00:00
|
|
|
# Icky use of CIPD_ARCHITECTURE should be effectively dead whenever the
|
|
|
|
# Python on bots becomes native ARM64.
|
|
|
|
if ((platform.system() == 'Windows') and
|
|
|
|
(os.environ.get("CIPD_ARCHITECTURE") == "arm64")):
|
|
|
|
# ARM64 Windows also can emulate X64.
|
|
|
|
return ['arm64', 'x64']
|
|
|
|
|
|
|
|
if m in ['aarch64', 'arm64', 'arm64e', 'ARM64']:
|
|
|
|
return ['arm64']
|
|
|
|
if m in ['armv7l', 'armv8l']:
|
|
|
|
return ['arm']
|
|
|
|
if m in ['i386', 'i686', 'ia32', 'x86']:
|
|
|
|
return ['x86', 'ia32']
|
|
|
|
if m in ['x64', 'x86-64', 'x86_64', 'amd64', 'AMD64']:
|
|
|
|
return ['x64', 'x86', 'ia32']
|
2023-12-11 19:12:50 +00:00
|
|
|
if m in ['riscv64']:
|
|
|
|
return ['riscv64']
|
2022-05-10 16:11:53 +00:00
|
|
|
raise Exception('Failed to determine host architectures for %s %s',
|
|
|
|
platform.machine(), platform.system())
|
|
|
|
|
|
|
|
|
2011-10-05 05:34:19 +00:00
|
|
|
# Try to guess the host architecture.
|
|
|
|
def GuessArchitecture():
|
2022-05-10 16:11:53 +00:00
|
|
|
return HostArchitectures()[0]
|
2011-10-05 05:34:19 +00:00
|
|
|
|
|
|
|
# Try to guess the number of cpus on this machine.
|
|
|
|
def GuessCpus():
|
2020-06-30 13:22:30 +00:00
|
|
|
if os.getenv('DART_NUMBER_OF_CORES') is not None:
|
|
|
|
return int(os.getenv('DART_NUMBER_OF_CORES'))
|
|
|
|
if os.path.exists('/proc/cpuinfo'):
|
2019-08-05 20:34:31 +00:00
|
|
|
return int(
|
|
|
|
subprocess.check_output(
|
2020-06-30 13:22:30 +00:00
|
|
|
'grep -E \'^processor\' /proc/cpuinfo | wc -l', shell=True))
|
|
|
|
if os.path.exists('/usr/bin/hostinfo'):
|
2019-08-05 20:34:31 +00:00
|
|
|
return int(
|
|
|
|
subprocess.check_output(
|
|
|
|
'/usr/bin/hostinfo |'
|
|
|
|
' grep "processors are logically available." |'
|
2024-01-12 16:38:51 +00:00
|
|
|
' awk "{ print \\$1 }"',
|
2019-08-05 20:34:31 +00:00
|
|
|
shell=True))
|
|
|
|
win_cpu_count = os.getenv("NUMBER_OF_PROCESSORS")
|
|
|
|
if win_cpu_count:
|
|
|
|
return int(win_cpu_count)
|
|
|
|
return 2
|
2011-10-05 05:34:19 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2011-10-05 05:34:19 +00:00
|
|
|
# Returns true if we're running under Windows.
|
|
|
|
def IsWindows():
|
2019-08-05 20:34:31 +00:00
|
|
|
return GuessOS() == 'win32'
|
2011-10-05 05:34:19 +00:00
|
|
|
|
|
|
|
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
def IsCrossBuild(target_os, arch):
|
2022-05-10 16:11:53 +00:00
|
|
|
if (target_os not in [None, 'host']) and (target_os != GuessOS()):
|
|
|
|
return True
|
|
|
|
if arch.startswith('sim'):
|
|
|
|
return False
|
2022-05-16 20:22:25 +00:00
|
|
|
if arch.endswith('c'):
|
|
|
|
# Strip 'compressed' suffix.
|
|
|
|
arch = arch[:-1]
|
2022-05-10 16:11:53 +00:00
|
|
|
if arch in HostArchitectures():
|
|
|
|
return False
|
|
|
|
return True
|
Fixes create_sdk target for cross-builds.
Building an sdk requires snapshots to be generated for
pub, analyzer, dart2js, etc. using a Dart VM binary that
has been built for the host. Currently, when we cross-build,
we do not build a Dart VM binary for the host.
Rather than monkey with the gyp files to do that, this
change modifies build.py to explicitly build:
1. The create_sdk target for the host arch,
2. The runtime target for the target arch,
After which files are copied to create a dart-sdk
directory for the target archetecture.
After this change, we *should* be able to cross-build Debian
packages for arm, which I'll work on in a subsequent change.
R=iposva@google.com, whesse@google.com
Review URL: https://codereview.chromium.org//397593006
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38337 260f80e4-7a28-3924-810f-c04153c831b5
2014-07-17 18:05:42 +00:00
|
|
|
|
2020-05-07 21:12:47 +00:00
|
|
|
|
2020-06-16 23:37:36 +00:00
|
|
|
def GetBuildConf(mode, arch, conf_os=None, sanitizer=None):
|
2020-06-30 13:22:30 +00:00
|
|
|
if conf_os is not None and conf_os != GuessOS() and conf_os != 'host':
|
|
|
|
return '{}{}{}'.format(GetBuildMode(mode), conf_os.title(),
|
|
|
|
arch.upper())
|
|
|
|
|
|
|
|
# Ask for a cross build if the host and target architectures don't match.
|
|
|
|
cross_build = ''
|
2022-05-10 16:11:53 +00:00
|
|
|
if IsCrossBuild(conf_os, arch):
|
2020-06-30 13:22:30 +00:00
|
|
|
cross_build = 'X'
|
|
|
|
return '{}{}{}{}'.format(GetBuildMode(mode), GetBuildSanitizer(sanitizer),
|
2020-06-16 23:37:36 +00:00
|
|
|
cross_build, arch.upper())
|
2011-10-05 05:34:19 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2020-06-16 23:37:36 +00:00
|
|
|
def GetBuildRoot(host_os, mode=None, arch=None, target_os=None, sanitizer=None):
|
2019-08-05 20:34:31 +00:00
|
|
|
build_root = GetBuildDir(host_os)
|
|
|
|
if mode:
|
2019-12-11 18:12:47 +00:00
|
|
|
build_root = os.path.join(
|
2020-06-16 23:37:36 +00:00
|
|
|
build_root, GetBuildConf(mode, arch, target_os, sanitizer))
|
2019-08-05 20:34:31 +00:00
|
|
|
return build_root
|
2011-10-05 05:34:19 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2023-09-27 14:27:40 +00:00
|
|
|
def GetVersion(no_git_hash=False, version_file=None, git_revision_file=None):
|
2019-08-05 20:34:31 +00:00
|
|
|
version = ReadVersionFile(version_file)
|
|
|
|
if not version:
|
|
|
|
return None
|
|
|
|
|
2020-07-07 06:08:20 +00:00
|
|
|
suffix = ''
|
2023-09-27 14:27:40 +00:00
|
|
|
if version.channel in ['main', 'be']:
|
2020-07-07 06:08:20 +00:00
|
|
|
suffix = '-edge' if no_git_hash else '-edge.{}'.format(
|
|
|
|
GetGitRevision(git_revision_file))
|
2020-03-19 07:49:38 +00:00
|
|
|
elif version.channel in ('beta', 'dev'):
|
2020-07-07 06:08:20 +00:00
|
|
|
suffix = '-{}.{}.{}'.format(version.prerelease,
|
|
|
|
version.prerelease_patch, version.channel)
|
2019-08-05 20:34:31 +00:00
|
|
|
else:
|
|
|
|
assert version.channel == 'stable'
|
2013-12-06 17:23:49 +00:00
|
|
|
|
2020-06-30 13:22:30 +00:00
|
|
|
return '{}.{}.{}{}'.format(version.major, version.minor, version.patch,
|
2020-07-07 06:08:20 +00:00
|
|
|
suffix)
|
2013-12-06 17:23:49 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2020-07-07 06:08:20 +00:00
|
|
|
def GetChannel(version_file=None):
|
|
|
|
version = ReadVersionFile(version_file)
|
2019-08-05 20:34:31 +00:00
|
|
|
return version.channel
|
2013-11-25 13:05:30 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2019-04-29 16:40:50 +00:00
|
|
|
def ReadVersionFile(version_file=None):
|
2013-12-06 17:23:49 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def match_against(pattern, file_content):
|
|
|
|
match = re.search(pattern, file_content, flags=re.MULTILINE)
|
|
|
|
if match:
|
|
|
|
return match.group(1)
|
|
|
|
return None
|
2019-04-29 16:40:50 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
if version_file == None:
|
|
|
|
version_file = VERSION_FILE
|
2013-12-06 17:23:49 +00:00
|
|
|
|
2020-06-30 13:22:30 +00:00
|
|
|
content = None
|
2019-08-05 20:34:31 +00:00
|
|
|
try:
|
2020-06-30 13:22:30 +00:00
|
|
|
with open(version_file) as fd:
|
|
|
|
content = fd.read()
|
2019-08-05 20:34:31 +00:00
|
|
|
except:
|
2020-06-30 13:22:30 +00:00
|
|
|
print('Warning: Could not read VERSION file ({})'.format(version_file))
|
2019-08-05 20:34:31 +00:00
|
|
|
return None
|
|
|
|
|
|
|
|
channel = match_against('^CHANNEL ([A-Za-z0-9]+)$', content)
|
2024-01-12 16:38:51 +00:00
|
|
|
major = match_against('^MAJOR (\\d+)$', content)
|
|
|
|
minor = match_against('^MINOR (\\d+)$', content)
|
|
|
|
patch = match_against('^PATCH (\\d+)$', content)
|
|
|
|
prerelease = match_against('^PRERELEASE (\\d+)$', content)
|
|
|
|
prerelease_patch = match_against('^PRERELEASE_PATCH (\\d+)$', content)
|
2019-08-05 20:34:31 +00:00
|
|
|
|
2020-08-06 19:55:12 +00:00
|
|
|
if (channel and major and minor and prerelease and prerelease_patch):
|
2019-08-05 20:34:31 +00:00
|
|
|
return Version(channel, major, minor, patch, prerelease,
|
2020-08-06 19:55:12 +00:00
|
|
|
prerelease_patch)
|
2020-06-30 13:22:30 +00:00
|
|
|
|
|
|
|
print('Warning: VERSION file ({}) has wrong format'.format(version_file))
|
|
|
|
return None
|
2012-10-15 08:21:44 +00:00
|
|
|
|
2012-08-08 14:55:01 +00:00
|
|
|
|
2020-07-07 06:08:20 +00:00
|
|
|
def GetGitRevision(git_revision_file=None, repo_path=DART_DIR):
|
2019-08-05 20:34:31 +00:00
|
|
|
# When building from tarball use tools/GIT_REVISION
|
2020-07-07 06:08:20 +00:00
|
|
|
if git_revision_file is None:
|
|
|
|
git_revision_file = os.path.join(repo_path, 'tools', 'GIT_REVISION')
|
2019-08-05 20:34:31 +00:00
|
|
|
try:
|
|
|
|
with open(git_revision_file) as fd:
|
2023-02-06 09:15:01 +00:00
|
|
|
return fd.read().strip()
|
2019-08-05 20:34:31 +00:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
p = subprocess.Popen(['git', 'rev-parse', 'HEAD'],
|
|
|
|
stdout=subprocess.PIPE,
|
2023-03-27 18:02:38 +00:00
|
|
|
stderr=subprocess.PIPE,
|
2019-08-05 20:34:31 +00:00
|
|
|
shell=IsWindows(),
|
2020-06-30 13:22:30 +00:00
|
|
|
cwd=repo_path)
|
2023-03-27 18:02:38 +00:00
|
|
|
out, err = p.communicate()
|
|
|
|
# TODO(https://github.com/dart-lang/sdk/issues/51865): Don't ignore errors.
|
|
|
|
# if p.wait() != 0:
|
|
|
|
# raise Exception('git rev-parse failed: ' + str(err))
|
|
|
|
revision = out.decode('utf-8').strip()
|
2019-08-05 20:34:31 +00:00
|
|
|
# We expect a full git hash
|
2020-06-30 13:22:30 +00:00
|
|
|
if len(revision) != 40:
|
|
|
|
print('Warning: Could not parse git commit, output was {}'.format(
|
2020-07-07 06:08:20 +00:00
|
|
|
revision),
|
|
|
|
file=sys.stderr)
|
2019-08-05 20:34:31 +00:00
|
|
|
return None
|
2020-06-30 13:22:30 +00:00
|
|
|
return revision
|
2015-05-28 09:20:36 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2020-06-30 13:22:30 +00:00
|
|
|
def GetShortGitHash(repo_path=DART_DIR):
|
2020-07-16 18:43:24 +00:00
|
|
|
p = subprocess.Popen(['git', 'rev-parse', '--short=10', 'HEAD'],
|
2019-08-05 20:34:31 +00:00
|
|
|
stdout=subprocess.PIPE,
|
2023-03-27 18:02:38 +00:00
|
|
|
stderr=subprocess.PIPE,
|
2019-08-05 20:34:31 +00:00
|
|
|
shell=IsWindows(),
|
2020-06-30 13:22:30 +00:00
|
|
|
cwd=repo_path)
|
2023-03-27 18:02:38 +00:00
|
|
|
out, err = p.communicate()
|
2019-08-05 20:34:31 +00:00
|
|
|
if p.wait() != 0:
|
2023-03-27 18:02:38 +00:00
|
|
|
# TODO(https://github.com/dart-lang/sdk/issues/51865): Don't ignore errors.
|
|
|
|
# raise Exception('git rev-parse failed: ' + str(err))
|
2023-03-25 04:37:43 +00:00
|
|
|
return None
|
2023-03-27 18:02:38 +00:00
|
|
|
revision = out.decode('utf-8').strip()
|
2020-06-30 13:22:30 +00:00
|
|
|
return revision
|
2018-02-16 20:44:48 +00:00
|
|
|
|
|
|
|
|
2023-02-06 09:15:01 +00:00
|
|
|
def GetGitTimestamp(git_timestamp_file=None, repo_path=DART_DIR):
|
|
|
|
# When building from tarball use tools/GIT_TIMESTAMP
|
|
|
|
if git_timestamp_file is None:
|
|
|
|
git_timestamp_file = os.path.join(repo_path, 'tools', 'GIT_TIMESTAMP')
|
|
|
|
try:
|
|
|
|
with open(git_timestamp_file) as fd:
|
|
|
|
return fd.read().strip()
|
|
|
|
except:
|
|
|
|
pass
|
2019-08-05 20:34:31 +00:00
|
|
|
p = subprocess.Popen(['git', 'log', '-n', '1', '--pretty=format:%cd'],
|
|
|
|
stdout=subprocess.PIPE,
|
2023-03-27 18:02:38 +00:00
|
|
|
stderr=subprocess.PIPE,
|
2019-08-05 20:34:31 +00:00
|
|
|
shell=IsWindows(),
|
2020-06-30 13:22:30 +00:00
|
|
|
cwd=repo_path)
|
2023-03-27 18:02:38 +00:00
|
|
|
out, err = p.communicate()
|
2019-08-05 20:34:31 +00:00
|
|
|
if p.wait() != 0:
|
2023-03-27 18:02:38 +00:00
|
|
|
# TODO(https://github.com/dart-lang/sdk/issues/51865): Don't ignore errors.
|
|
|
|
# raise Exception('git log failed: ' + str(err))
|
2023-03-25 04:37:43 +00:00
|
|
|
return None
|
2023-03-27 18:02:38 +00:00
|
|
|
timestamp = out.decode('utf-8').strip()
|
2020-06-30 13:22:30 +00:00
|
|
|
return timestamp
|
2017-11-23 00:07:56 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2020-06-30 13:22:30 +00:00
|
|
|
# TODO(42528): Can we remove this? It's basically just an alias for Exception.
|
2011-10-05 05:34:19 +00:00
|
|
|
class Error(Exception):
|
2019-08-05 20:34:31 +00:00
|
|
|
pass
|
2011-10-05 05:34:19 +00:00
|
|
|
|
|
|
|
|
2012-03-23 11:52:43 +00:00
|
|
|
def IsCrashExitCode(exit_code):
|
2019-08-05 20:34:31 +00:00
|
|
|
if IsWindows():
|
|
|
|
return 0x80000000 & exit_code
|
2020-06-30 13:22:30 +00:00
|
|
|
return exit_code < 0
|
2012-03-23 11:52:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
def DiagnoseExitCode(exit_code, command):
|
2019-08-05 20:34:31 +00:00
|
|
|
if IsCrashExitCode(exit_code):
|
2020-06-30 13:22:30 +00:00
|
|
|
sys.stderr.write(
|
|
|
|
'Command: {}\nCRASHED with exit code {} (0x{:x})\n'.format(
|
|
|
|
' '.join(command), exit_code, exit_code & 0xffffffff))
|
2012-03-23 11:52:43 +00:00
|
|
|
|
|
|
|
|
2015-09-14 14:05:51 +00:00
|
|
|
def CheckedInSdkPath():
|
2019-08-05 20:34:31 +00:00
|
|
|
tools_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
return os.path.join(tools_dir, 'sdks', 'dart-sdk')
|
2015-09-14 14:05:51 +00:00
|
|
|
|
|
|
|
|
2015-09-16 11:13:32 +00:00
|
|
|
def CheckedInSdkExecutable():
|
2019-08-05 20:34:31 +00:00
|
|
|
name = 'dart'
|
|
|
|
if IsWindows():
|
|
|
|
name = 'dart.exe'
|
|
|
|
return os.path.join(CheckedInSdkPath(), 'bin', name)
|
|
|
|
|
2015-09-16 11:13:32 +00:00
|
|
|
|
2017-02-14 15:34:31 +00:00
|
|
|
def CheckLinuxCoreDumpPattern(fatal=False):
|
2019-08-05 20:34:31 +00:00
|
|
|
core_pattern_file = '/proc/sys/kernel/core_pattern'
|
|
|
|
core_pattern = open(core_pattern_file).read()
|
|
|
|
|
|
|
|
expected_core_pattern = 'core.%p'
|
|
|
|
if core_pattern.strip() != expected_core_pattern:
|
|
|
|
message = (
|
|
|
|
'Invalid core_pattern configuration. '
|
|
|
|
'The configuration of core dump handling is *not* correct for '
|
2019-12-05 10:30:03 +00:00
|
|
|
'a buildbot. The content of {0} must be "{1}" instead of "{2}".'.
|
|
|
|
format(core_pattern_file, expected_core_pattern, core_pattern))
|
2019-08-05 20:34:31 +00:00
|
|
|
if fatal:
|
|
|
|
raise Exception(message)
|
2020-06-30 13:22:30 +00:00
|
|
|
print(message)
|
|
|
|
return False
|
2019-08-05 20:34:31 +00:00
|
|
|
return True
|
2017-02-14 15:34:31 +00:00
|
|
|
|
|
|
|
|
2013-07-17 11:40:49 +00:00
|
|
|
class TempDir(object):
|
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __init__(self, prefix=''):
|
|
|
|
self._temp_dir = None
|
|
|
|
self._prefix = prefix
|
|
|
|
|
|
|
|
def __enter__(self):
|
|
|
|
self._temp_dir = tempfile.mkdtemp(self._prefix)
|
|
|
|
return self._temp_dir
|
2013-07-17 11:40:49 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __exit__(self, *_):
|
|
|
|
shutil.rmtree(self._temp_dir, ignore_errors=True)
|
2013-07-17 11:40:49 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2017-02-14 15:34:31 +00:00
|
|
|
class UnexpectedCrash(object):
|
2017-01-20 16:44:51 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __init__(self, test, pid, *binaries):
|
|
|
|
self.test = test
|
|
|
|
self.pid = pid
|
|
|
|
self.binaries = binaries
|
|
|
|
|
|
|
|
def __str__(self):
|
2020-06-30 13:22:30 +00:00
|
|
|
return 'Crash({}: {} {})'.format(self.test, self.pid,
|
|
|
|
', '.join(self.binaries))
|
2017-01-20 16:44:51 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2017-04-19 08:36:18 +00:00
|
|
|
class PosixCoreDumpEnabler(object):
|
2017-01-19 16:25:39 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __init__(self):
|
|
|
|
self._old_limits = None
|
2017-01-19 16:25:39 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __enter__(self):
|
|
|
|
self._old_limits = resource.getrlimit(resource.RLIMIT_CORE)
|
|
|
|
resource.setrlimit(resource.RLIMIT_CORE, (-1, -1))
|
|
|
|
|
|
|
|
def __exit__(self, *_):
|
2019-12-05 10:30:03 +00:00
|
|
|
if self._old_limits != None:
|
|
|
|
resource.setrlimit(resource.RLIMIT_CORE, self._old_limits)
|
2017-04-19 08:36:18 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2017-04-19 08:36:18 +00:00
|
|
|
class LinuxCoreDumpEnabler(PosixCoreDumpEnabler):
|
2017-01-19 16:25:39 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __enter__(self):
|
|
|
|
# Bump core limits to unlimited if core_pattern is correctly configured.
|
|
|
|
if CheckLinuxCoreDumpPattern(fatal=False):
|
|
|
|
super(LinuxCoreDumpEnabler, self).__enter__()
|
|
|
|
|
|
|
|
def __exit__(self, *args):
|
|
|
|
CheckLinuxCoreDumpPattern(fatal=False)
|
|
|
|
super(LinuxCoreDumpEnabler, self).__exit__(*args)
|
2017-01-19 16:25:39 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2017-04-19 08:36:18 +00:00
|
|
|
class WindowsCoreDumpEnabler(object):
|
2019-08-05 20:34:31 +00:00
|
|
|
"""This enabler assumes that Dart binary was built with Crashpad support.
|
2020-06-30 13:22:30 +00:00
|
|
|
In this case DART_CRASHPAD_CRASHES_DIR environment variable allows to
|
|
|
|
specify the location of Crashpad crashes database. Actual minidumps will
|
|
|
|
be written into reports subfolder of the database.
|
|
|
|
"""
|
|
|
|
CRASHPAD_DB_FOLDER = os.path.join(DART_DIR, 'crashes')
|
|
|
|
DUMPS_FOLDER = os.path.join(CRASHPAD_DB_FOLDER, 'reports')
|
2017-01-19 16:25:39 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __init__(self):
|
|
|
|
pass
|
2017-01-20 16:44:51 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __enter__(self):
|
2020-06-30 13:22:30 +00:00
|
|
|
print('INFO: Enabling coredump archiving into {}'.format(
|
|
|
|
WindowsCoreDumpEnabler.CRASHPAD_DB_FOLDER))
|
2019-08-05 20:34:31 +00:00
|
|
|
os.environ[
|
|
|
|
'DART_CRASHPAD_CRASHES_DIR'] = WindowsCoreDumpEnabler.CRASHPAD_DB_FOLDER
|
2017-02-14 15:34:31 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __exit__(self, *_):
|
|
|
|
del os.environ['DART_CRASHPAD_CRASHES_DIR']
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2018-10-26 18:17:18 +00:00
|
|
|
|
|
|
|
def TryUnlink(file):
|
2019-08-05 20:34:31 +00:00
|
|
|
try:
|
|
|
|
os.unlink(file)
|
|
|
|
except Exception as error:
|
2020-06-30 13:22:30 +00:00
|
|
|
print('ERROR: Failed to remove {}: {}'.format(file, error))
|
2018-10-26 18:17:18 +00:00
|
|
|
|
|
|
|
|
2017-02-14 15:34:31 +00:00
|
|
|
class BaseCoreDumpArchiver(object):
|
2019-08-05 20:34:31 +00:00
|
|
|
"""This class reads coredumps file written by UnexpectedCrashDumpArchiver
|
2020-06-30 13:22:30 +00:00
|
|
|
into the current working directory and uploads all cores and binaries
|
|
|
|
listed in it into Cloud Storage (see
|
|
|
|
pkg/test_runner/lib/src/test_progress.dart).
|
|
|
|
"""
|
2017-01-19 16:25:39 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
# test.dart will write a line for each unexpected crash into this file.
|
2020-06-30 13:22:30 +00:00
|
|
|
_UNEXPECTED_CRASHES_FILE = 'unexpected-crashes'
|
2017-02-14 15:34:31 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __init__(self, search_dir, output_directory):
|
|
|
|
self._bucket = 'dart-temp-crash-archive'
|
|
|
|
self._binaries_dir = os.getcwd()
|
|
|
|
self._search_dir = search_dir
|
|
|
|
self._output_directory = output_directory
|
2017-02-14 15:34:31 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def _safe_cleanup(self):
|
|
|
|
try:
|
|
|
|
return self._cleanup()
|
|
|
|
except Exception as error:
|
2020-06-30 13:22:30 +00:00
|
|
|
print('ERROR: Failure during cleanup: {}'.format(error))
|
2019-08-05 20:34:31 +00:00
|
|
|
return False
|
2018-10-26 18:17:18 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __enter__(self):
|
2020-06-30 13:22:30 +00:00
|
|
|
print('INFO: Core dump archiving is activated')
|
2018-10-25 15:31:27 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
# Cleanup any stale files
|
|
|
|
if self._safe_cleanup():
|
2020-06-30 13:22:30 +00:00
|
|
|
print('WARNING: Found and removed stale coredumps')
|
2017-02-14 15:34:31 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __exit__(self, *_):
|
|
|
|
try:
|
|
|
|
crashes = self._find_unexpected_crashes()
|
|
|
|
if crashes:
|
|
|
|
# If we get a ton of crashes, only archive 10 dumps.
|
|
|
|
archive_crashes = crashes[:10]
|
|
|
|
print('Archiving coredumps for crash (if possible):')
|
|
|
|
for crash in archive_crashes:
|
2020-06-30 13:22:30 +00:00
|
|
|
print('----> {}'.format(crash))
|
2019-08-05 20:34:31 +00:00
|
|
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
|
|
|
self._archive(archive_crashes)
|
|
|
|
else:
|
2020-06-30 13:22:30 +00:00
|
|
|
print('INFO: No unexpected crashes recorded')
|
2019-08-05 20:34:31 +00:00
|
|
|
dumps = self._find_all_coredumps()
|
|
|
|
if dumps:
|
2020-06-30 13:22:30 +00:00
|
|
|
print('INFO: However there are {} core dumps found'.format(
|
|
|
|
len(dumps)))
|
2019-08-05 20:34:31 +00:00
|
|
|
for dump in dumps:
|
2020-06-30 13:22:30 +00:00
|
|
|
print('INFO: -> {}'.format(dump))
|
2019-08-05 20:34:31 +00:00
|
|
|
print()
|
|
|
|
except Exception as error:
|
2020-06-30 13:22:30 +00:00
|
|
|
print('ERROR: Failed to archive crashes: {}'.format(error))
|
2019-08-05 20:34:31 +00:00
|
|
|
raise
|
|
|
|
|
|
|
|
finally:
|
|
|
|
self._safe_cleanup()
|
|
|
|
|
|
|
|
def _archive(self, crashes):
|
|
|
|
files = set()
|
|
|
|
missing = []
|
|
|
|
for crash in crashes:
|
|
|
|
files.update(crash.binaries)
|
|
|
|
core = self._find_coredump_file(crash)
|
|
|
|
if core:
|
|
|
|
files.add(core)
|
|
|
|
else:
|
|
|
|
missing.append(crash)
|
|
|
|
if self._output_directory is not None and self._is_shard():
|
|
|
|
print(
|
|
|
|
"INFO: Moving collected dumps and binaries into output directory\n"
|
|
|
|
"INFO: They will be uploaded to isolate server. Look for \"isolated"
|
|
|
|
" out\" under the failed step on the build page.\n"
|
|
|
|
"INFO: For more information see runtime/docs/infra/coredumps.md"
|
|
|
|
)
|
|
|
|
self._move(files)
|
|
|
|
else:
|
|
|
|
print(
|
|
|
|
"INFO: Uploading collected dumps and binaries into Cloud Storage\n"
|
|
|
|
"INFO: Use `gsutil.py cp from-url to-path` to download them.\n"
|
|
|
|
"INFO: For more information see runtime/docs/infra/coredumps.md"
|
|
|
|
)
|
|
|
|
self._upload(files)
|
|
|
|
|
|
|
|
if missing:
|
2021-05-20 11:49:16 +00:00
|
|
|
self._report_missing_crashes(missing, throw=False)
|
2019-08-05 20:34:31 +00:00
|
|
|
|
|
|
|
# todo(athom): move the logic to decide where to copy core dumps into the recipes.
|
|
|
|
def _is_shard(self):
|
|
|
|
return 'BUILDBOT_BUILDERNAME' not in os.environ
|
|
|
|
|
2021-05-20 11:49:16 +00:00
|
|
|
def _report_missing_crashes(self, missing, throw=False):
|
2019-08-05 20:34:31 +00:00
|
|
|
missing_as_string = ', '.join([str(c) for c in missing])
|
|
|
|
other_files = list(glob.glob(os.path.join(self._search_dir, '*')))
|
|
|
|
sys.stderr.write(
|
2020-06-30 13:22:30 +00:00
|
|
|
"Could not find crash dumps for '{}' in search directory '{}'.\n"
|
2019-08-05 20:34:31 +00:00
|
|
|
"Existing files which *did not* match the pattern inside the search "
|
2020-06-30 13:22:30 +00:00
|
|
|
"directory are are:\n {}\n".format(missing_as_string,
|
|
|
|
self._search_dir,
|
|
|
|
'\n '.join(other_files)))
|
2019-08-05 20:34:31 +00:00
|
|
|
# TODO: Figure out why windows coredump generation does not work.
|
|
|
|
# See http://dartbug.com/36469
|
|
|
|
if throw and GuessOS() != 'win32':
|
2020-06-30 13:22:30 +00:00
|
|
|
raise Exception(
|
|
|
|
'Missing crash dumps for: {}'.format(missing_as_string))
|
2019-08-05 20:34:31 +00:00
|
|
|
|
|
|
|
def _get_file_name(self, file):
|
|
|
|
# Sanitize the name: actual cores follow 'core.%d' pattern, crashed
|
|
|
|
# binaries are copied next to cores and named
|
|
|
|
# 'binary.<mode>_<arch>_<binary_name>'.
|
|
|
|
# This should match the code in testing/dart/test_progress.dart
|
|
|
|
name = os.path.basename(file)
|
|
|
|
(prefix, suffix) = name.split('.', 1)
|
|
|
|
is_binary = prefix == 'binary'
|
|
|
|
if is_binary:
|
|
|
|
(mode, arch, binary_name) = suffix.split('_', 2)
|
|
|
|
name = binary_name
|
|
|
|
return (name, is_binary)
|
|
|
|
|
|
|
|
def _move(self, files):
|
|
|
|
for file in files:
|
2020-06-30 13:22:30 +00:00
|
|
|
print('+++ Moving {} to output_directory ({})'.format(
|
|
|
|
file, self._output_directory))
|
2019-08-05 20:34:31 +00:00
|
|
|
(name, is_binary) = self._get_file_name(file)
|
|
|
|
destination = os.path.join(self._output_directory, name)
|
|
|
|
shutil.move(file, destination)
|
|
|
|
if is_binary and os.path.exists(file + '.pdb'):
|
|
|
|
# Also move a PDB file if there is one.
|
|
|
|
pdb = os.path.join(self._output_directory, name + '.pdb')
|
|
|
|
shutil.move(file + '.pdb', pdb)
|
|
|
|
|
|
|
|
def _tar(self, file):
|
|
|
|
(name, is_binary) = self._get_file_name(file)
|
2020-06-30 13:22:30 +00:00
|
|
|
tarname = '{}.tar.gz'.format(name)
|
2019-08-05 20:34:31 +00:00
|
|
|
|
|
|
|
# Compress the file.
|
|
|
|
tar = tarfile.open(tarname, mode='w:gz')
|
|
|
|
tar.add(file, arcname=name)
|
|
|
|
if is_binary and os.path.exists(file + '.pdb'):
|
|
|
|
# Also add a PDB file if there is one.
|
|
|
|
tar.add(file + '.pdb', arcname=name + '.pdb')
|
|
|
|
tar.close()
|
|
|
|
return tarname
|
|
|
|
|
|
|
|
def _upload(self, files):
|
|
|
|
bot_utils = GetBotUtils()
|
|
|
|
gsutil = bot_utils.GSUtil()
|
2020-06-30 13:22:30 +00:00
|
|
|
storage_path = '{}/{}/'.format(self._bucket, uuid.uuid4())
|
|
|
|
gs_prefix = 'gs://{}'.format(storage_path)
|
|
|
|
http_prefix = 'https://storage.cloud.google.com/{}'.format(storage_path)
|
2019-08-05 20:34:31 +00:00
|
|
|
|
2020-06-30 13:22:30 +00:00
|
|
|
print('\n--- Uploading into {} ({}) ---'.format(gs_prefix, http_prefix))
|
2019-08-05 20:34:31 +00:00
|
|
|
for file in files:
|
|
|
|
tarname = self._tar(file)
|
|
|
|
|
|
|
|
# Remove / from absolute path to not have // in gs path.
|
2020-06-30 13:22:30 +00:00
|
|
|
gs_url = '{}{}'.format(gs_prefix, tarname)
|
|
|
|
http_url = '{}{}'.format(http_prefix, tarname)
|
2019-08-05 20:34:31 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
gsutil.upload(tarname, gs_url)
|
2020-06-30 13:22:30 +00:00
|
|
|
print('+++ Uploaded {} ({})'.format(gs_url, http_url))
|
2019-08-05 20:34:31 +00:00
|
|
|
except Exception as error:
|
2020-06-30 13:22:30 +00:00
|
|
|
print('!!! Failed to upload {}, error: {}'.format(
|
|
|
|
tarname, error))
|
2019-08-05 20:34:31 +00:00
|
|
|
|
|
|
|
TryUnlink(tarname)
|
|
|
|
|
|
|
|
print('--- Done ---\n')
|
|
|
|
|
|
|
|
def _find_all_coredumps(self):
|
|
|
|
"""Return coredumps that were recorded (if supported by the platform).
|
2022-12-21 17:26:48 +00:00
|
|
|
This method will be overridden by concrete platform specific implementations.
|
2020-06-30 13:22:30 +00:00
|
|
|
"""
|
2019-08-05 20:34:31 +00:00
|
|
|
return []
|
2018-10-25 15:31:27 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def _find_unexpected_crashes(self):
|
|
|
|
"""Load coredumps file. Each line has the following format:
|
2017-02-14 15:34:31 +00:00
|
|
|
|
2019-02-15 18:00:51 +00:00
|
|
|
test-name,pid,binary-file1,binary-file2,...
|
2020-06-30 13:22:30 +00:00
|
|
|
"""
|
2019-08-05 20:34:31 +00:00
|
|
|
try:
|
|
|
|
with open(BaseCoreDumpArchiver._UNEXPECTED_CRASHES_FILE) as f:
|
|
|
|
return [
|
|
|
|
UnexpectedCrash(*ln.strip('\n').split(','))
|
|
|
|
for ln in f.readlines()
|
|
|
|
]
|
|
|
|
except:
|
|
|
|
return []
|
|
|
|
|
|
|
|
def _cleanup(self):
|
|
|
|
found = False
|
|
|
|
if os.path.exists(BaseCoreDumpArchiver._UNEXPECTED_CRASHES_FILE):
|
|
|
|
os.unlink(BaseCoreDumpArchiver._UNEXPECTED_CRASHES_FILE)
|
|
|
|
found = True
|
|
|
|
for binary in glob.glob(os.path.join(self._binaries_dir, 'binary.*')):
|
|
|
|
found = True
|
|
|
|
TryUnlink(binary)
|
|
|
|
|
|
|
|
return found
|
2018-10-26 18:17:18 +00:00
|
|
|
|
2017-02-14 15:34:31 +00:00
|
|
|
|
2017-04-19 08:36:18 +00:00
|
|
|
class PosixCoreDumpArchiver(BaseCoreDumpArchiver):
|
2017-02-14 15:34:31 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def __init__(self, search_dir, output_directory):
|
|
|
|
super(PosixCoreDumpArchiver, self).__init__(search_dir,
|
|
|
|
output_directory)
|
|
|
|
|
|
|
|
def _cleanup(self):
|
|
|
|
found = super(PosixCoreDumpArchiver, self)._cleanup()
|
|
|
|
for core in glob.glob(os.path.join(self._search_dir, 'core.*')):
|
|
|
|
found = True
|
|
|
|
TryUnlink(core)
|
|
|
|
return found
|
2017-02-14 15:34:31 +00:00
|
|
|
|
2019-08-05 20:34:31 +00:00
|
|
|
def _find_coredump_file(self, crash):
|
2020-06-30 13:22:30 +00:00
|
|
|
core_filename = os.path.join(self._search_dir,
|
|
|
|
'core.{}'.format(crash.pid))
|
2019-08-05 20:34:31 +00:00
|
|
|
if os.path.exists(core_filename):
|
|
|
|
return core_filename
|
2017-02-14 15:34:31 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2017-04-19 08:36:18 +00:00
|
|
|
class LinuxCoreDumpArchiver(PosixCoreDumpArchiver):
|
2019-08-05 20:34:31 +00:00
|
|
|
|
|
|
|
def __init__(self, output_directory):
|
|
|
|
super(LinuxCoreDumpArchiver, self).__init__(os.getcwd(),
|
|
|
|
output_directory)
|
2017-04-19 08:36:18 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2017-04-19 08:36:18 +00:00
|
|
|
class MacOSCoreDumpArchiver(PosixCoreDumpArchiver):
|
2019-08-05 20:34:31 +00:00
|
|
|
|
|
|
|
def __init__(self, output_directory):
|
|
|
|
super(MacOSCoreDumpArchiver, self).__init__('/cores', output_directory)
|
2017-04-19 08:36:18 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2017-02-14 15:34:31 +00:00
|
|
|
class WindowsCoreDumpArchiver(BaseCoreDumpArchiver):
|
2019-08-05 20:34:31 +00:00
|
|
|
|
|
|
|
def __init__(self, output_directory):
|
|
|
|
super(WindowsCoreDumpArchiver, self).__init__(
|
|
|
|
WindowsCoreDumpEnabler.DUMPS_FOLDER, output_directory)
|
|
|
|
self._dumps_by_pid = None
|
|
|
|
|
|
|
|
# Find CDB.exe in the win_toolchain that we are using.
|
|
|
|
def _find_cdb(self):
|
|
|
|
win_toolchain_json_path = os.path.join(DART_DIR, 'build',
|
|
|
|
'win_toolchain.json')
|
|
|
|
if not os.path.exists(win_toolchain_json_path):
|
|
|
|
return None
|
|
|
|
|
2020-06-30 13:22:30 +00:00
|
|
|
with open(win_toolchain_json_path, 'r') as f:
|
2019-08-05 20:34:31 +00:00
|
|
|
win_toolchain_info = json.loads(f.read())
|
|
|
|
|
|
|
|
win_sdk_path = win_toolchain_info['win_sdk']
|
|
|
|
|
|
|
|
# We assume that we are running on 64-bit Windows.
|
|
|
|
# Note: x64 CDB can work with both X64 and IA32 dumps.
|
|
|
|
cdb_path = os.path.join(win_sdk_path, 'Debuggers', 'x64', 'cdb.exe')
|
|
|
|
if not os.path.exists(cdb_path):
|
|
|
|
return None
|
|
|
|
|
|
|
|
return cdb_path
|
|
|
|
|
|
|
|
CDBG_PROMPT_RE = re.compile(r'^\d+:\d+>')
|
|
|
|
|
|
|
|
def _dump_all_stacks(self):
|
|
|
|
# On Windows due to crashpad integration crashes do not produce any
|
|
|
|
# stacktraces. Dump stack traces from dumps Crashpad collected using
|
|
|
|
# CDB (if available).
|
|
|
|
cdb_path = self._find_cdb()
|
|
|
|
if cdb_path is None:
|
|
|
|
return
|
|
|
|
|
|
|
|
dumps = self._find_all_coredumps()
|
|
|
|
if not dumps:
|
|
|
|
return
|
|
|
|
|
2020-06-30 13:22:30 +00:00
|
|
|
print('### Collected {} crash dumps'.format(len(dumps)))
|
2019-08-05 20:34:31 +00:00
|
|
|
for dump in dumps:
|
|
|
|
print()
|
2020-06-30 13:22:30 +00:00
|
|
|
print('### Dumping stacks from {} using CDB'.format(dump))
|
2019-08-05 20:34:31 +00:00
|
|
|
cdb_output = subprocess.check_output(
|
2020-06-30 13:22:30 +00:00
|
|
|
'"{}" -z "{}" -kqm -c "!uniqstack -b -v -p;qd"'.format(
|
|
|
|
cdb_path, dump),
|
2019-08-05 20:34:31 +00:00
|
|
|
stderr=subprocess.STDOUT)
|
|
|
|
# Extract output of uniqstack from the whole output of CDB.
|
|
|
|
output = False
|
|
|
|
for line in cdb_output.split('\n'):
|
|
|
|
if re.match(WindowsCoreDumpArchiver.CDBG_PROMPT_RE, line):
|
|
|
|
output = True
|
2020-06-30 13:22:30 +00:00
|
|
|
elif line.startswith('quit:'):
|
2019-08-05 20:34:31 +00:00
|
|
|
break
|
|
|
|
elif output:
|
|
|
|
print(line)
|
|
|
|
print()
|
2020-06-30 13:22:30 +00:00
|
|
|
print('#############################################')
|
2019-08-05 20:34:31 +00:00
|
|
|
print()
|
|
|
|
|
|
|
|
def __exit__(self, *args):
|
|
|
|
try:
|
|
|
|
self._dump_all_stacks()
|
|
|
|
except Exception as error:
|
2020-06-30 13:22:30 +00:00
|
|
|
print('ERROR: Unable to dump stacks from dumps: {}'.format(error))
|
2019-08-05 20:34:31 +00:00
|
|
|
|
|
|
|
super(WindowsCoreDumpArchiver, self).__exit__(*args)
|
|
|
|
|
|
|
|
def _cleanup(self):
|
|
|
|
found = super(WindowsCoreDumpArchiver, self)._cleanup()
|
|
|
|
for core in glob.glob(os.path.join(self._search_dir, '*')):
|
|
|
|
found = True
|
|
|
|
TryUnlink(core)
|
|
|
|
return found
|
|
|
|
|
|
|
|
def _find_all_coredumps(self):
|
|
|
|
pattern = os.path.join(self._search_dir, '*.dmp')
|
|
|
|
return [core_filename for core_filename in glob.glob(pattern)]
|
|
|
|
|
|
|
|
def _find_coredump_file(self, crash):
|
|
|
|
if self._dumps_by_pid is None:
|
|
|
|
# If this function is invoked the first time then look through the directory
|
|
|
|
# that contains crashes for all dump files and collect pid -> filename
|
|
|
|
# mapping.
|
|
|
|
self._dumps_by_pid = {}
|
|
|
|
minidump = GetMinidumpUtils()
|
|
|
|
pattern = os.path.join(self._search_dir, '*.dmp')
|
|
|
|
for core_filename in glob.glob(pattern):
|
|
|
|
pid = minidump.GetProcessIdFromDump(core_filename)
|
|
|
|
if pid != -1:
|
|
|
|
self._dumps_by_pid[str(pid)] = core_filename
|
|
|
|
if crash.pid in self._dumps_by_pid:
|
|
|
|
return self._dumps_by_pid[crash.pid]
|
|
|
|
|
2021-05-20 11:49:16 +00:00
|
|
|
def _report_missing_crashes(self, missing, throw=False):
|
2019-08-05 20:34:31 +00:00
|
|
|
# Let's only print the debugging information and not throw. We'll do more
|
|
|
|
# validation for werfault.exe and throw afterwards.
|
|
|
|
super(WindowsCoreDumpArchiver, self)._report_missing_crashes(
|
|
|
|
missing, throw=False)
|
|
|
|
|
|
|
|
if throw:
|
|
|
|
missing_as_string = ', '.join([str(c) for c in missing])
|
2020-06-30 13:22:30 +00:00
|
|
|
raise Exception(
|
|
|
|
'Missing crash dumps for: {}'.format(missing_as_string))
|
2019-08-05 20:34:31 +00:00
|
|
|
|
2017-02-24 16:06:28 +00:00
|
|
|
|
2023-09-26 15:11:41 +00:00
|
|
|
class IncreasedNumberOfFileDescriptors(object):
|
|
|
|
|
|
|
|
def __init__(self, nofiles):
|
|
|
|
self._old_limits = None
|
|
|
|
self._limits = (nofiles, nofiles)
|
|
|
|
|
|
|
|
def __enter__(self):
|
|
|
|
self._old_limits = resource.getrlimit(resource.RLIMIT_NOFILE)
|
|
|
|
resource.setrlimit(resource.RLIMIT_NOFILE, self._limits)
|
|
|
|
|
|
|
|
def __exit__(self, *_):
|
|
|
|
resource.setrlimit(resource.RLIMIT_CORE, self._old_limits)
|
|
|
|
|
|
|
|
|
2017-02-14 15:34:31 +00:00
|
|
|
@contextlib.contextmanager
|
2018-10-16 09:25:10 +00:00
|
|
|
def NooptContextManager():
|
2019-08-05 20:34:31 +00:00
|
|
|
yield
|
2017-02-14 15:34:31 +00:00
|
|
|
|
2018-02-16 20:44:48 +00:00
|
|
|
|
2017-02-14 15:34:31 +00:00
|
|
|
def CoreDumpArchiver(args):
|
2019-08-05 20:34:31 +00:00
|
|
|
enabled = '--copy-coredumps' in args
|
|
|
|
prefix = '--output-directory='
|
|
|
|
output_directory = next(
|
|
|
|
(arg[len(prefix):] for arg in args if arg.startswith(prefix)), None)
|
|
|
|
|
|
|
|
if not enabled:
|
2021-04-15 10:10:20 +00:00
|
|
|
return (NooptContextManager(),)
|
2019-08-05 20:34:31 +00:00
|
|
|
|
|
|
|
osname = GuessOS()
|
|
|
|
if osname == 'linux':
|
2021-04-15 10:10:20 +00:00
|
|
|
return (LinuxCoreDumpEnabler(), LinuxCoreDumpArchiver(output_directory))
|
2019-08-05 20:34:31 +00:00
|
|
|
elif osname == 'macos':
|
2021-04-15 10:10:20 +00:00
|
|
|
return (PosixCoreDumpEnabler(), MacOSCoreDumpArchiver(output_directory))
|
2019-08-05 20:34:31 +00:00
|
|
|
elif osname == 'win32':
|
2021-04-15 10:10:20 +00:00
|
|
|
return (WindowsCoreDumpEnabler(),
|
|
|
|
WindowsCoreDumpArchiver(output_directory))
|
2020-06-30 13:22:30 +00:00
|
|
|
|
|
|
|
# We don't have support for MacOS yet.
|
2021-04-15 10:10:20 +00:00
|
|
|
return (NooptContextManager(),)
|
2019-08-05 20:34:31 +00:00
|
|
|
|
2018-10-16 09:25:10 +00:00
|
|
|
|
|
|
|
def FileDescriptorLimitIncreaser():
|
2019-08-05 20:34:31 +00:00
|
|
|
osname = GuessOS()
|
|
|
|
if osname == 'macos':
|
|
|
|
return IncreasedNumberOfFileDescriptors(nofiles=10000)
|
2020-06-30 13:22:30 +00:00
|
|
|
|
|
|
|
assert osname in ('linux', 'win32')
|
|
|
|
# We don't have support for MacOS yet.
|
|
|
|
return NooptContextManager()
|
2019-08-05 20:34:31 +00:00
|
|
|
|
2017-01-19 16:25:39 +00:00
|
|
|
|
2020-06-29 15:05:23 +00:00
|
|
|
def Main():
|
2020-06-30 13:22:30 +00:00
|
|
|
print('GuessOS() -> ', GuessOS())
|
|
|
|
print('GuessArchitecture() -> ', GuessArchitecture())
|
|
|
|
print('GuessCpus() -> ', GuessCpus())
|
|
|
|
print('IsWindows() -> ', IsWindows())
|
|
|
|
print('GetGitRevision() -> ', GetGitRevision())
|
|
|
|
print('GetGitTimestamp() -> ', GetGitTimestamp())
|
2024-01-12 16:38:51 +00:00
|
|
|
print('ReadVersionFile() -> ', ReadVersionFile())
|
2020-06-30 13:22:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2019-08-05 20:34:31 +00:00
|
|
|
Main()
|