[PATCH] intel-gpu-tools: Add script to build testdisplay in Android environment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Ds, Sreedhara" <sreedhara.ds@xxxxxxxxx>

Added build_testdisplay.py under intel_gpu_tools/scripts. This script takes
care of all the dependencies of testdisplay tool like cairo and glib in android
build environment.

Signed-off-by: Ds, Sreedhara <sreedhara.ds@xxxxxxxxx>
---
 scripts/build_testdisplay.py |  287 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 287 insertions(+)
 create mode 100755 scripts/build_testdisplay.py

diff --git a/scripts/build_testdisplay.py b/scripts/build_testdisplay.py
new file mode 100755
index 0000000..62dd274
--- /dev/null
+++ b/scripts/build_testdisplay.py
@@ -0,0 +1,287 @@
+#!/usr/bin/env python
+
+# This python script helps to build "testdisplay" test under intel_gpu_tools
+# "testdisplay" test has dependency on cairo and glib
+# This script downloads cairo, pixman and glib for android
+# Generates android make file to build cairo and test display
+# modifies downloaded make files to enable "testdisplay"
+# This script must be run under inetl_gpu_tools/scripts directory
+# Creates new directory "testdisplay" under intel_gpu_tools and downloads required software here
+
+import sys
+import os
+import string
+
+CAIRO_REPO = 'git clone --recursive https://github.com/anoek/android-cairo.git'
+
+makefile1 = """ LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+include $(LOCAL_PATH)/jni/Android.mk
+#-----------------------------------------
+"""
+
+make1="""LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+#-----------------------------------------
+"""
+
+make2 = """
+LOCAL_C_INCLUDES +=                                      \\
+       $(LOCAL_PATH)/android-cairo/jni/cairo-extra                         \\
+       $(LOCAL_PATH)/android-cairo/jni/pixman/pixman                       \\
+       $(LOCAL_PATH)/android-cairo/jni/pixman-extra                       \\
+
+LIBCAIRO_CFLAGS:=                                                   \\
+    -DPACKAGE_VERSION="\"android-cairo\""                           \\
+    -DPACKAGE_BUGREPORT="\"http://github.com/anoek/android-cairo\""; \\
+    -DCAIRO_NO_MUTEX=1                                              \\
+    -DHAVE_STDINT_H                                                 \\
+    -DHAVE_UINT64_T                                                 \\
+
+LIBPIXMAN_CFLAGS:= 						    \\
+    -D_USE_MATH_DEFINES 					    \\
+    -DPIXMAN_NO_TLS 						    \\
+    -DPACKAGE="android-cairo" 					    \\
+
+
+LOCAL_MODULE    := libcairo-pixman
+
+LOCAL_CFLAGS    := \\
+    -O2 $(LIBCAIRO_CFLAGS) \\
+    -O2 $(LIBPIXMAN_CFLAGS) \\
+    -Iandroid-cairo/jni/pixman/pixman -Iandroid-cairo/jni/cairo/src \\
+    -Iandroid-cairo/jni/cairo-extra -Iandroid-cairo/jni/pixman-extra \\
+    -Wno-missing-field-initializers -Wno-attributes \\
+    -include "pixman-elf-fix.h"
+    -include "limits.h"
+
+LOCAL_LDFLAGS   := -lz
+LOCAL_SRC_FILES := $(LIBCAIRO_SRC)
+
+include $(BUILD_STATIC_LIBRARY)
+"""
+
+make3="""
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(INTEL_GPU_TOOLS)/tests/testdisplay.c       \\
+                   $(INTEL_GPU_TOOLS)/tests/testdisplay_hotplug.c \\
+                   $(INTEL_GPU_TOOLS)/lib/igt_kms.c \\
+                   $(INTEL_GPU_TOOLS)/testdisplay/testdisplay_stub.c
+
+"""
+
+make4="""
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
+
+LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES
+LOCAL_CFLAGS += -DANDROID -DHAVE_MMAP64
+LOCAL_CFLAGS += -DIGT_DATADIR="\"\""
+LOCAL_CFLAGS += -std=c99
+LOCAL_CFLAGS += -Wno-return-type
+
+LOCAL_MODULE := testdisplay
+LOCAL_MODULE_TAGS := optional
+LOCAL_STATIC_LIBRARIES := libintel_gpu_tools libcairo-pixman libglib-2.0 libgmodule-2.0
+LOCAL_SHARED_LIBRARIES := libpciaccess  libdrm libdrm_intel
+include $(BUILD_EXECUTABLE)
+"""
+
+env1 = """export TOP=$ANDROID_BUILD_TOP
+export BUILD_STATIC=true
+
+export IGT_LIB_CFLAGS="-I$ANDROID_BUILD_TOP/external/PRIVATE/libpciaccess/include \\
+                        -I$ANDROID_BUILD_TOP/external/PRIVATE/drm \\
+                        -I$ANDROID_BUILD_TOP/external/PRIVATE/drm/intel \\
+                        -I$ANDROID_BUILD_TOP/external/PRIVATE/drm/include \\
+                        -I$ANDROID_BUILD_TOP/external/PRIVATE/drm/include/drm \\
+                        -DHAVE_MMAP64"
+"""
+
+# Following files are not required in building cairo library
+cairo_file_filter = [ 'xcb', 'cogl', 'directfb', 'egl', 'cairo-gl', 'ft-font',
+	'cairo-image-mask-compositor', 'cairo-os2-surface', 'cairo-pdf', 'cairo-png',
+	'cairo-ps-surface', 'cairo-quartz', 'cairo-script-surface', 'cairo-svg-surface',
+	'cairo-vg-surface', 'cairo-wgl', 'cairo-xlib', 'cairo-xml', 'check-',
+]
+
+# Many files exists under pixman. Only following files are required in building pixman
+pixman_files1 = ['pixman-access.c', 'pixman-access-accessors.c', 'pixman-gradient-walker.c',
+               'pixman-region16.c', 'pixman-region32.c', 'pixman-image.c',
+               'pixman-implementation.c', 'pixman-general.c', 'pixman.c',
+               'pixman-fast-path.c', 'pixman-solid-fill.c', 'pixman-conical-gradient.c',
+               'pixman-linear-gradient.c', 'pixman-radial-gradient.c', 'pixman-bits-image.c',
+               'pixman-utils.c', 'pixman-edge.c', 'pixman-edge-accessors.c', 'pixman-trap.c',
+	       'pixman-timer.c', 'pixman-matrix.c', 'pixman-noop.c', 'pixman-cpu.c',
+]
+
+#Files under pixman-extra
+pixman_files2 = ['pixman-combine32.c', 'pixman-combine64.c',]
+
+#Downlaods cairo and glib for android
+def download_cairo_glib():
+	print 'Downloading cairo ....'
+	os.system('git clone --recursive https://github.com/anoek/android-cairo.git')
+	print 'Downloading glib ....'
+	os.system('git clone https://github.com/ieei/glib.git')
+
+#Checks is files is under filter list or not
+#Entry in cairo_file_filter is not included in building cairo library
+def is_filtered(file):
+	for filter in cairo_file_filter:
+		if(string.find(file, filter) >= 0): return True
+	return False
+
+#Default glib make is for ARM. Edit the make file to suite our needs
+#Adds defines for G_BIT_LOCK_FORCE_FUTEX_EMULATION to overcome compilatiuon error
+#Adds compiler flag no-format-security to overcome compilatiuon error
+def edit_glib_make():
+	if(os.path.exists('glib/glib/Android.mk_ORG')):
+		return
+	os.system('cp glib/glib/Android.mk glib/glib/Android.mk_ORG')
+	f = open('glib/glib/Android.mk')
+	lines = f.readlines()
+	f.close()
+
+	f = open('glib/glib/Android.mk', 'w')
+	for line in lines:
+		if(string.find(line, '-DG_DISABLE_DEPRECATED') >= 0):
+			f.write('\t' + '-DG_BIT_LOCK_FORCE_FUTEX_EMULATION' + '\t\\\n')
+			f.write('\t' + '-Wno-format-security' + '\t\\\n')
+		f.write(line)
+
+#Edit make file for building libintel_gpu-tools (intel_gpu_tools/lib/Andrid.nk)
+#Adds environ variable IGT_LIB_CFLAGS which is defined in igtbuild.sh
+def edit_igt_lib_make(pardir):
+	mfile = pardir + os.sep + 'lib' + os.sep + 'Android.mk'
+
+	if(os.path.exists( mfile + '_ORG')):
+		return
+
+	if(not os.path.exists(mfile)):
+		print 'No "' + mfile + '" found'
+
+	os.system('cp ' + mfile + ' ' + mfile + '_ORG')
+	f = open(mfile)
+	lines = f.readlines()
+	f.close()
+	f = open(mfile, 'w')
+	for line in lines:
+		if(string.find(line, 'LOCAL_CFLAGS += -DANDROID') >= 0):
+			f.write('LOCAL_CFLAGS += $(IGT_LIB_CFLAGS)' + '\n')
+		f.write(line)
+
+#Create "igtbuild.sh" which has include paths under android source
+#User need to modify this according to andoird source tree
+def gen_environ_file(pdir):
+	f = open(pdir + os.sep +  'igtbuild.sh', 'w')
+	f.write(env1)
+	f.close()
+
+#Creates make file (intel_gpu_tools/testdisplay/Android.mk) to build cairo,
+# intel gpu tools library and test display.
+def gen_make(pardir, f):
+	android_cairo_dir = pardir + os.sep + 'android-cairo'
+	cairo_files = os.listdir(android_cairo_dir + os.sep + 'jni/cairo/src')
+	cairo_files.sort()
+	f.write('LIBCAIRO_SRC = \\' + '\n')
+	for file in cairo_files:
+		if(os.path.splitext(file)[1] != '.c'): continue
+		if(is_filtered(file)): continue
+		#f.write('\tcairo/src' + os.sep + file + ' \\' + '\n')
+		f.write('\tandroid-cairo/jni/cairo/src' + os.sep + file + ' \\' + '\n')
+	for file in pixman_files1:
+		f.write('\tandroid-cairo/jni/pixman/pixman' + os.sep + file + ' \\' + '\n')
+	for file in pixman_files2:
+		f.write('\tandroid-cairo/jni/pixman-extra' + os.sep + file + ' \\' + '\n')
+	f.write('\n')
+	f.write(make2)
+	f.write('#----------------------------------------------------------------\n')
+	f.write('include $(LOCAL_PATH)/../lib/Android.mk\n')
+	f.write('#----------------------------------------------------------------\n')
+
+	f.write(make3)
+	gen_includes(testdisplay_dir, f)
+	f.write(make4)
+
+def gen_includes(pardir, f):
+        f.write('LOCAL_CFLAGS += -I' + pardir + '/android-cairo/jni/cairo/src' + '\n')
+        f.write('LOCAL_CFLAGS += -I' + pardir + '/android-cairo/jni/cairo-extra' + '\n')
+        f.write('LOCAL_CFLAGS += -I' + pardir + '/glib' + '\n')
+        f.write('LOCAL_CFLAGS += -I' + pardir + '/glib/android' + '\n')
+        f.write('LOCAL_CFLAGS += -I' + pardir + '/glib/glib' + '\n')
+        f.write('LOCAL_CFLAGS += -I$(ANDROID_BUILD_TOP)/external/PRIVATE/libpciaccess/include' + '\n')
+
+
+if __name__ == "__main__":
+	"""
+	if(len(sys.argv) <= 1):
+		usage();
+		sys.exit(0);
+	"""
+
+	pardir, curdir = os.path.split(os.getcwd())
+	testdisplay_dir = pardir + os.sep + 'testdisplay'
+	android_cairo_dir = testdisplay_dir + os.sep + 'android-cairo'
+	if(curdir == 'scripts'):
+		if(not os.path.exists(testdisplay_dir)): os.mkdir(testdisplay_dir)
+		os.chdir(testdisplay_dir)
+		#os.system('cd ..')
+	else:
+		print 'Run the script in the directory \"scripts\"'
+		sys.exit(0)
+
+	if(not os.path.exists('android-cairo')):
+		download_cairo_glib()
+		"""
+		try:
+			ans = raw_input('Want to download andoird cairo source? [y]:')
+		except:
+			ans = 'y'
+
+		if(ans == '' or ans == 'y'):
+			print 'Downloading android cairo sources, this may take some time ..\n'
+			download_cairo_glib()
+		else:
+			sys.exit(0)
+		"""
+
+	if(not os.path.exists(android_cairo_dir + os.sep + 'jni/cairo/src')):
+		print 'Invalid android cairo, download cairo sources from ' + CAIRO_REPO + ' and try again'
+		sys.exit(0);
+
+	make_file = testdisplay_dir + os.sep + 'Android.mk'
+	print ''
+	if(not os.path.exists(make_file)):
+		print 'Generating makefiles ...'
+		f = open(make_file, 'w')
+		f.write('INTEL_GPU_TOOLS := ' + '..' + '\n')
+		f.write(make1)
+		gen_make(testdisplay_dir, f)
+		f.close()
+	else:
+		print 'Nothing to do, make file already exists ...'
+
+	edit_glib_make()
+
+	f = open(testdisplay_dir + os.sep + 'testdisplay_stub.c', 'w')
+	f.write('void _pixman_implementation_create_sse2() {}' + '\n')
+	f.write('void cairo_image_surface_create_from_png() {printf("%s not supported\\n", __FUNCTION__); exit(0);}' + '\n')
+	f.write('void cairo_surface_write_to_png() {printf("%s not supported\\n", __FUNCTION__); exit(0);}' + '\n')
+	f.write('void __android_log_print() {}' + '\n')
+
+	f.close()
+
+	edit_igt_lib_make(pardir)
+	gen_environ_file(testdisplay_dir)
+
+	print 'Follow the below steps to build testdisplay\n'
+	print '-------------------------------------------------------------------------'
+	print '1. Run "lunch <target platform>'
+	#print '2. Set environment "TOP" to android source root'
+	print '2. cd intel_gpu_tools/testdisplay'
+	print '3. source igtbuild.sh. if required, edit according to android source path'
+	print '4. Build testdisplay - Run "cd glib; mm; cd -; mm"'
+	print '-------------------------------------------------------------------------'
+
-- 
1.7.9.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux