am c80353d7: am ca5d0d73: Enable clang compilation for mips.
[platform/upstream/VK-GL-CTS.git] / scripts / launchcontrol_build.py
1 # -*- coding: utf-8 -*-
2
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
6 #
7 # Copyright 2015 The Android Open Source Project
8 #
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12 #
13 #      http://www.apache.org/licenses/LICENSE-2.0
14 #
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 #
21 #-------------------------------------------------------------------------
22
23 import os
24 from build.common import *
25 from build.build import *
26 from argparse import ArgumentParser
27 import multiprocessing
28
29 # This is a bit silly, but CMake needs to know the word width prior to
30 # parsing the project files, hence cannot use our own defines.
31 X86_64_ARGS = ["-DDE_CPU=DE_CPU_X86_64", "-DCMAKE_C_FLAGS=-m64", "-DCMAKE_CXX_FLAGS=-m64"]
32
33 BUILD_CONFIGS = {
34         "gcc-x86_64-x11_glx":   X86_64_ARGS + ["-DDEQP_TARGET=x11_glx"],
35         "clang-x86_64-x11_glx": X86_64_ARGS + ["-DDEQP_TARGET=x11_glx", "-DCMAKE_C_COMPILER=clang", "-DCMAKE_CXX_COMPILER=clang++"]
36 }
37
38 def buildWithMake (workingDir):
39         pushWorkingDir(workingDir)
40         # CMake docs advised this to be the best magic formula...
41         threadCount = multiprocessing.cpu_count() + 1
42         print "Invoke make with %d threads" % threadCount
43         execute(["make", "-j%d" % threadCount])
44         popWorkingDir()
45
46 def parseOptions ():
47         parser = ArgumentParser()
48
49         parser.add_argument("-d",
50                                                 "--build-dir",
51                                                 dest="buildDir",
52                                                 default="out",
53                                                 help="Temporary build directory")
54         parser.add_argument("-c",
55                                                 "--config",
56                                                 dest="config",
57                                                 choices=BUILD_CONFIGS.keys(),
58                                                 required=True,
59                                                 help="Build configuration name")
60         parser.add_argument("-t",
61                                                 "--build-type",
62                                                 dest="buildType",
63                                                 choices=["Debug", "Release"],
64                                                 default="Debug",
65                                                 help="Build type")
66         return parser.parse_args()
67
68 if __name__ == "__main__":
69         options = parseOptions()
70
71         print "\n############################################################"
72         print "# %s %s BUILD" % (options.config.upper(), options.buildType.upper())
73         print "############################################################\n"
74
75         buildDir = os.path.realpath(os.path.normpath(options.buildDir))
76         config = BuildConfig(buildDir, options.buildType, BUILD_CONFIGS[options.config])
77         initBuildDir(config, MAKEFILE_GENERATOR)
78         buildWithMake(buildDir)
79
80         print "\n--- BUILD SCRIPT COMPLETE"