From 2c630fa5331912b7661527b14758e968aed80a0a Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 1 Mar 2016 21:44:16 -0800 Subject: [PATCH] Move the Cygwin location code into a function Add a note to README about the need for Cygwin --- README.rst | 16 +++++++++++----- build.py | 28 ++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/README.rst b/README.rst index 8058812c..e3b6cf38 100644 --- a/README.rst +++ b/README.rst @@ -55,12 +55,18 @@ decoding errors. For example:: chcp 1252 python build.py ... +In addition, some tasks within the build currently expect to be able to use +Cygwin on Windows (https://www.cygwin.com/) to do its work. If you have +Cygwin installed in one of the default locations (c:\cygwin or c:\cygwin64) +then all is well. If you have it installed somewhere else then you can set +CYGWIN_BASE in the environment and the build tool will use that for the base +dir. -If you just want to do a standard setuptools-style build using setup.py and -are using a full source tarball, then you can stop reading at this point. If -you want to build from a source repository checkout, or need to make changes -and/or to regenerate some of the generated source files, then please continue -reading. +On the other hand, if you just want to do a standard setuptools-style build +using setup.py and are using a full source tarball, then you can stop reading +at this point. If you want to build from a source repository checkout, or +need to make changes and/or to regenerate some of the generated source files, +then please continue reading. Building wxWidgets diff --git a/build.py b/build.py index 9cecfb8b..56309643 100755 --- a/build.py +++ b/build.py @@ -85,13 +85,6 @@ doxygenMD5 = { # And the location where they can be downloaded from toolsURL = 'http://wxpython.org/Phoenix/tools' -# Cygwin is needed on Windows. This tool assumes it is installed in -# the default location. Try to at least guess if we are using 32 bit -# or 64 bit builds. -if isWindows: - cygwin_path_32 = 'c:/cygwin' - cygwin_path_64 = 'c:/cygwin64' - cygwin_path = cygwin_path_64 if os.path.isdir(cygwin_path_64) else cygwin_path_32 #--------------------------------------------------------------------------- @@ -248,7 +241,7 @@ def setPythonVersion(args): # TOOLS = os.environ.get('TOOLS') if 'cygdrive' in TOOLS: - TOOLS = runcmd(cygwin_path+'/bin/cygpath -w '+TOOLS, True, False) + TOOLS = runcmd(getCygwinPath()+'/bin/cygpath -w '+TOOLS, True, False) use64flag = '--x64' in args if use64flag: args.remove('--x64') @@ -715,6 +708,24 @@ def getWafBuildBase(): return base +def getCygwinPath(): + """ + Try to locate the path where cygwin is installed. + + If CYGWIN_BASE is set in the environment then use that. Otherwise look in + default install locations. + """ + if os.environ.get('CYGWIN_BASE'): + return os.environ.get('CYGWIN_BASE') + + for path in ['c:/cygwin', 'c:/cygwin64']: + if os.path.isdir(path): + return path + + return None + + + #--------------------------------------------------------------------------- # Command functions and helpers #--------------------------------------------------------------------------- @@ -725,6 +736,7 @@ def _doDox(arg): doxCmd = os.path.abspath(doxCmd) if isWindows: + cygwin_path = getCygwinPath() doxCmd = doxCmd.replace('\\', '/') doxCmd = runcmd(cygwin_path+'/bin/cygpath -u '+doxCmd, True, False) os.environ['DOXYGEN'] = doxCmd