Skip to content

Commit

Permalink
Fixed compilation issues
Browse files Browse the repository at this point in the history
* Fixed some compilation issues
* Update GenerateAndroidMk.py fix compile issue and
update tpl for cmrt and media_driver.
* Add 'media_add_curr_to_include_path()' to media_srcs.cmake

Tracked-On: OAM-117146
Signed-off-by: zhangyichix <yichix.zhang@intel.com>
Signed-off-by: zhepeng.xu <zhepengx.xu@intel.com>
  • Loading branch information
zhangyichix committed Apr 25, 2024
1 parent 8068c2e commit a7b942e
Show file tree
Hide file tree
Showing 336 changed files with 2,810 additions and 284 deletions.
67 changes: 42 additions & 25 deletions Tools/MediaDriverTools/Android/GenerateAndroidMk.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,42 +43,44 @@ def remove(f):
cmd = "rm " + f + "> /dev/null 2>&1"
os.system(cmd)


def getDriverName(root):
driver = "mod"
if not path.exists(path.join(root, driver)):
driver = "media-driver"
if not path.exists(path.join(root, driver)):
raise Exception("driver path " + driver +" not existed")
raise Exception("driver path " + driver + " not existed")
return driver


class Generator:
def __init__(self, src, root, makefile=None):
#where to put the Android makefile
# where to put the Android makefile
self.makefile = makefile if makefile else src

#where is the major source file
# where is the major source file
self.src = src

#driver name
# driver name
driver = getDriverName(root)
#where to put build file and template
# where to put build file and template
self.tool = path.join(root, driver, TOOL_DIR)

"""where to put the template"""
self.templ = path.join(root, driver, TEMPLATE_DIR)

#major function
# major function
def generate(self):

if path.exists(self.src) == False:
if not path.exists(self.src):
raise Exception(self.src + "not existed")
self.generateMakefile()
self.generateMakefile(debug=True)

mk = path.join(self.makefile, "Android.mk")
#remove old Android.mk
# remove old Android.mk
remove(mk)

#create new Android.mk
# create new Android.mk
with open(self.getTemplatePath()) as f:
tpl = f.read()
tpl = tpl.replace("@LOCAL_SRC_FILES", self.getSources())
Expand All @@ -88,7 +90,7 @@ def generate(self):
f.write(tpl)
print("generated " + self.getName() + " to " + self.makefile)

#virtuall functions
# virtuall functions
def getTemplate(self):
raise Exception("pure virtul function")

Expand All @@ -108,19 +110,19 @@ def getBuildDir(self):
return path.join(self.tool, 'build', self.getName())

def adjustSources(self, lines):
#print(lines)
# print(lines)
return lines

def adjustIncludes(self, lines):
#print(lines)
# print(lines)
return lines

def getCmakeCmd(self):
return "cmake " + self.src

def generateMakefile(self, debug=False):
#Win env can help us debug the script
#but we do not want generate makefile on Win-system
# Win env can help us debug the script
# but we do not want generate makefile on Win-system
if os.name == "nt":
return
verbose = ";" if debug else "> /dev/null 2>&1;"
Expand All @@ -136,11 +138,13 @@ def getIncludes(self):
includes = []
lines = text.split("\n")
for l in lines:
#normpath will make sure we did not refer outside.
# normpath will make sure we did not refer outside.
l = l.strip()[2:]
if l == '/linux':
continue

p = path.normpath(l)
j = p.find(self.src)
if j != -1:
includes.append(p[j:].replace(self.src, "$(LOCAL_PATH)"))
includes.append(path.join("$(LOCAL_PATH)", path.relpath(p, self.src)))
return INDENT + ("\n" + INDENT).join(includes) if includes else ""

def getDefines(self, name):
Expand All @@ -161,7 +165,7 @@ def getSources(self):
lines = re.findall(".*?\\.o:\\n", text)
lines = [l.replace(".o:\n", " \\") for l in lines]
self.adjustSources(lines)
#make source pretty
# make source pretty
return INDENT + ("\n" + INDENT).join(lines)


Expand All @@ -175,6 +179,7 @@ def getTemplate(self):

def getMakefile(self):
return "Source/GmmLib/Makefile"

def getFlagsfile(self):
return "Source/GmmLib/CMakeFiles/igfx_gmmumd_dll.dir/flags.make"

Expand All @@ -184,7 +189,7 @@ def adjustSources(self, lines):
if j == -1:
lines[i] = path.join("Source/GmmLib", l)
else:
lines[i] = path.join("Source", l[j+3:])
lines[i] = path.join("Source", l[j + 3:])


class CmrtGeneator(Generator):
Expand All @@ -207,7 +212,7 @@ def adjustSources(self, lines):
if j == -1:
lines[i] = path.join("linux", l)
else:
lines[i] = l[j+3:]
lines[i] = l[j + 3:]


