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): |
| 32 | self.buildArgs = buildArgs |
| 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 | |
| 41 | # This is a bit silly, but CMake needs to know the word width prior to |
| 42 | # parsing the project files, hence cannot use our own defines. |
| 43 | X86_64_ARGS = ["-DDE_CPU=DE_CPU_X86_64", "-DCMAKE_C_FLAGS=-m64", "-DCMAKE_CXX_FLAGS=-m64"] |
| 44 | |
| 45 | BUILD_CONFIGS = { |
Kalle Raita | ad8bdbb | 2015-07-10 13:54:54 -0700 | [diff] [blame] | 46 | "gcc-x86_64-x11_glx": LaunchControlConfig(X86_64_ARGS + ["-DDEQP_TARGET=x11_glx"], False), |
| 47 | "clang-x86_64-x11_glx": LaunchControlConfig(X86_64_ARGS + ["-DDEQP_TARGET=x11_glx", "-DCMAKE_C_COMPILER=clang", "-DCMAKE_CXX_COMPILER=clang++"], False), |
| 48 | "gcc-x86_64-null": LaunchControlConfig(X86_64_ARGS + ["-DDEQP_TARGET=null"], True) |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | def buildWithMake (workingDir): |
| 52 | pushWorkingDir(workingDir) |
| 53 | # CMake docs advised this to be the best magic formula... |
| 54 | threadCount = multiprocessing.cpu_count() + 1 |
| 55 | print "Invoke make with %d threads" % threadCount |
| 56 | execute(["make", "-j%d" % threadCount]) |
| 57 | popWorkingDir() |
| 58 | |
Kalle Raita | ad8bdbb | 2015-07-10 13:54:54 -0700 | [diff] [blame] | 59 | def checkForChanges (): |
| 60 | pushWorkingDir(DEQP_DIR) |
| 61 | # If there are changed files, exit code will be non-zero and the script terminates immediately. |
| 62 | execute(["git", "diff", "--exit-code"]) |
| 63 | popWorkingDir() |
| 64 | |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 65 | def parseOptions (): |
| 66 | parser = ArgumentParser() |
| 67 | |
| 68 | parser.add_argument("-d", |
| 69 | "--build-dir", |
| 70 | dest="buildDir", |
| 71 | default="out", |
| 72 | help="Temporary build directory") |
| 73 | parser.add_argument("-c", |
| 74 | "--config", |
| 75 | dest="config", |
| 76 | choices=BUILD_CONFIGS.keys(), |
| 77 | required=True, |
| 78 | help="Build configuration name") |
| 79 | parser.add_argument("-t", |
| 80 | "--build-type", |
| 81 | dest="buildType", |
| 82 | choices=["Debug", "Release"], |
| 83 | default="Debug", |
| 84 | help="Build type") |
| 85 | return parser.parse_args() |
| 86 | |
| 87 | if __name__ == "__main__": |
| 88 | options = parseOptions() |
| 89 | |
| 90 | print "\n############################################################" |
| 91 | print "# %s %s BUILD" % (options.config.upper(), options.buildType.upper()) |
| 92 | print "############################################################\n" |
| 93 | |
Kalle Raita | ad8bdbb | 2015-07-10 13:54:54 -0700 | [diff] [blame] | 94 | launchControlConfig = BUILD_CONFIGS[options.config] |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 95 | buildDir = os.path.realpath(os.path.normpath(options.buildDir)) |
Kalle Raita | ad8bdbb | 2015-07-10 13:54:54 -0700 | [diff] [blame] | 96 | config = BuildConfig(buildDir, options.buildType, launchControlConfig.getBuildArgs()) |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 97 | initBuildDir(config, MAKEFILE_GENERATOR) |
| 98 | buildWithMake(buildDir) |
| 99 | |
Kalle Raita | ad8bdbb | 2015-07-10 13:54:54 -0700 | [diff] [blame] | 100 | if launchControlConfig.getCheckMustpassLists(): |
| 101 | genMustpassLists(MUSTPASS_LISTS, MAKEFILE_GENERATOR, config) |
| 102 | checkForChanges() |
| 103 | |
Kalle Raita | 77f7159 | 2014-10-20 12:22:44 -0700 | [diff] [blame] | 104 | print "\n--- BUILD SCRIPT COMPLETE" |