1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
7 # Copyright 2016 The Android Open Source Project
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
13 # http://www.apache.org/licenses/LICENSE-2.0
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.
21 #-------------------------------------------------------------------------
27 from build.common import *
28 from build.build import *
31 def __init__ (self, srcDir, tmpDir):
39 def isAvailable (self, env):
43 raise Exception("Not implemented")
45 class RunScript(BuildTestStep):
46 def __init__ (self, scriptPath):
47 self.scriptPath = scriptPath
50 return self.scriptPath
53 execute(["python", os.path.join(env.srcDir, self.scriptPath)])
55 def makeCflagsArgs (cflags):
56 cflagsStr = " ".join(cflags)
57 return ["-DCMAKE_C_FLAGS=%s" % cflagsStr, "-DCMAKE_CXX_FLAGS=%s" % cflagsStr]
59 def makeBuildArgs (target, cc, cpp, cflags):
60 return ["-DDEQP_TARGET=%s" % target, "-DCMAKE_C_COMPILER=%s" % cc, "-DCMAKE_CXX_COMPILER=%s" % cpp] + makeCflagsArgs(cflags)
63 def isAvailable (self, env):
66 class UnixConfig(BuildConfigGen):
67 def __init__ (self, target, buildType, cc, cpp, cflags):
69 self.buildType = buildType
74 def isAvailable (self, env):
75 return which(self.cc) != None and which(self.cpp) != None
77 def getBuildConfig (self, env, buildDir):
78 args = makeBuildArgs(self.target, self.cc, self.cpp, self.cflags)
79 return BuildConfig(buildDir, self.buildType, args, env.srcDir)
81 class VSConfig(BuildConfigGen):
82 def __init__ (self, buildType):
83 self.buildType = buildType
85 def getBuildConfig (self, env, buildDir):
86 args = ["-DCMAKE_C_FLAGS=/WX -DCMAKE_CXX_FLAGS=/WX"]
87 return BuildConfig(buildDir, self.buildType, args, env.srcDir)
89 class Build(BuildTestStep):
90 def __init__ (self, buildDir, configGen, generator):
91 self.buildDir = buildDir
92 self.configGen = configGen
93 self.generator = generator
98 def isAvailable (self, env):
99 return self.configGen.isAvailable(env) and self.generator != None and self.generator.isAvailable()
102 # specialize config for env
103 buildDir = os.path.join(env.tmpDir, self.buildDir)
104 curConfig = self.configGen.getBuildConfig(env, buildDir)
106 build(curConfig, self.generator)
108 class CheckSrcChanges(BuildTestStep):
110 return "check for changes"
113 pushWorkingDir(env.srcDir)
114 execute(["git", "diff", "--exit-code"])
117 def getClangVersion ():
118 knownVersions = ["4.0", "3.9", "3.8", "3.7", "3.6", "3.5"]
119 for version in knownVersions:
120 if which("clang-" + version) != None:
124 COMMON_GCC_CFLAGS = ["-Werror"]
125 COMMON_CLANG_CFLAGS = COMMON_GCC_CFLAGS + ["-Wno-error=unused-command-line-argument"]
126 GCC_32BIT_CFLAGS = COMMON_GCC_CFLAGS + ["-m32"]
127 CLANG_32BIT_CFLAGS = COMMON_CLANG_CFLAGS + ["-m32"]
128 GCC_64BIT_CFLAGS = COMMON_GCC_CFLAGS + ["-m64"]
129 CLANG_64BIT_CFLAGS = COMMON_CLANG_CFLAGS + ["-m64"]
130 CLANG_VERSION = getClangVersion()
133 RunScript(os.path.join("external", "fetch_sources.py")),
134 Build("clang-64-debug",
137 "clang" + CLANG_VERSION,
138 "clang++" + CLANG_VERSION,
141 Build("gcc-32-debug",
148 Build("gcc-64-release",
157 ANY_VS_X64_GENERATOR),
158 RunScript(os.path.join("scripts", "build_android_mustpass.py")),
159 RunScript(os.path.join("external", "vulkancts", "build_mustpass.py")),
160 RunScript(os.path.join("scripts", "gen_egl.py")),
161 RunScript(os.path.join("scripts", "opengl", "gen_all.py")),
162 RunScript(os.path.join("scripts", "src_util", "check_all.py")),
167 parser = argparse.ArgumentParser(description = "Build and test source",
168 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
170 parser.add_argument("-s",
174 help="Source directory")
175 parser.add_argument("-t",
178 default=os.path.join(tempfile.gettempdir(), "deqp-build-test"),
179 help="Temporary directory")
180 return parser.parse_args()
182 if __name__ == "__main__":
184 env = Environment(args.srcDir, args.tmpDir)
187 if step.isAvailable(env):
188 print "Run: %s" % step.getName()
191 print "Skip: %s" % step.getName()
193 print "All steps completed successfully"