Add --environment-version, currently just for Windows targets.
authorCarl Hetherington <cth@carlh.net>
Mon, 3 Feb 2020 22:28:44 +0000 (23:28 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 3 Feb 2020 22:28:44 +0000 (23:28 +0100)
cdist

diff --git a/cdist b/cdist
index e5af8f53e595d2084418454140f97e2e78db52cc..139968052bf63298b20b3b788443b4bf55f327df 100755 (executable)
--- a/cdist
+++ b/cdist
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-#    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+#    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
 #
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -514,9 +514,8 @@ class Target(object):
 
 
 class DockerTarget(Target):
-    def __init__(self, platform, directory, version):
+    def __init__(self, platform, directory):
         super(DockerTarget, self).__init__(platform, directory)
-        self.version = version
         self.mounts = []
         self.privileged = False
 
@@ -589,8 +588,9 @@ class WindowsTarget(DockerTarget):
     environment_prefix: path to Windows environment for the appropriate target (libraries and some tools)
     tool_path: path to 32- and 64-bit tools
     """
-    def __init__(self, version, bits, directory=None):
-        super(WindowsTarget, self).__init__('windows', directory, version)
+    def __init__(self, windows_version, bits, directory, environment_version):
+        super(WindowsTarget, self).__init__('windows', directory)
+        self.version = windows_version
         self.bits = bits
 
         self.tool_path = '%s/usr/bin' % config.get('mxe_prefix')
@@ -616,6 +616,8 @@ class WindowsTarget(DockerTarget):
         self.set('LDFLAGS', '"%s"' % link)
 
         self.image = 'windows'
+        if environment_version is not None:
+            self.image += '_%s' % environment_version
 
     @property
     def library_prefix(self):
@@ -655,8 +657,9 @@ class LinuxTarget(DockerTarget):
     """
 
     def __init__(self, distro, version, bits, directory=None):
-        super(LinuxTarget, self).__init__('linux', directory, version)
+        super(LinuxTarget, self).__init__('linux', directory)
         self.distro = distro
+        self.version = version
         self.bits = bits
         self.detail = None
 
@@ -798,9 +801,9 @@ def target_factory(args):
     if s.startswith('windows-'):
         x = s.split('-')
         if len(x) == 2:
-            target = WindowsTarget(None, int(x[1]), args.work)
+            target = WindowsTarget(None, int(x[1]), args.work, args.environment_version)
         elif len(x) == 3:
-            target = WindowsTarget(x[1], int(x[2]), args.work)
+            target = WindowsTarget(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-'):
@@ -1015,6 +1018,7 @@ def main():
     parser.add_argument('-o', '--output', help='output directory', default='.')
     parser.add_argument('-q', '--quiet', help='be quiet', action='store_true')
     parser.add_argument('-t', '--target', help='target', action='append')
+    parser.add_argument('--environment-version', help='version of environment to use')
     parser.add_argument('-k', '--keep', help='keep working tree', action='store_true')
     parser.add_argument('--debug', help='build with debugging symbols where possible', action='store_true')
     parser.add_argument('-w', '--work', help='override default work directory')