Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows scons vcxproj to work on all systems #404

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,7 @@ def config_base(env):
except KeyError:
pass

if Beast.system.linux:
env.ParseConfig('pkg-config --static --cflags --libs openssl')
env.ParseConfig('pkg-config --static --cflags --libs protobuf')
elif Beast.system.windows:
if Beast.system.windows:
try:
OPENSSL_ROOT = os.path.normpath(os.environ['OPENSSL_ROOT'])
env.Append(CPPPATH=[
Expand All @@ -244,6 +241,11 @@ def config_env(toolchain, variant, env):
env.Append(CPPDEFINES=['NDEBUG'])

if toolchain in Split('clang gcc'):

if Beast.system.linux:
env.ParseConfig('pkg-config --static --cflags --libs openssl')
env.ParseConfig('pkg-config --static --cflags --libs protobuf')

env.Append(CCFLAGS=[
'-Wall',
'-Wno-sign-compare',
Expand Down Expand Up @@ -322,7 +324,7 @@ def config_env(toolchain, variant, env):
if toolchain == 'clang':
if Beast.system.osx:
env.Replace(CC='clang', CXX='clang++', LINK='clang++')
else:
elif 'CLANG_CC' in env and 'CLANG_CXX' in env and 'CLANG_LINK' in env:
env.Replace(CC=env['CLANG_CC'], CXX=env['CLANG_CXX'], LINK=env['CLANG_LINK'])
# C and C++
# Add '-Wshorten-64-to-32'
Expand All @@ -332,7 +334,8 @@ def config_env(toolchain, variant, env):
env.Append(CXXFLAGS=['-Wno-mismatched-tags'])

elif toolchain == 'gcc':
env.Replace(CC=env['GNU_CC'], CXX=env['GNU_CXX'], LINK=env['GNU_LINK'])
if 'GNU_CC' in env and 'GNU_CXX' in env and 'GNU_LINK' in env:
env.Replace(CC=env['GNU_CC'], CXX=env['GNU_CXX'], LINK=env['GNU_LINK'])
# Why is this only for gcc?!
env.Append(CCFLAGS=['-Wno-unused-local-typedefs'])

Expand Down Expand Up @@ -396,7 +399,7 @@ def config_env(toolchain, variant, env):
'/MACHINE:X64',
'/MANIFEST',
#'''/MANIFESTUAC:"level='asInvoker' uiAccess='false'"''',
#'/NOLOGO',
'/NOLOGO',
'/NXCOMPAT',
'/SUBSYSTEM:CONSOLE',
'/TLBID:1',
Expand Down Expand Up @@ -446,10 +449,6 @@ base.Append(CPPPATH=[
os.path.join('src', 'beast'),
os.path.join(build_dir, 'proto'),
])
if Beast.system.windows:
base.Append(CPPPATH=[
os.path.join('src', 'protobuf', 'src'),
])

# Configure the toolchains, variants, default toolchain, and default target
variants = ['debug', 'release']
Expand Down Expand Up @@ -488,7 +487,7 @@ for source in [
# Declare the targets
aliases = collections.defaultdict(list)
msvc_configs = []
for toolchain in toolchains:
for toolchain in ['gcc', 'clang', 'msvc']:
for variant in variants:
# Configure this variant's construction environment
env = base.Clone()
Expand Down Expand Up @@ -568,7 +567,7 @@ for toolchain in toolchains:
'src/snappy/config',
]))

if Beast.system.osx:
if toolchain == "clang" and Beast.system.osx:
objects.append(addSource('src/ripple/unity/beastobjc.mm', env, variant_dirs))

target = env.Program(
Expand All @@ -587,9 +586,10 @@ for toolchain in toolchains:
msvc_configs.append(config)
if toolchain in toolchains:
aliases['all'].extend(target)
aliases[variant].extend(target)
aliases[toolchain].extend(target)
env.Alias(variant_name, target)
aliases[variant].extend(target)
aliases[toolchain].extend(target)
env.Alias(variant_name, target)

for key, value in aliases.iteritems():
env.Alias(key, value)

Expand Down
48 changes: 28 additions & 20 deletions src/beast/site_scons/site_tools/VSProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,23 @@ def is_subdir(child, parent):
'''Determine if child is a subdirectory of parent'''
return os.path.commonprefix([parent, child]) == parent

def xsorted(*args, **kwargs):
'''Performs sorted in a deterministic manner.'''
if not 'key' in kwargs:
def _lower(item):
if isinstance(item, str):
return (item.lower(), item)
return (item, item)
kwargs['key'] = _lower
return sorted(*args, **kwargs)

def itemList(items, sep):
if type(items) == str: # Won't work in Python 3.
return items
def gen():
for item in sorted(items):
for item in xsorted(items):
if type(item) == dict:
for k, v in sorted(item.items()):
for k, v in xsorted(item.items()):
yield k + '=' + v
else:
yield item
Expand All @@ -124,6 +134,7 @@ def __init__(self, table, booltable):
def getXml(self, switches, prefix = ''):
if type(switches) != list:
switches = list(switches)
switches = list(set(switches)) # Filter dupes because on windows platforms, /nologo is added automatically to the environment.
xml = []
unknown = []
for switch in switches:
Expand Down Expand Up @@ -272,12 +283,7 @@ def __init__(self):
booltable = {
'/DEBUG' : ['GenerateDebugInformation'],
'/DYNAMICBASE' : ['RandomizedBaseAddress'],
'/DYNAMICBASE' : ['RandomizedBaseAddress'],
'/DYNAMICBASE' : ['RandomizedBaseAddress'],
'/DYNAMICBASE' : ['RandomizedBaseAddress'],
'/DYNAMICBASE' : ['RandomizedBaseAddress'],
'/NOLOGO' : ['SuppressStartupBanner'],
'/nologo' : ['SuppressStartupBanner'],
}
table = {
'/ERRORREPORT:NONE' : ['ErrorReporting', 'NoErrorReport'],
Expand Down Expand Up @@ -548,7 +554,7 @@ class _ProjectGenerator(object):

def __init__(self, project_node, filters_node, env):
try:
self.configs = sorted(env['VSPROJECT_CONFIGS'], key=lambda x: x.name)
self.configs = xsorted(env['VSPROJECT_CONFIGS'], key=lambda x: x.name)
except KeyError:
raise ValueError ('Missing VSPROJECT_CONFIGS')
self.root_dir = os.getcwd()
Expand Down Expand Up @@ -586,7 +592,7 @@ def _walk(target, items, prefix=''):
targets = config.target
for target in targets:
_walk(target, items)
self.items = sorted(items.itervalues(), key=lambda x: x.path())
self.items = xsorted(items.itervalues(), key=lambda x: x.path())

def makeListTag(self, items, prefix, tag, attrs, inherit=True):
'''Builds an XML tag string from a list of items. If items is
Expand Down Expand Up @@ -640,7 +646,7 @@ def writeHeader(self):
variant_dir = os.path.relpath(os.path.dirname(
config.target[0].get_abspath()), self.project_dir)
out_dir = winpath(variant_dir) + ntpath.sep
int_dir = winpath(os.path.join(variant_dir, 'src')) + ntpath.sep
int_dir = winpath(ntpath.join(variant_dir, 'src')) + ntpath.sep
f.write(V12DSPPropertyGroup % locals())

f.write(' <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r\n')
Expand All @@ -661,20 +667,20 @@ def writeHeader(self):
' <PreprocessorDefinitions>%s%%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n' % (
itemList(config.env['CPPDEFINES'], ';')))
props = ''
props += self.makeListTag(self.relPaths(sorted(config.env['CPPPATH'])),
props += self.makeListTag(self.relPaths(xsorted(config.env['CPPPATH'])),
' ', 'AdditionalIncludeDirectories', '', True)
f.write(props)
f.write(CLSWITCHES.getXml(sorted(config.env['CCFLAGS']), ' '))
f.write(CLSWITCHES.getXml(xsorted(config.env['CCFLAGS']), ' '))
f.write(' </ClCompile>\r\n')

f.write(' <Link>\r\n')
props = ''
props += self.makeListTag(sorted(config.env['LIBS']),
props += self.makeListTag(xsorted(config.env['LIBS']),
' ', 'AdditionalDependencies', '', True)
props += self.makeListTag(self.relPaths(sorted(config.env['LIBPATH'])),
props += self.makeListTag(self.relPaths(xsorted(config.env['LIBPATH'])),
' ', 'AdditionalLibraryDirectories', '', True)
f.write(props)
f.write(LINKSWITCHES.getXml(sorted(config.env['LINKFLAGS']), ' '))
f.write(LINKSWITCHES.getXml(xsorted(config.env['LINKFLAGS']), ' '))
f.write(' </Link>\r\n')

f.write(' </ItemDefinitionGroup>\r\n')
Expand All @@ -692,21 +698,23 @@ def writeProject(self):
props = ' <ExcludedFromBuild>True</ExcludedFromBuild>\r\n'
elif item.builder() == 'Object':
props = ''
for config, output in sorted(item.node.iteritems()):
for config, output in xsorted(item.node.iteritems()):
name = config.name
env = output.get_build_env()
variant = config.variant
platform = config.platform
props += self.makeListTag(self.extraRelPaths(sorted(env['CPPPATH']), config.env['CPPPATH']),
props += self.makeListTag(self.extraRelPaths(xsorted(env['CPPPATH']), config.env['CPPPATH']),
' ', 'AdditionalIncludeDirectories',
''' Condition="'$(Configuration)|$(Platform)'=='%(variant)s|%(platform)s'"''' % locals(),
True)
elif item.builder() == 'Protoc':
for config, output in sorted(item.node.iteritems()):
for config, output in xsorted(item.node.iteritems()):
name = config.name
out_dir = os.path.relpath(os.path.dirname(str(output)), self.project_dir)
cpp_out = winpath(out_dir)
base_out = os.path.join(out_dir, os.path.splitext(os.path.basename(item.path()))[0])
out_parts = out_dir.split(os.sep)
out_parts.append(os.path.splitext(os.path.basename(item.path()))[0])
base_out = ntpath.join(*out_parts)
props += V12CustomBuildProtoc % locals()

f.write(' <%(tag)s Include="%(path)s">\r\n' % locals())
Expand Down Expand Up @@ -740,7 +748,7 @@ def getGroup(abspath):
while group != '':
groups.add(group)
group = ntpath.split(group)[0]
for group in sorted(groups):
for group in xsorted(groups):
guid = _guid(self.guid, group)
f.write(
' <Filter Include="%(group)s">\r\n'
Expand Down