#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import SCons
import shutil
import subprocess
import time
import datetime
import glob
import uuid
from xml.dom import minidom
import SCons.Script as SCons
from build import util, depends
mixxx_version = util.get_mixxx_version()
branch_name = util.get_branch_name()
vcs_revision = util.get_revision()
vcs_name = util.get_current_vcs()
print("WE ARE IN:", os.getcwd())
print("Building ", branch_name, " - rev.", vcs_revision)
plugins = []
# Grab these from the SConstruct above us
Import('build')
Import('sources')
env = build.env
flags = build.flags
# Make a static library of all Mixxx's sources. This library will be linked into
# both mixxx and mixxx-test.
mixxx_lib = env.StaticLibrary('libmixxx',
[source for source in sources
if str(source) != 'src/main.cpp'])
# mixxx.qrc must not be bundled into libmixxx.a since the linker will not link
# it into the resulting binary unless it is on the link command-line explicitly
# (it has no link-time symbols that are needed by anything in Mixxx).
mixxx_qrc = env.StaticObject(env.Qrc5('res/mixxx.cc', 'res/mixxx.qrc'))
# libmixxx.a needs to precede all other libraries so that symbols it requires
# end up in the linker's list of unresolved symbols before other libraries are
# searched for symbols.
env.Prepend(LIBS=mixxx_lib)
mixxx_main = env.StaticObject('src/main.cpp')
#Tell SCons to build Mixxx
#=========================
if build.platform_is_windows:
dist_dir = 'dist%s' % build.bitwidth
# Populate the stuff that changes in the .rc file
fo = open(File('src/mixxx.rc.include').abspath, "w")
str_list = []
str_list.append('#define VER_FILEVERSION ')
# Remove anything after ~ or - in the version number and replace the dots with commas
str_list.append(mixxx_version.partition('~')[0].partition('-')[0].replace('.',','))
if vcs_revision:
str_list.append(','+str(vcs_revision))
str_list.append('\n')
str_list.append('#define VER_PRODUCTVERSION ')
str_list.append(mixxx_version.partition('~')[0].partition('-')[0].replace('.',','))
if vcs_revision:
str_list.append(','+str(vcs_revision))
str_list.append('\n')
import datetime
now = datetime.datetime.now()
str_list.append('#define CUR_YEAR "'+str(now.year)+'"\n\n')
if build.build_is_debug:
str_list.append('#define DEBUG 1\n')
if 'pre' in mixxx_version.lower():
str_list.append('#define PRERELEASE 1\n')
fo.write(''.join(str_list))
fo.close()
mixxx_rc = env.RES('src/mixxx.rc')
mixxx_bin = env.Program('mixxx',
[mixxx_main, mixxx_qrc, mixxx_rc],
LINKCOM = [env['LINKCOM'], 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;1'])
elif build.platform_is_osx:
# Bug #1258435: executable name must match CFBundleExecutable in the
# Info.plist. For codesigned bundles it seems the CFBundleExecutable
# must match the bundle name or else we SIGILL at startup (not sure
# why).
mixxx_bin = env.Program('Mixxx', [mixxx_main, mixxx_qrc])
else:
mixxx_bin = env.Program('mixxx', [mixxx_main, mixxx_qrc])
# For convenience, copy the Mixxx binary out of the build directory to the
# root. Don't do it on windows because the binary can't run on its own and needs
# the DLLs present with it.
if not build.platform_is_windows:
copy_mixxx_bin = Command("../mixxx", mixxx_bin, Copy("$TARGET", "$SOURCE"))
Default(copy_mixxx_bin)
else:
Default(mixxx_bin)
test_bin = None
def define_test_targets(default=False):
global test_bin
test_files = Glob('src/test/*.cpp', strings=True)
test_env = env.Clone()
test_env.Append(CPPPATH="lib/gtest-1.7.0/include")
test_env.Append(LIBPATH="lib/gtest-1.7.0")
test_env