class DriverGeneator(Generator):
Expand All @@ -217,11 +222,19 @@ def __init__(self, root):

def getCmakeCmd(self):
wd = path.join(self.src, "..")
cmd = 'cmake ' + wd +' -DCMAKE_INSTALL_PREFIX=/usr'
cmd = 'cmake ' + wd + ' -DCMAKE_INSTALL_PREFIX=/usr'
cmd += ' -DBUILD_ALONG_WITH_CMRTLIB=1 -DBS_DIR_GMMLIB=' + path.join(wd, '../gmmlib/Source/GmmLib/')
cmd += ' -DBS_DIR_COMMON=' + path.join(wd, '../gmmlib/Source/Common/')
cmd += ' -DBS_DIR_INC=' + path.join(wd, '../gmmlib/Source/inc/')
cmd += ' -DBS_DIR_MEDIA=' + wd
cmd += (' -DSKIP_GMM_CHECK=ON'
' -DGEN12=ON'
' -DXe_M=ON'
' -DXEHP_SDV=ON'
' -DENABLE_PRODUCTION_KMD=ON' # For /media_softlet/agnostic/Xe_R/Xe_HPC/renderhal
# ' -DGEN10=ON' # For /media_interface/media_interfaces_m10_cnl
' -DGEN12_RKL=ON' # For /media_interface/media_interfaces_m12_rkl
)
return cmd

def getTemplate(self):
Expand All @@ -234,14 +247,18 @@ def getFlagsfile(self):
return "media_driver/CMakeFiles/iHD_drv_video.dir/flags.make"

def adjustSources(self, lines):
lines[:] = [l for l in lines if "media_libva_putsurface_linux.cpp" not in l]
lines[:] = [l.replace('__/', '../') for l in lines
if "media_libva_putsurface_linux.cpp" not in l
and '/private/' not in l
]


class Main:

def run(self):
tool = path.dirname(__file__)
root = path.abspath(path.join(tool, "../../../../"))
print("root = "+root)
print("root = " + root)
gens = [GmmGeneator(root), CmrtGeneator(root), DriverGeneator(root)]
for g in gens:
g.generate()
Expand Down
4 changes: 4 additions & 0 deletions Tools/MediaDriverTools/Android/mk/cmrt.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ LOCAL_C_INCLUDES += \
@LOCAL_C_INCLUDES

LOCAL_CFLAGS += \
-Wno-error \
-Wno-unused-variable \
-Wno-unused-parameter \
-Wno-unused-private-field \
-Wno-non-virtual-dtor \
-DANDROID=1 \
@LOCAL_CFLAGS
Expand Down
31 changes: 25 additions & 6 deletions Tools/MediaDriverTools/Android/mk/media_driver.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,56 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
@LOCAL_SRC_FILES

LOCAL_HEADER_LIBRARIES := libva_headers

LOCAL_SHARED_LIBRARIES := \
libsync \
libcutils \
libutils \
libdrm \
libva \
liblog \


LOCAL_STATIC_LIBRARIES = \
libgmm_umd \

LOCAL_CPPFLAGS = \
-DDRV_I915 \
-DOTC_GRALLOC \
-DANDROID_VERSION=800 \
-fexceptions \
-frtti \
-std=c++14 \
-Wno-error \
-Wno-ignored-qualifiers \
-Wno-unused-parameter \
-Wno-missing-braces \
-Wno-overloaded-virtual \
-Wno-unused-variable \
-Wno-missing-field-initializers \
-Wno-unused-function \
-Wno-logical-op-parentheses \
-Wno-implicit-fallthrough \
-Wno-comment \
-Wno-unused-private-field \
-Wno-unused-value \
-Wno-parentheses-equality \
-Wno-unused-label \
-Wno-parentheses \
-Wno-c++11-narrowing \
-Wno-unused-lambda-capture \
-Wno-unreachable-code-loop-increment \
-Wno-delete-incomplete \
-DGMM_LIB_DLL \
@LOCAL_CFLAGS

LOCAL_CONLYFLAGS = -x c++
LOCAL_CFLAGS = $(LOCAL_CPPFLAGS)

LOCAL_C_INCLUDES = \
@LOCAL_C_INCLUDES

$(LOCAL_PATH)/../cmrtlib/linux/hardware \

#LOCAL_CPP_FEATURES := rtti exceptions

LOCAL_MODULE := i965_drv_video
LOCAL_PROPRIETARY_MODULE := true

include $(BUILD_SHARED_LIBRARY)
include $(BUILD_SHARED_LIBRARY)
84 changes: 84 additions & 0 deletions cmrtlib/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright(c) 2018 Intel Corporation

# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files(the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and / or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.

LOCAL_PATH:= $(call my-dir)


$(info value of CMRT_BUILD_TYPE is: $(CMRT_BUILD_TYPE))
$(info value of CMRT_ARCH is: $(CMRT_ARCH))

include $(CLEAR_VARS)

LOCAL_SRC_FILES := \
agnostic/hardware/cm_device.cpp \
agnostic/hardware/cm_device_export.cpp \
agnostic/hardware/cm_kernel_debugger.cpp \
agnostic/hardware/cm_perf_statistics.cpp \
agnostic/hardware/cm_queue.cpp \
agnostic/hardware/cm_surface_manager.cpp \
agnostic/hardware/cm_timer.cpp \
agnostic/share/cm_avs_state_msg_ex.cpp \
agnostic/share/cm_printf_host.cpp \
agnostic/share/cm_rt_helpers.cpp \
linux/hardware/cm_device_export_os.cpp \
linux/hardware/cm_device_os.cpp \
linux/hardware/cm_surface_manager_os.cpp \
linux/hardware/cm_timer_os.cpp \
linux/share/cm_performance.cpp \

LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/proprietary/share \
$(LOCAL_PATH)/agnostic/share \
$(LOCAL_PATH)/agnostic/hardware \
$(LOCAL_PATH)/linux/share \
$(LOCAL_PATH)/linux/hardware

LOCAL_CFLAGS += \
-Wno-error \
-Wno-unused-variable \
-Wno-unused-parameter \
-Wno-unused-private-field \
-Wno-non-virtual-dtor \
-DANDROID=1 \
-DCM_RT_EXPORTS \
-DISTDLIB_UMD \
-DVPHAL \
-D__CT__ \
-Digfxcmrt_EXPORTS

ifeq ($(CMRT_BUILD_TYPE), debug)
LOCAL_CFLAGS += \
-D_DEBUG \
-D__DEBUG \
-O0
else
LOCAL_CFLAGS += \
-fno-strict-aliasing \
-D_FORTIFY_SOURCE=2
endif


LOCAL_MODULE := libigfxcmrt
LOCAL_PROPRIETARY_MODULE := true

LOCAL_LDLIBS := -lc -lva -lva-android
LOCAL_SHARED_LIBRARIES := libc libdl libcutils liblog libutils libm libva libva-android

include $(BUILD_SHARED_LIBRARY)
6 changes: 4 additions & 2 deletions cmrtlib/linux/hardware/cm_device_os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,10 @@ CmDevice_RT::CmDevice_RT(
m_gtpinBufferUP1(nullptr),
m_gtpinBufferUP2(nullptr),
m_createOption(createOption),
m_driverStoreEnabled(0),
m_driFileDescriptor(0)
#if !defined(ANDROID)
m_driFileDescriptor(0),
#endif
m_driverStoreEnabled(0)
{

// New Surface Manager
Expand Down
3 changes: 2 additions & 1 deletion media_common/agnostic/common/cp/media_srcs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ set(COMMON_CP_DIRECTORIES_
set(CP_INTERFACE_DIRECTORIES_
${CP_INTERFACE_DIRECTORIES_}
${CMAKE_CURRENT_LIST_DIR}
)
)
media_add_curr_to_include_path()
3 changes: 2 additions & 1 deletion media_common/agnostic/common/heap_manager/media_srcs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ source_group( "Common Files" FILES ${TMP_HEADERS_} )
set(SOFTLET_COMMON_PRIVATE_INCLUDE_DIRS_
${SOFTLET_COMMON_PRIVATE_INCLUDE_DIRS_}
${CMAKE_CURRENT_LIST_DIR}
)
)
media_add_curr_to_include_path()
3 changes: 2 additions & 1 deletion media_common/agnostic/common/hw/media_srcs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,5 @@ set(SOFTLET_MHW_SFC_PRIVATE_INCLUDE_DIRS_
set(SOFTLET_MHW_VEBOX_PRIVATE_INCLUDE_DIRS_
${SOFTLET_MHW_VEBOX_PRIVATE_INCLUDE_DIRS_}
${CMAKE_CURRENT_LIST_DIR}
)
)
media_add_curr_to_include_path()
3 changes: 2 additions & 1 deletion media_common/agnostic/common/hw/vdbox/media_srcs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ set(TMP_SOFTLET_MHW_VDBOX_HUC_HEADERS_ "")
set(SOFTLET_MHW_VDBOX_PRIVATE_INCLUDE_DIRS_
${SOFTLET_MHW_VDBOX_PRIVATE_INCLUDE_DIRS_}
${CMAKE_CURRENT_LIST_DIR}
)
)
media_add_curr_to_include_path()

0 comments on commit a7b942e

Please sign in to comment.