Load functions from ARB_uniform_buffer_object
[platform/upstream/VK-GL-CTS.git] / external / openglcts / scripts / build_caselists.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 import sys
25 import string
26 import argparse
27 import tempfile
28 import shutil
29
30 sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "scripts"))
31
32 from build.common import *
33 from build.config import *
34 from build.build import *
35
36
37 class Module:
38         def __init__ (self, name, api):
39                 self.name               = name
40                 self.api        = api
41
42 MODULES = [
43         Module("dEQP-EGL",              "EGL"),
44         Module("dEQP-GLES2",    "GLES2"),
45         Module("dEQP-GLES3",    "GLES3"),
46         Module("dEQP-GLES31",   "GLES31"),
47         Module("KHR-GLES3",             "GLES3"),
48         Module("KHR-GLES2",             "GLES2"),
49         Module("KHR-GLES31",    "GLES31"),
50         Module("KHR-GLES32",    "GLES32"),
51         Module("KHR-NOCTX-ES2", "GLES2"),
52         Module("KHR-NOCTX-ES32","GLES32"),
53         Module("GTF-GLES2",             "GLES2" ),
54         Module("GTF-GLES3",             "GLES3" ),
55         Module("GTF-GLES31",    "GLES31"),
56         Module("KHR-GL46",              "GL46"),
57         Module("KHR-GL45",              "GL45"),
58         Module("KHR-GL44",              "GL44"),
59         Module("KHR-GL43",              "GL43"),
60         Module("KHR-GL42",              "GL42"),
61         Module("KHR-GL41",              "GL41"),
62         Module("KHR-GL40",              "GL40"),
63         Module("KHR-GL33",              "GL33"),
64         Module("KHR-GL32",              "GL32"),
65         Module("KHR-GL31",              "GL31"),
66         Module("KHR-GL30",              "GL30"),
67         Module("GTF-GL46",              "GL46"),
68         Module("GTF-GL45",              "GL45"),
69         Module("GTF-GL44",              "GL44"),
70         Module("GTF-GL43",              "GL43"),
71         Module("GTF-GL42",              "GL42"),
72         Module("GTF-GL41",              "GL41"),
73         Module("GTF-GL40",              "GL40"),
74         Module("GTF-GL33",              "GL33"),
75         Module("GTF-GL32",              "GL32"),
76         Module("GTF-GL31",              "GL31"),
77         Module("GTF-GL30",              "GL30"),
78         Module("KHR-NOCTX-GL30","GL30"),
79         Module("KHR-NOCTX-GL40","GL40"),
80         Module("KHR-NOCTX-GL45","GL45"),
81 ]
82 GLCTS_BIN_NAME = "glcts"
83 GLCTS_DIR_NAME = "external/openglcts/modules/"
84 DEFAULT_BUILD_DIR       = os.path.join(tempfile.gettempdir(), "deqp-caselists", "{targetName}-{buildType}")
85 DEFAULT_TARGET          = "null"
86
87 def getModuleByName (name):
88         for module in MODULES:
89                 if module.name == name:
90                         return module
91         else:
92                 raise Exception("Unknown module %s" % name)
93
94 def getBuildConfig (buildPathPtrn, targetName, buildType):
95         buildPath = buildPathPtrn.format(
96                 targetName      = targetName,
97                 buildType       = buildType)
98
99         return BuildConfig(buildPath, buildType, ["-DDEQP_TARGET=%s" % targetName])
100
101 def getModulesPath (buildCfg):
102         return os.path.join(buildCfg.getBuildDir(), GLCTS_DIR_NAME)
103
104 def getCaseListFileName (module, caseListType):
105         mname = module.name
106         if mname == "KHR-NOCTX-ES2" or mname == "KHR-NOCTX-ES32" or mname == "KHR-NOCTX-GL30" or mname == "KHR-NOCTX-GL40" or mname == "KHR-NOCTX-GL45":
107                 mname =  "KHR-NoContext"
108         return "%s-cases.%s" % (mname, caseListType)
109
110 def getCaseListPath (buildCfg, module, caseListType):
111         workDir = getModulesPath(buildCfg)
112
113         return os.path.join(workDir, getCaseListFileName(module, caseListType))
114
115 def genCaseList (buildCfg, generator, caseListType):
116         workDir = getModulesPath(buildCfg)
117
118         pushWorkingDir(workDir)
119
120         try:
121                 binPath = generator.getBinaryPath(buildCfg.getBuildType(), os.path.join(".", GLCTS_BIN_NAME))
122                 execute([binPath, "--deqp-runmode=%s-caselist" % caseListType])
123         finally:
124                 popWorkingDir()
125
126 def genAndCopyCaseList (buildCfg, generator, module, dstDir, caseListType):
127         caseListFile    = getCaseListFileName(module, caseListType)
128         srcPath                 = getCaseListPath(buildCfg, module, caseListType)
129         dstPath                 = os.path.join(dstDir, caseListFile)
130
131         if os.path.exists(srcPath):
132                 os.remove(srcPath)
133
134         genCaseList(buildCfg, generator, module, caseListType)
135
136         if not os.path.exists(srcPath):
137                 raise Exception("%s not generated" % srcPath)
138
139         shutil.copyfile(srcPath, dstPath)