Skip to content
Merged
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
6 changes: 3 additions & 3 deletions build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,10 @@ class SoundTouch(Dependence):
SOUNDTOUCH_PATH = 'soundtouch-1.8.0'

def sse_enabled(self, build):
optimize = int(util.get_flags(build.env, 'optimize', 1))
optimize = SCons.ARGUMENTS.get('optimize', None)
return (build.machine_is_64bit or
(build.toolchain_is_msvs and optimize > 2) or
(build.toolchain_is_gnu and optimize > 1))
(build.toolchain_is_msvs and optimize == 'tuned') or
(build.toolchain_is_gnu and optimize == 'tuned'))

def sources(self, build):
sources = ['engine/enginebufferscalest.cpp',
Expand Down
35 changes: 20 additions & 15 deletions build/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,8 +942,8 @@ def description(self):
return "Optimization and Tuning"

def enabled(self, build):
build.flags['optimize'] = util.get_flags(build.env, 'optimize', 1)
if int(build.flags['optimize']):
build.flags['optimize'] = SCons.ARGUMENTS.get('optimize', None)
if build.flags['optimize'] is not None:
return True
else:
return False
Expand All @@ -956,7 +956,11 @@ def configure(self, build, conf):
if not self.enabled(build):
return

optimize_level = int(build.flags['optimize'])
optimize_level = SCons.ARGUMENTS.get('optimize', 'portable')
try:
optimize_level_int = int(build.flags['optimize'])
except:
optimize_level_int = 0

if build.toolchain_is_msvs:
if build.build_is_debug:
Expand Down Expand Up @@ -994,22 +998,22 @@ def configure(self, build, conf):
# In general, you should pick /O2 over /Ox
build.env.Append(CCFLAGS='/O2')

if optimize_level == 1:
if optimize_level_int == 1:
# portable-binary: sse2 CPU (>= Pentium 4)
self.status = "portable: sse2 CPU (>= Pentium 4)"
build.env.Append(CCFLAGS='/arch:SSE2')
build.env.Append(CPPDEFINES=['__SSE__', '__SSE2__'])
elif optimize_level == 2:
elif optimize_level_int == 2:
if build.machine_is_64bit:
self.status = "native: exclusive for this CPU (%s)" % build.machine
build.env.Append(CCFLAGS='/favor:' + build.machine)
self.status = "native: exclusive for this CPU (%s)" % build.machine
build.env.Append(CCFLAGS='/favor:' + build.machine)
else:
self.status = "Disabled (optimize=2 on 32-bit MSVC)"
elif optimize_level == 3:
self.status = "Disabled (optimize=2 on 32-bit MSVC)"
elif optimize_level_int == 3:
self.status = "legacy: pure i386 code"
else:
raise Exception("optimize=%s is not supported, use 1 .. 3." % optimize_level)

raise Exception("optimize={} is not supported on windows, "
"use 1 .. 3.".format(optimize_level_int))

# SSE and SSE2 are core instructions on x64
if build.machine_is_64bit:
Expand All @@ -1029,7 +1033,7 @@ def configure(self, build, conf):
build.env.Append(CCFLAGS='-fomit-frame-pointer')

# Historicaly our gcc release packages are built with optimize=9.
if optimize_level == 1 or optimize_level == 9:
if 1 <= optimize_level_int <= 9 or optimize_level == 'legacy':
# portable-binary: sse2 CPU (>= Pentium 4)
self.status = "portable: sse2 CPU (>= Pentium 4)"
build.env.Append(
Expand All @@ -1044,22 +1048,23 @@ def configure(self, build, conf):
# The downside of this is that we aren't truly
# i386 compatible, so builds that claim 'i386' will crash.
# Note: SSE2 is a core part of x64 CPUs
elif optimize_level == 2:
elif optimize_level == 'portable':
self.status = "native: exclusive for this CPU (%s)" % build.machine
build.env.Append(
CCFLAGS='-march=native -mfpmath=sse')
# http://en.chys.info/2010/04/what-exactly-marchnative-means/
# Note: requires gcc >= 4.2.0
# macros like __SSE2_MATH__ __SSE_MATH__ __SSE2__ __SSE__
# are set automaticaly
elif optimize_level == 3:
elif optimize_level == 'tuned':
self.status = "legacy: pure i386 code"
build.env.Append(
CCFLAGS='-mtune=generic')
# -mtune=generic pick the most common, but compatible options.
# Used by the debian rules script.
else:
raise Exception("optimize=%s is not supported, use 1 .. 3." % optimize_level)
raise Exception("optimize={} is not supported, use legacy,"
"portable, tuned".format(optimize_level))

# what others do:
# soundtouch uses just -O3 in Ubuntu Trusty
Expand Down
11 changes: 3 additions & 8 deletions src/SConscript.env
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ env = conf.Finish()
#Tell SCons to build libraries that are bundled with Mixxx
#===================================================

#Parse command-line build flags
build_flags = ""

# Print feature summary
print "\nFeatures Summary:\n================"

Expand All @@ -120,14 +117,12 @@ for feature in available_features:

print "%035s... %s" % (feature.description(), message)

build_flags = ' '.join(sorted([('%s=%s' % (k,v) if int(v) > 1 else k) for k,v in build.flags.iteritems() if int(v) > 0]))
build_flags = ' '.join(sorted(
[('%s=%s' % (k,v) if v is not None else k) for k,v in build.flags.iteritems() if v is not None]))

### Put flags info into a file
f = open("build.h","a")
try:
with open("build.h","a") as f:
f.write('#define BUILD_FLAGS "' + build_flags + '"\n')
finally:
f.close()

#Set up the MSVC target to build a Visual Studio project/solution file
if 'msvc' in COMMAND_LINE_TARGETS:
Expand Down