Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame^] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | import os |
| 4 | from build.common import * |
| 5 | from build.build import * |
| 6 | from argparse import ArgumentParser |
| 7 | import 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. |
| 11 | X86_64_ARGS = ["-DDE_CPU=DE_CPU_X86_64", "-DCMAKE_C_FLAGS=-m64", "-DCMAKE_CXX_FLAGS=-m64"] |
| 12 | |
| 13 | BUILD_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 | |
| 18 | def 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 | |
| 26 | def 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 | |
| 48 | if __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" |