## @file
#
# Automation of instructions from:
# howto-build/mingw-w64-howto-build.txt?revision=216&view=markup
#
# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>
# 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
import os
import shutil
import subprocess
import sys
import tarfile
import urllib
import urlparse
try:
except Exception:
#
# This script (and edk2 BaseTools) require Python 2.5 or newer
#
print 'Python version 2.5 or later is required.'
#
# Version and Copyright
#
class Config:
"""class Config
Stores the configuration options for the rest of the script.
Handles the command line options, and allows the code within
the script to easily interact with the 'config' requested by
the user.
"""
Parser = \
prog="mingw-gcc-build",
usage="%prog [options] [target]"
)
"--arch",
default = '',
dest = "arch",
help = "Processor architecture to build gcc for."
)
"--src-dir",
)
"--build-dir",
)
"--prefix",
)
"--skip-binutils",
help = "Will skip building binutils"
)
"--skip-gcc",
help = "Will skip building GCC"
)
"--symlinks",
)
"-v", "--verbose",
action="store_true",
)
'Please use --arch to specify one of: %s' %
)
building = []
print "Nothing will be built!"
print
print "Please try using --help and then change the configuration."
return False
print "Current directory:"
print
print
print "Please try using --help and then change the configuration."
return False
print
print 'Please note that the IPF compiler built by this script has'
print 'not yet been validated!'
print
print
print "Please try using --help and then change the configuration."
return False
print
return True
return path
class SourceFiles:
"""class SourceFiles
Handles the downloading of source files used by the script.
"""
'binutils': {
'url': 'http://www.kernel.org/pub/linux/devel/binutils/' + \
'binutils-$version.tar.bz2',
'version': '2.20.51.0.5',
'md5': '6d2de7cdf7a8389e70b124e3d73b4d37',
},
}
source_files_x64 = {
'gcc': {
'url': 'http://ftpmirror.gnu.org/gcc/' + \
'version': '4.3.0',
'md5': '197ed8468b38db1d3481c3111691d85b',
},
}
}
'--with-gnu-as', '--with-gnu-ld', '--with-newlib',
'--verbose', '--disable-libssp', '--disable-nls',
'--enable-languages=c,c++'
)
source_files = {
}
for arch in source_files:
mergedSourceFiles = {}
for downloadItem in mergedSourceFiles:
if 'extract-dir' not in fdata:
break
for replaceItem in fdata:
if replaceItem in replaceables: continue
for replaceable in replaceables:
if replaceable in fdata:
fdata[replaceable] = \
'$' + replaceItem,
)
#print 'source_files:', source_files
if fileSize < 0: return
print '.',
maxRetries = 1
try:
if retries > 0:
print '(retry)',
if md5_pass:
print '[md5 match]',
else:
print '[md5 mismatch]',
if not completed:
#
# BUGBUG: Suggest proxy to user if download fails.
#
# export http_proxy=http://proxyservername.mycompany.com:911
# export ftp_proxy=http://proxyservername.mycompany.com:911
if md5_pass:
print '[md5 match]',
else:
print '[md5 mismatch]',
if completed:
print '[done]'
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 Exception, e:
print e
return True
else:
return tuple()
class Extracter:
"""class Extracter
Handles the extraction of the source files from their downloaded
archive files.
"""
extractedMd5 = None
if extractedMd5 != moduleMd5:
else:
pass
#print 'Previously extracted', self.config.Relative(local_file)
class Builder:
"""class Builder
Builds and installs the GCC tool suite.
"""
return \
)
)
open(
),
"w"
).close()
cmd = (
'--prefix=' + prefix,
'--with-sysroot=' + prefix,
'--disable-werror',
)
cmd = ('make',)
if module == 'gcc':
cmd += ('all-gcc',)
cmd = ('make',)
if module == 'gcc':
cmd += ('install-gcc',)
else:
cmd += ('install',)
print '%s module is now built and installed' % module
if skipable:
return
cmd,
)
p.wait()
if p.returncode != 0:
print '[failed!]'
f.close()
else:
print '[done]'
if skipable:
)
if not startPrinted:
print link,
if startPrinted:
print '[done]'
class App:
"""class App
The main body of the application.
"""
if not config.IsConfigOk():
return
if result:
print 'All files have been downloaded & verified'
else:
print 'An error occured while downloading a file'
return
App()