forked from mixxxdj/mixxx
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSConscript.env
182 lines (145 loc) · 6.85 KB
/
SConscript.env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, os, platform
import SCons
import SCons.Script
import logging
import fnmatch
import shutil
from build import util, mixxx, depends
Import('build')
# Grab the created environment from the MixxxBuild
env = build.env
# Check for old build.h file and delete it if it exists
defs = str(SCons.Script.File('#src/build.h'))
if os.path.exists(defs):
print "Deleting deprecated build file: %s" % defs
os.remove(defs)
#env.Append(CPPDEFINES=[('BUILD_REV', '"%s"' % getBZRRevision())]) #doing this forces a rebuild of everything whenever a commit happens -- not much fun
## instead, embed BZR version into build
## Put version info into a file, so it doesn't force a rebuild of everything :)
if os.path.exists(os.path.join('..', 'build.h')):
# If a build.h exists in the project root mixxx/ directory then use that
# instead of writing our own. This is mostly since when we build Debian
# packages we don't have any of the Bazaar metadata so we can't write one
# ourselves.
shutil.copy(os.path.join('..', 'build.h'), 'build.h')
else:
util.write_build_header('build.h')
#Check for dependencies if we're not doing a clean...
#if not env.GetOption('clean') and not SCons.Util.containsAny(os.sys.argv, ['-h', '--help']):
conf = Configure(env, custom_tests = { 'CheckForPKGConfig' : util.CheckForPKGConfig,
'CheckForPKG' : util.CheckForPKG })
available_features = [depends.MixxxCore]
extra_features = build.get_features()
available_features.extend(extra_features)
# Instantiate the features
available_features = [feature_class() for feature_class in available_features]
visited_dependencies = set()
active_dependencies = []
unmet_dependencies = False
def visit_dependency(dependency_class, build, conf):
"""Recursively configure all dependencies. Skip over dependencies we
have already setup."""
global unmet_dependencies
if dependency_class in visited_dependencies:
return
visited_dependencies.add(dependency_class)
dependency = dependency_class()
try:
print "Configuring %s" % dependency.name
dependency.configure(build, conf)
except Exception, e:
logging.error("Unmet dependency: %s" % e)
unmet_dependencies = True
active_dependencies.append(dependency)
for sub_dependency in dependency.depends(build):
visit_dependency(sub_dependency, build, conf)
for feature in available_features:
try:
print "Configuring %s" % feature.name
feature.configure(build, conf)
# Only process the feature's dependencies if it's enabled
if feature.enabled(build):
active_dependencies.append(feature)
for dependency in feature.depends(build):
visit_dependency(dependency, build, conf)
except Exception, e:
logging.error("Unmet dependency: %s" % e)
unmet_dependencies = True
if unmet_dependencies:
logging.error("Build had unmet dependencies. Exiting.")
Exit(1)
sources = []
# Query each active dependency for sources they require
for dependency in active_dependencies:
dep_sources = dependency.sources(build)
if dep_sources is not None:
sources.extend(dep_sources)
#If there's additional env variables that need to be set after the
#Configure checks have run, then we'll take care of that now.
dependency.post_dependency_check_configure(build, conf)
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================"
for feature in available_features:
message = "Enabled" if feature.enabled(build) else "Disabled"
# If the plugin has a status message, show it instead
if len(feature.status) > 0:
message = "%s" % feature.status
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]))
### Put flags info into a file
f = open("build.h","a")
try:
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:
#includes = map(str, Glob('#src/*.h'))
#Make the project file aware of any command-line arguments that were passed...
cmdargs = ""
for k in SCons.Script.ARGUMENTS:
cmdargs += " " + k + "=" + SCons.Script.ARGUMENTS[k]
env.Append(MSVSSCONSFLAGS = cmdargs)
#env.Append(MSVSSCONSFLAGS = ' qtdir=' + build.flags['qtdir'])
# This is the right way to do it but scons is stupid and doesn't copy flags in... Adam
# Set up environment for debug target
# TODO Handle lib versions ie /MDd /Md etc...
#debugenv = env.Clone()
#debugenv.Prepend(LINKFLAGS = ['/DEBUG','/PDB:dist' + str(build.bitwidth) + '/mixxx.pdb']) # Generate MS VC Program Debug Database
#debugenv.Append(CXXFLAGS = '/ZI')
cppfiles = []
hfiles = []
# XXX: Assumes we're in the "src" directory!
for root, dirs, filenames in os.walk('.'):
for file in filenames:
filepath = os.path.join(root, file)
if filepath.startswith(".\\"):
filepath = filepath[2:]
if fnmatch.fnmatch(filepath, '*.cpp'):
cppfiles.append(filepath)
elif fnmatch.fnmatch(filepath, '*.h'):
hfiles.append(filepath)
msvc = env.MSVSProject(target = 'mixxx' + env['MSVSPROJECTSUFFIX'], srcs = cppfiles, incs = hfiles, variant = 'Debug', runfile = '../dist' + str(build.bitwidth) + '/mixxx.exe')
# Reenable this once bug in scons is fixed...
#msvc = env.MSVSProject(target = 'mixxx' + env['MSVSPROJECTSUFFIX'], srcs = cppfiles, incs = hfiles, variant = 'Release', runfile = '../dist' + str(build.bitwidth) + '/mixxx.exe')
env.Alias('msvc', msvc)
# Print the build flags (useful if the flags have been cached, ie. if you just run "scons"
# and want to see the flags that you used last time)
print "================"
print "Building with flags: %s" % build_flags
print "Building with CC: %s" % env['CC']
print "Building with CXX: %s" % env['CXX']
print "Building with CCFLAGS: %s" % env['CCFLAGS']
print "Building with CPPDEFINES: %s" % ' '.join(['-D'+'='.join(pair) if not isinstance(pair, basestring) else '-D'+pair for pair in env['CPPDEFINES']])
print "Building with CXXFLAGS: %s" % env['CXXFLAGS']
print "Building with LINKFLAGS: %s" % env['LINKFLAGS']
print "Building with LIBS: %s" % ' '.join(env['LIBS'])
print "================\n"
Export('sources')