blob: b7448c9b331b9b7b54e37f25e84d4f8177fa5d9f [file] [log] [blame]
Kalle Raita77f71592014-10-20 12:22:44 -07001# -*- coding: utf-8 -*-
2
3import os
4from build.common import *
5from build.build import *
6from argparse import ArgumentParser
7import multiprocessing
8
9# This is a bit silly, but CMake needs to know the word width prior to
10# parsing the project files, hence cannot use our own defines.
11X86_64_ARGS = ["-DDE_CPU=DE_CPU_X86_64", "-DCMAKE_C_FLAGS=-m64", "-DCMAKE_CXX_FLAGS=-m64"]
12
13BUILD_CONFIGS = {
14 "gcc-x86_64-x11_glx": X86_64_ARGS + ["-DDEQP_TARGET=x11_glx"],
15 "clang-x86_64-x11_glx": X86_64_ARGS + ["-DDEQP_TARGET=x11_glx", "-DCMAKE_C_COMPILER=clang", "-DCMAKE_CXX_COMPILER=clang++"]
16}
17
18def buildWithMake (workingDir):
19 pushWorkingDir(workingDir)
20 # CMake docs advised this to be the best magic formula...
21 threadCount = multiprocessing.cpu_count() + 1
22 print "Invoke make with %d threads" % threadCount
23 execute(["make", "-j%d" % threadCount])
24 popWorkingDir()
25
26def parseOptions ():
27 parser = ArgumentParser()
28
29 parser.add_argument("-d",
30 "--build-dir",
31 dest="buildDir",
32 default="out",
33 help="Temporary build directory")
34 parser.add_argument("-c",
35 "--config",
36 dest="config",
37 choices=BUILD_CONFIGS.keys(),
38 required=True,
39 help="Build configuration name")
40 parser.add_argument("-t",
41 "--build-type",
42 dest="buildType",
43 choices=["Debug", "Release"],
44 default="Debug",
45 help="Build type")
46 return parser.parse_args()
47
48if __name__ == "__main__":
49 options = parseOptions()
50
51 print "\n############################################################"
52 print "# %s %s BUILD" % (options.config.upper(), options.buildType.upper())
53 print "############################################################\n"
54
55 buildDir = os.path.realpath(os.path.normpath(options.buildDir))
56 config = BuildConfig(buildDir, options.buildType, BUILD_CONFIGS[options.config])
57 initBuildDir(config, MAKEFILE_GENERATOR)
58 buildWithMake(buildDir)
59
60 print "\n--- BUILD SCRIPT COMPLETE"