diff --git a/build/depends.py b/build/depends.py index aa22c25dd93..9e0d645c10e 100644 --- a/build/depends.py +++ b/build/depends.py @@ -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', diff --git a/build/features.py b/build/features.py index bdfda779246..302d82b2717 100644 --- a/build/features.py +++ b/build/features.py @@ -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 @@ -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: @@ -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: @@ -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( @@ -1044,7 +1048,7 @@ 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') @@ -1052,14 +1056,15 @@ def configure(self, build, conf): # 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 diff --git a/src/SConscript.env b/src/SConscript.env index 7f9b34daae6..2f9a9f3c98b 100644 --- a/src/SConscript.env +++ b/src/SConscript.env @@ -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================" @@ -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: