import inspect
import multiprocessing
import os
+import platform
import re
import shlex
import shutil
def command(c):
log_normal(c)
- r = os.system(c)
- if (r >> 8):
- raise Error('command %s failed' % c)
+ try:
+ r = subprocess.run(c, shell=True)
+ if r.returncode != 0:
+ raise Error('command %s failed (%d)' % (c, r.returncode))
+ except Exception as e:
+ raise Error('command %s failed (%s)' % (c, e))
def command_and_read(c):
log_normal(c)
return b
-class WindowsTarget(DockerTarget):
+class WindowsDockerTarget(DockerTarget):
"""
This target exposes the following additional API:
tool_path: path to 32- and 64-bit tools
"""
def __init__(self, windows_version, bits, directory, environment_version):
- super(WindowsTarget, self).__init__('windows', directory)
+ super(WindowsDockerTarget, self).__init__('windows', directory)
self.version = windows_version
self.bits = bits
return self.name
+class WindowsNativeTarget(Target):
+ """
+ This target exposes the following additional API:
+
+ version: Windows version ('xp' or None)
+ bits: bitness of Windows (32 or 64)
+ name: name of our target e.g. x86_64-w64-mingw32.shared
+ environment_prefix: path to Windows environment for the appropriate target (libraries and some tools)
+ """
+ def __init__(self, directory):
+ super().__init__('windows', directory)
+ self.version = None
+ self.bits = 64
+
+ self.environment_prefix = config.get('windows_native_environmnet_prefix')
+
+ self.set('PATH', '%s/bin:%s' % (self.environment_prefix, os.environ['PATH']))
+
+ def command(self, cmd):
+ command(cmd)
+
+
class LinuxTarget(DockerTarget):
"""
Build for Linux in a docker container.
def string_after(process, key):
lines = p.stdout.decode('utf-8').splitlines()
- request_uuid = None
for i in range(0, len(lines)):
if lines[i].find(key) != -1:
return lines[i+1].strip().replace('<string>', '').replace('</string>', '')
- raise Error("Missing expected response %s from Apple" % key)
-
request_uuid = string_after(p, "RequestUUID")
+ if request_uuid is None:
+ raise Error('No RequestUUID found in response from Apple')
for i in range(0, 30):
print('Checking up on %s' % request_uuid)
def cleanup(self):
rmtree(self.directory)
- def package(self, project, checkout, output_dir, options):
+ def package(self, project, checkout, output_dir, options, no_notarize):
tree = globals.trees.get(project, checkout, self)
with TreeDirectory(tree):
name = read_wscript_variable(os.getcwd(), 'APPNAME')
target = None
if s.startswith('windows-'):
x = s.split('-')
- if len(x) == 2:
- target = WindowsTarget(None, int(x[1]), args.work, args.environment_version)
- elif len(x) == 3:
- target = WindowsTarget(x[1], int(x[2]), args.work, args.environment_version)
+ if platform.system() == "Windows":
+ target = WindowsNativeTarget(args.work)
else:
- raise Error("Bad Windows target name `%s'")
+ if len(x) == 2:
+ target = WindowsDockerTarget(None, int(x[1]), args.work, args.environment_version)
+ elif len(x) == 3:
+ target = WindowsDockerTarget(x[1], int(x[2]), args.work, args.environment_version)
+ else:
+ raise Error("Bad Windows target name `%s'")
elif s.startswith('ubuntu-') or s.startswith('debian-') or s.startswith('centos-') or s.startswith('fedora-') or s.startswith('mageia-'):
p = s.split('-')
if len(p) != 3:
try:
self.version = Version(v)
except:
- tag = command_and_read('git -C %s describe --tags' % proj)[0][1:]
- self.version = Version.from_git_tag(tag)
+ try:
+ tag = command_and_read('git -C %s describe --tags' % proj)[0][1:]
+ self.version = Version.from_git_tag(tag)
+ except:
+ # We'll leave version as None if we can't read it; maybe this is a bad idea
+ # Should probably just install git on the Windows VM
+ pass
os.chdir(cwd)
parser_manual = subparsers.add_parser("manual", help="build the project's manual")
parser_doxygen = subparsers.add_parser("doxygen", help="build the project's Doxygen documentation")
parser_latest = subparsers.add_parser("latest", help="print out the latest version")
- parser_latest.add_argument('--latest-major', help='major version to return', type=int)
- parser_latest.add_argument('--latest-minor', help='minor version to return', type=int)
+ parser_latest.add_argument('--major', help='major version to return', type=int)
+ parser_latest.add_argument('--minor', help='minor version to return', type=int)
parser_test = subparsers.add_parser("test", help="build the project and run its unit tests")
parser_test.add_argument('--no-implicit-build', help='do not build first', action='store_true')
parser_test.add_argument('--test', help="name of test to run, defaults to all")
t = s[1]
if len(t) > 0 and t[0] == 'v':
v = Version(t[1:])
- if (args.latest_major is None or v.major == args.latest_major) and (args.latest_minor is None or v.minor == args.latest_minor):
+ if (args.major is None or v.major == args.major) and (args.minor is None or v.minor == args.minor):
latest = v
print(latest)