1e5c31af7Sopenharmony_ci# -*- coding: utf-8 -*- 2e5c31af7Sopenharmony_ci 3e5c31af7Sopenharmony_ci#------------------------------------------------------------------------- 4e5c31af7Sopenharmony_ci# drawElements Quality Program utilities 5e5c31af7Sopenharmony_ci# -------------------------------------- 6e5c31af7Sopenharmony_ci# 7e5c31af7Sopenharmony_ci# Copyright 2015 The Android Open Source Project 8e5c31af7Sopenharmony_ci# 9e5c31af7Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 10e5c31af7Sopenharmony_ci# you may not use this file except in compliance with the License. 11e5c31af7Sopenharmony_ci# You may obtain a copy of the License at 12e5c31af7Sopenharmony_ci# 13e5c31af7Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 14e5c31af7Sopenharmony_ci# 15e5c31af7Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 16e5c31af7Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 17e5c31af7Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18e5c31af7Sopenharmony_ci# See the License for the specific language governing permissions and 19e5c31af7Sopenharmony_ci# limitations under the License. 20e5c31af7Sopenharmony_ci# 21e5c31af7Sopenharmony_ci#------------------------------------------------------------------------- 22e5c31af7Sopenharmony_ci 23e5c31af7Sopenharmony_ciimport os 24e5c31af7Sopenharmony_cifrom ctsbuild.common import * 25e5c31af7Sopenharmony_cifrom ctsbuild.build import * 26e5c31af7Sopenharmony_cifrom argparse import ArgumentParser 27e5c31af7Sopenharmony_ciimport multiprocessing 28e5c31af7Sopenharmony_cifrom build_android_mustpass import * 29e5c31af7Sopenharmony_ci 30e5c31af7Sopenharmony_ciclass LaunchControlConfig: 31e5c31af7Sopenharmony_ci def __init__ (self, buildArgs, checkMustpassLists): 32e5c31af7Sopenharmony_ci self.buildArgs = buildArgs 33e5c31af7Sopenharmony_ci self.checkMustpassLists = checkMustpassLists 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_ci def getBuildArgs (self): 36e5c31af7Sopenharmony_ci return self.buildArgs 37e5c31af7Sopenharmony_ci 38e5c31af7Sopenharmony_ci def getCheckMustpassLists (self): 39e5c31af7Sopenharmony_ci return self.checkMustpassLists 40e5c31af7Sopenharmony_ci 41e5c31af7Sopenharmony_ciCOMMON_GCC_CFLAGS = ["-Werror"] 42e5c31af7Sopenharmony_ciCOMMON_CLANG_CFLAGS = COMMON_GCC_CFLAGS + ["-Wno-error=unused-command-line-argument"] 43e5c31af7Sopenharmony_ciX86_64_GCC_CFLAGS = COMMON_GCC_CFLAGS + ["-m64"] 44e5c31af7Sopenharmony_ciX86_64_CLANG_CFLAGS = COMMON_CLANG_CFLAGS + ["-m64"] 45e5c31af7Sopenharmony_ci 46e5c31af7Sopenharmony_cidef makeCflagsArgs (cflags): 47e5c31af7Sopenharmony_ci cflagsStr = " ".join(cflags) 48e5c31af7Sopenharmony_ci return ["-DCMAKE_C_FLAGS=%s" % cflagsStr, "-DCMAKE_CXX_FLAGS=%s" % cflagsStr] 49e5c31af7Sopenharmony_ci 50e5c31af7Sopenharmony_ciBUILD_CONFIGS = { 51e5c31af7Sopenharmony_ci "gcc-x86_64-x11_glx": LaunchControlConfig(["-DDEQP_TARGET=x11_glx"] + makeCflagsArgs(X86_64_GCC_CFLAGS), False), 52e5c31af7Sopenharmony_ci "clang-x86_64-x11_glx": LaunchControlConfig(["-DDEQP_TARGET=x11_glx", "-DCMAKE_C_COMPILER=clang", "-DCMAKE_CXX_COMPILER=clang++"] + makeCflagsArgs(X86_64_CLANG_CFLAGS), False), 53e5c31af7Sopenharmony_ci "gcc-x86_64-null": LaunchControlConfig(["-DDEQP_TARGET=null"] + makeCflagsArgs(X86_64_GCC_CFLAGS), True) 54e5c31af7Sopenharmony_ci} 55e5c31af7Sopenharmony_ci 56e5c31af7Sopenharmony_cidef buildWithMake (workingDir): 57e5c31af7Sopenharmony_ci pushWorkingDir(workingDir) 58e5c31af7Sopenharmony_ci # CMake docs advised this to be the best magic formula... 59e5c31af7Sopenharmony_ci threadCount = multiprocessing.cpu_count() + 1 60e5c31af7Sopenharmony_ci print("Invoke make with %d threads" % threadCount) 61e5c31af7Sopenharmony_ci execute(["make", "-j%d" % threadCount]) 62e5c31af7Sopenharmony_ci popWorkingDir() 63e5c31af7Sopenharmony_ci 64e5c31af7Sopenharmony_cidef checkForChanges (): 65e5c31af7Sopenharmony_ci pushWorkingDir(DEQP_DIR) 66e5c31af7Sopenharmony_ci # If there are changed files, exit code will be non-zero and the script terminates immediately. 67e5c31af7Sopenharmony_ci execute(["git", "diff", "--exit-code"]) 68e5c31af7Sopenharmony_ci popWorkingDir() 69e5c31af7Sopenharmony_ci 70e5c31af7Sopenharmony_cidef parseOptions (): 71e5c31af7Sopenharmony_ci parser = ArgumentParser() 72e5c31af7Sopenharmony_ci 73e5c31af7Sopenharmony_ci parser.add_argument("-d", 74e5c31af7Sopenharmony_ci "--build-dir", 75e5c31af7Sopenharmony_ci dest="buildDir", 76e5c31af7Sopenharmony_ci default="out", 77e5c31af7Sopenharmony_ci help="Temporary build directory") 78e5c31af7Sopenharmony_ci parser.add_argument("-c", 79e5c31af7Sopenharmony_ci "--config", 80e5c31af7Sopenharmony_ci dest="config", 81e5c31af7Sopenharmony_ci choices=BUILD_CONFIGS.keys(), 82e5c31af7Sopenharmony_ci required=True, 83e5c31af7Sopenharmony_ci help="Build configuration name") 84e5c31af7Sopenharmony_ci parser.add_argument("-t", 85e5c31af7Sopenharmony_ci "--build-type", 86e5c31af7Sopenharmony_ci dest="buildType", 87e5c31af7Sopenharmony_ci choices=["Debug", "Release"], 88e5c31af7Sopenharmony_ci default="Debug", 89e5c31af7Sopenharmony_ci help="Build type") 90e5c31af7Sopenharmony_ci return parser.parse_args() 91e5c31af7Sopenharmony_ci 92e5c31af7Sopenharmony_ciif __name__ == "__main__": 93e5c31af7Sopenharmony_ci options = parseOptions() 94e5c31af7Sopenharmony_ci 95e5c31af7Sopenharmony_ci print("\n############################################################") 96e5c31af7Sopenharmony_ci print("# %s %s BUILD" % (options.config.upper(), options.buildType.upper())) 97e5c31af7Sopenharmony_ci print("############################################################\n") 98e5c31af7Sopenharmony_ci 99e5c31af7Sopenharmony_ci launchControlConfig = BUILD_CONFIGS[options.config] 100e5c31af7Sopenharmony_ci buildDir = os.path.realpath(os.path.normpath(options.buildDir)) 101e5c31af7Sopenharmony_ci config = BuildConfig(buildDir, options.buildType, launchControlConfig.getBuildArgs()) 102e5c31af7Sopenharmony_ci initBuildDir(config, MAKEFILE_GENERATOR) 103e5c31af7Sopenharmony_ci buildWithMake(buildDir) 104e5c31af7Sopenharmony_ci 105e5c31af7Sopenharmony_ci if launchControlConfig.getCheckMustpassLists(): 106e5c31af7Sopenharmony_ci genMustpassLists(MUSTPASS_LISTS, MAKEFILE_GENERATOR, config) 107e5c31af7Sopenharmony_ci checkForChanges() 108e5c31af7Sopenharmony_ci 109e5c31af7Sopenharmony_ci print("\n--- BUILD SCRIPT COMPLETE") 110