]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/gcc/mingw-gcc-build.py
Sync EDKII BaseTools to BaseTools project r1911.
[mirror_edk2.git] / BaseTools / gcc / mingw-gcc-build.py
old mode 100644 (file)
new mode 100755 (executable)
index 73eb3de..4133feb
@@ -1,10 +1,21 @@
 #!/usr/bin/env python
 
+## @file
 #
 # Automation of instructions from:
 #   http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64/trunk/mingw-w64-doc/
 #     howto-build/mingw-w64-howto-build.txt?revision=216&view=markup
 #
+# Copyright (c) 2008 - 2010, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution.    The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+
 
 from optparse import OptionParser
 import os
@@ -19,12 +30,19 @@ try:
 except Exception:
     from md5 import md5
 
+if sys.version_info < (2, 5):
+    #
+    # This script (and edk2 BaseTools) require Python 2.5 or newer
+    #
+    print 'Python version 2.5 or later is required.'
+    sys.exit(-1)
+
 #
 # Version and Copyright
 #
 VersionNumber = "0.01"
 __version__ = "%prog Version " + VersionNumber
-__copyright__ = "Copyright (c) 2008, Intel Corporation.  All rights reserved."
+__copyright__ = "Copyright (c) 2008 - 2010, Intel Corporation.  All rights reserved."
 
 class Config:
     """class Config
@@ -74,6 +92,18 @@ class Config:
             default = os.path.join(self.base_dir, 'install'),
             help = "Prefix to install binutils/gcc into"
             )
+        Parser.add_option(
+            "--skip-binutils",
+            action = "store_true", dest = "skip_binutils",
+            default = False,
+            help = "Will skip building binutils"
+            )
+        Parser.add_option(
+            "--skip-gcc",
+            action = "store_true", dest = "skip_gcc",
+            default = False,
+            help = "Will skip building GCC"
+            )
         Parser.add_option(
             "--symlinks",
             action = "store", type = "string", dest = "symlinks",
@@ -109,13 +139,25 @@ class Config:
         self.symlinks = os.path.realpath(os.path.expanduser(self.options.symlinks))
 
     def IsConfigOk(self):
-                
+
+        building = []
+        if not self.options.skip_binutils:
+            building.append('binutils')
+        if not self.options.skip_gcc:
+            building.append('gcc')
+        if len(building) == 0:
+            print "Nothing will be built!"
+            print
+            print "Please try using --help and then change the configuration."
+            return False
+
         print "Current directory:"
         print "   ", self.base_dir
         print "Sources download/extraction:", self.Relative(self.src_dir)
         print "Build directory            :", self.Relative(self.build_dir)
         print "Prefix (install) directory :", self.Relative(self.prefix)
         print "Create symlinks directory  :", self.Relative(self.symlinks)
+        print "Building                   :", ', '.join(building)
         print
         answer = raw_input("Is this configuration ok? (default = no): ")
         if (answer.lower() not in ('y', 'yes')):
@@ -157,50 +199,49 @@ class SourceFiles:
         self.config = config
         self.source_files = self.source_files[config.arch]
 
+        if config.options.skip_binutils:
+            del self.source_files['binutils']
+
+        if config.options.skip_gcc:
+            del self.source_files['gcc']
+            del self.source_files['mingw_hdr']
+
     source_files_common = {
         'binutils': {
             'url': 'http://www.kernel.org/pub/linux/devel/binutils/' + \
                    'binutils-$version.tar.bz2',
-            'version': '2.18.50.0.5',
-            'md5': 'daee18dbbf0a6ccfc186141bee18bf62',
+            'version': '2.20.51.0.5',
+            'md5': '6d2de7cdf7a8389e70b124e3d73b4d37',
             },
         }
 
     source_files_x64 = {
         'gcc': {
-            'url': 'http://gcc-ca.internet.bs/releases/' + \
+            'url': 'http://ftpmirror.gnu.org/gcc/' + \
                    'gcc-$version/gcc-$version.tar.bz2',
             'version': '4.3.0',
             'md5': '197ed8468b38db1d3481c3111691d85b',
             },
         'mingw_hdr': {
-            'url': 'http://superb-west.dl.sourceforge.net/sourceforge/' + \
-                   'mingw-w64/mingw-w64-snapshot-$version.tar.bz2',
-            'extract-dir': os.path.join('trunk', 'mingw-w64-headers'),
-            'version': '20080310',
-            'md5': '235b2d15c2411f7d213c0c0977b2162f',
+            'url': 'http://sourceforge.net/projects/' + \
+                   'mingw-w64/files/mingw-w64/mingw-w64-snapshot/' + \
+                   'mingw-w64-v1.0-snapshot-$version.tar.bz2/download',
+            'extract-dir': os.path.join('mingw-w64-v1.0-$version', 'mingw-w64-headers'),
+            'version': '20100223',
+            'md5': '700b9f54e740b1b962c8a3a0f52b7c04',
             },
         }
 
     source_files_ia32 = {
-        'gcc': {
-            'url': 'http://superb-east.dl.sourceforge.net/sourceforge/' + \
-                   'mingw/gcc-$version-mingw-$minor_version-src.tar.gz',
-            'version': '4.3.0',
-            'minor_version': 'alpha-20080403',
-            'extract-dir': 'gcc-$version',
-            'md5': '27961d80e304f4ef32c980833c6e8e44',
-            'configure-params': ('--with-gnu-as', '--with-gnu-ld', '--with-newlib',
-                                 '--verbose', '--disable-libssp', '--disable-nls',
-                                 '--enable-languages=c,c++'
-                                )
-            },
+        'gcc': source_files_x64['gcc'],
         'mingw_hdr': {
-            'url': 'http://superb-west.dl.sourceforge.net/sourceforge/' + \
-                   'mingw/mingw-runtime-$version-src.tar.gz',
-            'extract-dir': 'mingw-runtime-$version',
-            'version': '3.14',
-            'md5': '7d049a8331efcfe34600c0cda6934ac6',
+            'url': 'http://sourceforge.net/projects/' + \
+                   'mingw/files/MinGW%20Runtime/' + \
+                   'mingwrt-$version/' + \
+                   'mingwrt-$version-mingw32-src.tar.gz/download',
+            'extract-dir': 'mingwrt-$version-mingw32',
+            'version': '3.15.2',
+            'md5': '7bf0525f158213f3ac990ea68a5ec34d',
             },
         }
 
@@ -255,14 +296,14 @@ class SourceFiles:
                     sys.stdout.flush()
                     self.dots += 1
 
-        maxRetries = 3
+        maxRetries = 1
         for (fname, fdata) in self.source_files.items():
             for retries in range(maxRetries):
                 try:
                     self.dots = 0
                     local_file = os.path.join(self.config.src_dir, fdata['filename'])
                     url = fdata['url']
-                    print 'Downloading %s:' % fname,
+                   print 'Downloading %s:' % fname, url
                     if retries > 0:
                         print '(retry)',
                     sys.stdout.flush()
@@ -300,14 +341,21 @@ class SourceFiles:
                         break
                     else:
                         print '[failed]'
+                        print '  Tried to retrieve', url
+                        print '  to', local_file
+                        print 'Possible fixes:'
+                        print '* If you are behind a web-proxy, try setting the',
+                        print 'http_proxy environment variable'
+                        print '* You can try to download this file separately',
+                        print 'and rerun this script'
                         raise Exception()
                 
                 except KeyboardInterrupt:
                     print '[KeyboardInterrupt]'
                     return False
 
-                except:
-                    pass
+                except Exception, e:
+                    print e
 
             if not completed: return False
 
@@ -388,10 +436,12 @@ class Builder:
         self.config = config
 
     def Build(self):
-        self.BuildModule('binutils')
-        self.CopyIncludeDirectory()
-        self.BuildModule('gcc')
-        self.MakeSymLinks()
+        if not self.config.options.skip_binutils:
+            self.BuildModule('binutils')
+        if not self.config.options.skip_gcc:
+            self.CopyIncludeDirectory()
+            self.BuildModule('gcc')
+            self.MakeSymLinks()
 
     def IsBuildStepComplete(self, step):
         return \