1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
4 # drawElements Quality Program utilities
5 # --------------------------------------
7 # Copyright 2017 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 #-------------------------------------------------------------------------
25 from fnmatch import fnmatch
27 from build.common import DEQP_DIR, writeFile
37 "framework/platform/android",
39 "framework/randomshaders",
40 "framework/referencerenderer",
50 "execserver/xsWin32TestProcess.cpp",
51 "external/vulkancts/modules/vulkan/vktBuildPrograms.cpp",
52 "framework/delibs/dethread/standalone_test.c",
53 "framework/randomshaders/rsgTest.cpp",
59 # WARNING: This is auto-generated file. Do not modify, since changes will
60 # be lost! Modify scripts/gen_android_mk.py instead.
62 LOCAL_SRC_FILES :={SRC_FILES}
64 LOCAL_C_INCLUDES :={INCLUDES}
68 def matchesAny (filename, patterns):
70 if fnmatch(filename, ptrn):
74 def isSourceFile (filename):
75 return matchesAny(filename, INCLUDE_PATTERNS) and not matchesAny(filename, EXCLUDE_PATTERNS)
77 def toPortablePath (nativePath):
78 # os.path is so convenient...
79 head, tail = os.path.split(nativePath)
82 while head != None and head != '':
83 head, tail = os.path.split(head)
84 components.append(tail)
89 for component in components:
90 portablePath = posixpath.join(portablePath, component)
94 def getSourceFiles ():
97 for srcRoot in SRC_ROOTS:
98 baseDir = os.path.join(DEQP_DIR, srcRoot)
99 for root, dirs, files in os.walk(baseDir):
101 absPath = os.path.join(root, file)
102 nativeRelPath = os.path.relpath(absPath, DEQP_DIR)
103 portablePath = toPortablePath(nativeRelPath)
105 if isSourceFile(portablePath):
106 sources.append(portablePath)
112 def getSourceDirs (sourceFiles):
116 for sourceFile in sourceFiles:
117 sourceDir = posixpath.dirname(sourceFile)
119 if not sourceDir in seenDirs:
120 sourceDirs.append(sourceDir)
121 seenDirs.add(sourceDir)
125 def genMkStringList (items):
129 src += " \\\n\t%s" % item
133 def genAndroidMk (sourceDirs, sourceFiles):
135 src = src.replace("{INCLUDES}", genMkStringList(["$(deqp_dir)/%s" % s for s in sourceDirs]))
136 src = src.replace("{SRC_FILES}", genMkStringList(sourceFiles))
140 if __name__ == "__main__":
141 sourceFiles = getSourceFiles()
142 sourceDirs = getSourceDirs(sourceFiles)
143 androidMkText = genAndroidMk(sourceDirs, sourceFiles)
145 writeFile(os.path.join(DEQP_DIR, "AndroidGen.mk"), androidMkText)