Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
Jarkko Pöyry | 3c77ed4 | 2015-01-06 12:54:34 -0800 | [diff] [blame] | 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 | |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 23 | import os |
| 24 | from build.common import * |
| 25 | from build.build import * |
| 26 | from argparse import ArgumentParser |
| 27 | import multiprocessing |
Kalle Raita | ad8bdbb | 2015-07-10 13:54:54 -0700 | [diff] [blame] | 28 | from build_android_mustpass import * |
| 29 | |
| 30 | class LaunchControlConfig: |
| 31 | def __init__ (self, buildArgs, checkMustpassLists): |
Pyry Haulos | f189365 | 2016-08-16 12:35:51 +0200 | [diff] [blame] | 32 | self.buildArgs = buildArgs |
Kalle Raita | ad8bdbb | 2015-07-10 13:54:54 -0700 | [diff] [blame] | 33 | self.checkMustpassLists = checkMustpassLists |
| 34 | |
| 35 | def getBuildArgs (self): |
| 36 | return self.buildArgs |
| 37 | |
| 38 | def getCheckMustpassLists (self): |
| 39 | return self.checkMustpassLists |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 40 | |
Pyry Haulos | 2011fb5 | 2016-08-09 18:19:10 -0700 | [diff] [blame] | 41 | COMMON_GCC_CFLAGS = ["-Werror"] |
| 42 | COMMON_CLANG_CFLAGS = COMMON_GCC_CFLAGS + ["-Wno-error=unused-command-line-argument"] |
| 43 | X86_64_GCC_CFLAGS = COMMON_GCC_CFLAGS + ["-m64"] |
| 44 | X86_64_CLANG_CFLAGS = COMMON_CLANG_CFLAGS + ["-m64"] |
| 45 | |
| 46 | def makeCflagsArgs (cflags): |
| 47 | cflagsStr = " ".join(cflags) |
| 48 | return ["-DCMAKE_C_FLAGS=%s" % cflagsStr, "-DCMAKE_CXX_FLAGS=%s" % cflagsStr] |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 49 | |
| 50 | BUILD_CONFIGS = { |
Pyry Haulos | 2011fb5 | 2016-08-09 18:19:10 -0700 | [diff] [blame] | 51 | "gcc-x86_64-x11_glx": LaunchControlConfig(["-DDEQP_TARGET=x11_glx"] + makeCflagsArgs(X86_64_GCC_CFLAGS), False), |
| 52 | "clang-x86_64-x11_glx": LaunchControlConfig(["-DDEQP_TARGET=x11_glx", "-DCMAKE_C_COMPILER=clang", "-DCMAKE_CXX_COMPILER=clang++"] + makeCflagsArgs(X86_64_CLANG_CFLAGS), False), |
| 53 | "gcc-x86_64-null": LaunchControlConfig(["-DDEQP_TARGET=null"] + makeCflagsArgs(X86_64_GCC_CFLAGS), True) |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | def buildWithMake (workingDir): |
| 57 | pushWorkingDir(workingDir) |
| 58 | # CMake docs advised this to be the best magic formula... |
| 59 | threadCount = multiprocessing.cpu_count() + 1 |
| 60 | print "Invoke make with %d threads" % threadCount |
| 61 | execute(["make", "-j%d" % threadCount]) |
| 62 | popWorkingDir() |
| 63 | |
Kalle Raita | ad8bdbb | 2015-07-10 13:54:54 -0700 | [diff] [blame] | 64 | def checkForChanges (): |
| 65 | pushWorkingDir(DEQP_DIR) |
| 66 | # If there are changed files, exit code will be non-zero and the script terminates immediately. |
| 67 | execute(["git", "diff", "--exit-code"]) |
| 68 | popWorkingDir() |
| 69 | |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 70 | def parseOptions (): |
| 71 | parser = ArgumentParser() |
| 72 | |
| 73 | parser.add_argument("-d", |
| 74 | "--build-dir", |
| 75 | dest="buildDir", |
| 76 | default="out", |
| 77 | help="Temporary build directory") |
| 78 | parser.add_argument("-c", |
| 79 | "--config", |
| 80 | dest="config", |
| 81 | choices=BUILD_CONFIGS.keys(), |
| 82 | required=True, |
| 83 | help="Build configuration name") |
| 84 | parser.add_argument("-t", |
| 85 | "--build-type", |
| 86 | dest="buildType", |
| 87 | choices=["Debug", "Release"], |
| 88 | default="Debug", |
| 89 | help="Build type") |
| 90 | return parser.parse_args() |
| 91 | |
| 92 | if __name__ == "__main__": |
| 93 | options = parseOptions() |
| 94 | |
| 95 | print "\n############################################################" |
| 96 | print "# %s %s BUILD" % (options.config.upper(), options.buildType.upper()) |
| 97 | print "############################################################\n" |
| 98 | |
Kalle Raita | ad8bdbb | 2015-07-10 13:54:54 -0700 | [diff] [blame] | 99 | launchControlConfig = BUILD_CONFIGS[options.config] |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 100 | buildDir = os.path.realpath(os.path.normpath(options.buildDir)) |
Kalle Raita | ad8bdbb | 2015-07-10 13:54:54 -0700 | [diff] [blame] | 101 | config = BuildConfig(buildDir, options.buildType, launchControlConfig.getBuildArgs()) |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 102 | initBuildDir(config, MAKEFILE_GENERATOR) |
| 103 | buildWithMake(buildDir) |
| 104 | |
Kalle Raita | ad8bdbb | 2015-07-10 13:54:54 -0700 | [diff] [blame] | 105 | if launchControlConfig.getCheckMustpassLists(): |
| 106 | genMustpassLists(MUSTPASS_LISTS, MAKEFILE_GENERATOR, config) |
| 107 | checkForChanges() |
| 108 | |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 109 | print "\n--- BUILD SCRIPT COMPLETE" |