@@ -43,42 +43,44 @@ def remove(f):
4343 cmd = "rm " + f + "> /dev/null 2>&1"
4444 os .system (cmd )
4545
46+
4647def getDriverName (root ):
4748 driver = "mod"
4849 if not path .exists (path .join (root , driver )):
4950 driver = "media-driver"
5051 if not path .exists (path .join (root , driver )):
51- raise Exception ("driver path " + driver + " not existed" )
52+ raise Exception ("driver path " + driver + " not existed" )
5253 return driver
5354
55+
5456class Generator :
5557 def __init__ (self , src , root , makefile = None ):
56- #where to put the Android makefile
58+ # where to put the Android makefile
5759 self .makefile = makefile if makefile else src
5860
59- #where is the major source file
61+ # where is the major source file
6062 self .src = src
6163
62- #driver name
64+ # driver name
6365 driver = getDriverName (root )
64- #where to put build file and template
66+ # where to put build file and template
6567 self .tool = path .join (root , driver , TOOL_DIR )
6668
6769 """where to put the template"""
6870 self .templ = path .join (root , driver , TEMPLATE_DIR )
6971
70- #major function
72+ # major function
7173 def generate (self ):
7274
73- if path .exists (self .src ) == False :
75+ if not path .exists (self .src ):
7476 raise Exception (self .src + "not existed" )
75- self .generateMakefile ()
77+ self .generateMakefile (debug = True )
7678
7779 mk = path .join (self .makefile , "Android.mk" )
78- #remove old Android.mk
80+ # remove old Android.mk
7981 remove (mk )
8082
81- #create new Android.mk
83+ # create new Android.mk
8284 with open (self .getTemplatePath ()) as f :
8385 tpl = f .read ()
8486 tpl = tpl .replace ("@LOCAL_SRC_FILES" , self .getSources ())
@@ -88,7 +90,7 @@ def generate(self):
8890 f .write (tpl )
8991 print ("generated " + self .getName () + " to " + self .makefile )
9092
91- #virtuall functions
93+ # virtuall functions
9294 def getTemplate (self ):
9395 raise Exception ("pure virtul function" )
9496
@@ -108,19 +110,19 @@ def getBuildDir(self):
108110 return path .join (self .tool , 'build' , self .getName ())
109111
110112 def adjustSources (self , lines ):
111- #print(lines)
113+ # print(lines)
112114 return lines
113115
114116 def adjustIncludes (self , lines ):
115- #print(lines)
117+ # print(lines)
116118 return lines
117119
118120 def getCmakeCmd (self ):
119121 return "cmake " + self .src
120122
121123 def generateMakefile (self , debug = False ):
122- #Win env can help us debug the script
123- #but we do not want generate makefile on Win-system
124+ # Win env can help us debug the script
125+ # but we do not want generate makefile on Win-system
124126 if os .name == "nt" :
125127 return
126128 verbose = ";" if debug else "> /dev/null 2>&1;"
@@ -136,11 +138,13 @@ def getIncludes(self):
136138 includes = []
137139 lines = text .split ("\n " )
138140 for l in lines :
139- #normpath will make sure we did not refer outside.
141+ # normpath will make sure we did not refer outside.
142+ l = l .strip ()[2 :]
143+ if l == '/linux' :
144+ continue
145+
140146 p = path .normpath (l )
141- j = p .find (self .src )
142- if j != - 1 :
143- includes .append (p [j :].replace (self .src , "$(LOCAL_PATH)" ))
147+ includes .append (path .join ("$(LOCAL_PATH)" , path .relpath (p , self .src )))
144148 return INDENT + ("\n " + INDENT ).join (includes ) if includes else ""
145149
146150 def getDefines (self , name ):
@@ -161,7 +165,7 @@ def getSources(self):
161165 lines = re .findall (".*?\\ .o:\\ n" , text )
162166 lines = [l .replace (".o:\n " , " \\ " ) for l in lines ]
163167 self .adjustSources (lines )
164- #make source pretty
168+ # make source pretty
165169 return INDENT + ("\n " + INDENT ).join (lines )
166170
167171
@@ -175,6 +179,7 @@ def getTemplate(self):
175179
176180 def getMakefile (self ):
177181 return "Source/GmmLib/Makefile"
182+
178183 def getFlagsfile (self ):
179184 return "Source/GmmLib/CMakeFiles/igfx_gmmumd_dll.dir/flags.make"
180185
@@ -184,7 +189,7 @@ def adjustSources(self, lines):
184189 if j == - 1 :
185190 lines [i ] = path .join ("Source/GmmLib" , l )
186191 else :
187- lines [i ] = path .join ("Source" , l [j + 3 :])
192+ lines [i ] = path .join ("Source" , l [j + 3 :])
188193
189194
190195class CmrtGeneator (Generator ):
@@ -207,7 +212,7 @@ def adjustSources(self, lines):
207212 if j == - 1 :
208213 lines [i ] = path .join ("linux" , l )
209214 else :
210- lines [i ] = l [j + 3 :]
215+ lines [i ] = l [j + 3 :]
211216
212217
213218class DriverGeneator (Generator ):
@@ -217,11 +222,19 @@ def __init__(self, root):
217222
218223 def getCmakeCmd (self ):
219224 wd = path .join (self .src , ".." )
220- cmd = 'cmake ' + wd + ' -DCMAKE_INSTALL_PREFIX=/usr'
225+ cmd = 'cmake ' + wd + ' -DCMAKE_INSTALL_PREFIX=/usr'
221226 cmd += ' -DBUILD_ALONG_WITH_CMRTLIB=1 -DBS_DIR_GMMLIB=' + path .join (wd , '../gmmlib/Source/GmmLib/' )
222227 cmd += ' -DBS_DIR_COMMON=' + path .join (wd , '../gmmlib/Source/Common/' )
223228 cmd += ' -DBS_DIR_INC=' + path .join (wd , '../gmmlib/Source/inc/' )
224229 cmd += ' -DBS_DIR_MEDIA=' + wd
230+ cmd += (' -DSKIP_GMM_CHECK=ON'
231+ ' -DGEN12=ON'
232+ ' -DXe_M=ON'
233+ ' -DXEHP_SDV=ON'
234+ ' -DENABLE_PRODUCTION_KMD=ON' # For /media_softlet/agnostic/Xe_R/Xe_HPC/renderhal
235+ # ' -DGEN10=ON' # For /media_interface/media_interfaces_m10_cnl
236+ ' -DGEN12_RKL=ON' # For /media_interface/media_interfaces_m12_rkl
237+ )
225238 return cmd
226239
227240 def getTemplate (self ):
@@ -234,14 +247,18 @@ def getFlagsfile(self):
234247 return "media_driver/CMakeFiles/iHD_drv_video.dir/flags.make"
235248
236249 def adjustSources (self , lines ):
237- lines [:] = [l for l in lines if "media_libva_putsurface_linux.cpp" not in l ]
250+ lines [:] = [l .replace ('__/' , '../' ) for l in lines
251+ if "media_libva_putsurface_linux.cpp" not in l
252+ and '/private/' not in l
253+ ]
254+
238255
239256class Main :
240257
241258 def run (self ):
242259 tool = path .dirname (__file__ )
243260 root = path .abspath (path .join (tool , "../../../../" ))
244- print ("root = " + root )
261+ print ("root = " + root )
245262 gens = [GmmGeneator (root ), CmrtGeneator (root ), DriverGeneator (root )]
246263 for g in gens :
247264 g .generate ()
0 commit comments