Skip to content

Commit

Permalink
Merge 0cefc2b into 20927b4
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbaddog committed Mar 25, 2018
2 parents 20927b4 + 0cefc2b commit 6299719
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__/
build/**
bootstrap/**
.idea/
src/build/**


# Translations
Expand Down
7 changes: 7 additions & 0 deletions src/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
- Updated Jar builder to flatten source list which could contain embedded lists
- Removed some magic numbers from jar.py on behalf of Mats Wichmann (mats@linux.com)

From William Deegan:
- Updated logic for mingw and clang on win32 to search default tool install paths if not
found in normal SCons PATH. If the user specifies PATH or tool specific paths they
will be used and the default paths below will be ignored.
- Default path for clang/clangxx : C:\Program Files\LLVM\bin
- Default path for mingw : c:\MinGW\bin

From Gary Oberbrunner:
- Fix bug when Installing multiple subdirs outside the source tree
- fix to_str to handle None without raising exception
Expand Down
29 changes: 29 additions & 0 deletions src/engine/SCons/Tool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,35 @@ def tool_list(platform, env):

return [x for x in tools if x]


def find_program_path(env, key_program, default_paths=[]):
"""
Find the location of key_program and then return the path it was located at.
Checking the default install locations.
Mainly for windows where tools aren't all installed in /usr/bin,etc
:param env: Current Environment()
:param key_program: Program we're using to locate the directory to add to PATH.
"""
# First search in the SCons path
path=env.WhereIs(key_program)
if (path):
return path
# then the OS path:
path=SCons.Util.WhereIs(key_program)
if (path):
return path

# If that doesn't work try default location for mingw
save_path = env['ENV']['PATH']
for p in default_paths:
env.AppendENVPath('PATH',p)
path = env.WhereIs(key_program)
if not path:
env['ENV']['PATH']=save_path
return path



# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
Expand Down
10 changes: 10 additions & 0 deletions src/engine/SCons/Tool/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,28 @@

import SCons.Util
import SCons.Tool.cc
from SCons.Tool.clangCommon import get_clang_install_dirs


compilers = ['clang']

def generate(env):
"""Add Builders and construction variables for clang to an Environment."""
SCons.Tool.cc.generate(env)

if env['PLATFORM'] == 'win32':
# Ensure that we have a proper path for clang
clang = SCons.Tool.find_program_path(env, compilers[0], default_paths=get_clang_install_dirs(env['PLATFORM']))
if clang:
clang_bin_dir = os.path.dirname(clang)
env.AppendENVPath('PATH', clang_bin_dir)

env['CC'] = env.Detect(compilers) or 'clang'
if env['PLATFORM'] in ['cygwin', 'win32']:
env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
else:
env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS -fPIC')

# determine compiler version
if env['CC']:
#pipe = SCons.Action._subproc(env, [env['CC'], '-dumpversion'],
Expand Down
17 changes: 17 additions & 0 deletions src/engine/SCons/Tool/clangCommon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
Common routines and data for clang tools
"""

clang_win32_dirs = [
r'C:\Program Files\LLVM\bin',
r'C:\cygwin64\bin',
r'C:\msys64',
r'C:\cygwin\bin',
r'C:\msys',
]

def get_clang_install_dirs(platform):
if platform == 'win32':
return clang_win32_dirs
else:
return []
13 changes: 12 additions & 1 deletion src/engine/SCons/Tool/clangxx.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
import SCons.Tool
import SCons.Util
import SCons.Tool.cxx
from SCons.Tool.clangCommon import get_clang_install_dirs


compilers = ['clang++']

Expand All @@ -66,13 +68,22 @@ def generate(env):
env['SHOBJSUFFIX'] = '.pic.o'
elif env['PLATFORM'] == 'sunos':
env['SHOBJSUFFIX'] = '.pic.o'
elif env['PLATFORM'] == 'win32':
# Ensure that we have a proper path for clang++
clangxx = SCons.Tool.find_program_path(env, compilers[0], default_paths=get_clang_install_dirs(env['PLATFORM']))
if clangxx:
clangxx_bin_dir = os.path.dirname(clangxx)
env.AppendENVPath('PATH', clangxx_bin_dir)

# determine compiler version
if env['CXX']:
pipe = SCons.Action._subproc(env, [env['CXX'], '--version'],
stdin='devnull',
stderr='devnull',
stdout=subprocess.PIPE)
if pipe.wait() != 0: return
if pipe.wait() != 0:
return

# clang -dumpversion is of no use
line = pipe.stdout.readline()
if sys.version_info[0] > 2:
Expand Down
31 changes: 7 additions & 24 deletions src/engine/SCons/Tool/mingw.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,6 @@
import SCons.Tool
import SCons.Util

# This is what we search for to find mingw:
key_program = 'mingw32-gcc'

def find(env):
# First search in the SCons path
path=env.WhereIs(key_program)
if (path):
return path
# then the OS path:
path=SCons.Util.WhereIs(key_program)
if (path):
return path

# If that doesn't work try default location for mingw
save_path=env['ENV']['PATH']
env.AppendENVPath('PATH',r'c:\MinGW\bin')
path =env.WhereIs(key_program)
if not path:
env['ENV']['PATH']=save_path
return path

def shlib_generator(target, source, env, for_signature):
cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS'])
Expand Down Expand Up @@ -126,12 +106,15 @@ def shlib_emitter(target, source, env):
source_scanner=SCons.Tool.SourceFileScanner)
SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan)

# This is what we search for to find mingw:
key_program = 'mingw32-gcc'


def generate(env):
mingw = find(env)
mingw = SCons.Tool.find_program_path(env, key_program, default_paths=[r'c:\MinGW\bin',])
if mingw:
dir = os.path.dirname(mingw)
env.PrependENVPath('PATH', dir )

mingw_bin_dir = os.path.dirname(mingw)
env.AppendENVPath('PATH', mingw_bin_dir)

# Most of mingw is the same as gcc and friends...
gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas', 'gfortran', 'm4']
Expand Down

0 comments on commit 6299719

Please sign in to comment.