Skip to contentSkip to conversation

Android build system clean-up

PATCH In review [email protected] 2 participants 7 messages Jan 31, 2014 – Feb 4, 2014 Library code

lore
Share & tools
lore
#0 lore raw

cover Android build system clean-up

From: Rafael Barbalho <[email protected]>

IGT in android still had some hang-ups from the initial porting, we were re-compiling the lib directory every time for each tool or test binary. It also could get its include paths confused due to overloaded make variable names. It also wasn't possible to do the typical android thing of issuing the "mm" command inside either the tests or tools directory to only rebuild & install the binaries that you modified.

The patch series tries to clean all this up by using the new include path mechanism introduced in recent versions of android and making the lib directory as a static library in the same way that is it done in the autotools version.

Rafael Barbalho (5):
android: Handle the case when android doesn't have mmap64
android: Clean-up common makefile directives
android: Add makefile for the lib directory
android: Add the generation of vesion.h & config.h to lib
android: Change tests & tools directory to use the lib directory

 Android.mk            |  5 +---
 lib/Android.mk        | 64 +++++++++++++++++++++++++++++++++++++++++++++++
 lib/intel_gpu_tools.h | 11 ++++++++
 tests/Android.mk      | 69 ++++-----------------------------------------------
 tools/Android.mk      | 37 ++++-----------------------
 5 files changed, 86 insertions(+), 100 deletions(-)
 create mode 100644 lib/Android.mk
Signature · 1 line
1.8.5.2
#1 lore raw

PATCH 1/5 android: Handle the case when android doesn't have mmap64

From: Rafael Barbalho <[email protected]>

Not all versions of Android have the mmap64 call, thus a suitable alternative must be called.

---
 lib/intel_gpu_tools.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
lib/intel_gpu_tools.h +11 -0
index b242243..1ae1bab 100644
@@ -35,6 +35,17 @@
 #include "intel_chipset.h"
 #include "intel_reg.h"
 
+#ifdef ANDROID
+#ifndef HAVE_MMAP64
+extern void*  __mmap2(void *, size_t, int, int, int, off_t);
+static inline void *mmap64(void *addr, size_t length, int prot, int flags,
+        int fd, off64_t offset)
+{
+    return __mmap2(addr, length, prot, flags, fd, offset >> 12);
+}
+#endif
+#endif
+
 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
 
 extern void *mmio;
Signature · 1 line
1.8.5.2
#2 lore raw

PATCH 2/5 android: Clean-up common makefile directives

In reply to [email protected]

From: Rafael Barbalho <[email protected]>

All the Android.mk files had the same directives to find the path of libdrm & libpciaccess. These are no longer required as the android system now allows the libraries being used to export include paths to dependant modules & programs.

---
 tests/Android.mk | 20 +-------------------
 tools/Android.mk | 20 +-------------------
 2 files changed, 2 insertions(+), 38 deletions(-)
tests/Android.mk +1 -19
index abccb7f..0e292a9 100644
@@ -1,21 +1,6 @@
 include $(LOCAL_PATH)/tests/Makefile.sources
 include $(LOCAL_PATH)/lib/Makefile.sources
 
-LIBPCIACCESS_PATH := $(firstword $(wildcard  \
-   $(TOP)/external/PRIVATE/libpciaccess      \
-   $(TOP)/hardware/intel/libpciaccess        \
-   $(TOP)/external/libpciaccess))
-ifeq ($(LIBPCIACCESS_PATH),)
-   $(error "Unable to find libpciaccess!")
-endif
-
-LIBDRM_PATH := $(firstword $(wildcard  \
-   $(TOP)/external/PRIVATE/drm         \
-   $(TOP)/external/drm))
-ifeq ($(LIBDRM_PATH),)
-   $(error "Unable to find libdrm!")
-endif
-
 skip_lib_list := \
     igt_kms.c \
     igt_kms.h
@@ -65,10 +50,7 @@ define add_test
        $(LOCAL_PATH)/config.h
 
     LOCAL_C_INCLUDES +=              \
-       $(LOCAL_PATH)/lib             \
-       $(LIBDRM_PATH)/include/drm    \
-       $(LIBDRM_PATH)/intel          \
-       $(LIBPCIACCESS_PATH)/include
+       $(LOCAL_PATH)/lib
 
     LOCAL_CFLAGS += -DHAVE_STRUCT_SYSINFO_TOTALRAM
     LOCAL_CFLAGS += -DANDROID -UNDEBUG -include "check-ndebug.h"
tools/Android.mk +1 -19
index 99c39b7..7227c89 100644
@@ -1,21 +1,6 @@
 include $(LOCAL_PATH)/tools/Makefile.sources
 include $(LOCAL_PATH)/lib/Makefile.sources
 
-LIBPCIACCESS_PATH := $(firstword $(wildcard  \
-   $(TOP)/external/PRIVATE/libpciaccess      \
-   $(TOP)/hardware/intel/libpciaccess        \
-   $(TOP)/external/libpciaccess))
-ifeq ($(LIBPCIACCESS_PATH),)
-   $(error "Unable to find libpciaccess!")
-endif
-
-LIBDRM_PATH := $(firstword $(wildcard  \
-   $(TOP)/external/PRIVATE/drm         \
-   $(TOP)/external/drm))
-ifeq ($(LIBDRM_PATH),)
-   $(error "Unable to find libdrm!")
-endif
-
 skip_lib_list := \
     igt_kms.c \
     igt_kms.h
@@ -33,10 +18,7 @@ define add_tool
        $(LIB_SOURCES)
 
     LOCAL_C_INCLUDES +=              \
-       $(LOCAL_PATH)/lib             \
-       $(LIBDRM_PATH)/include/drm    \
-       $(LIBDRM_PATH)/intel          \
-       $(LIBPCIACCESS_PATH)/include
+       $(LOCAL_PATH)/lib
 
     LOCAL_CFLAGS += -DHAVE_TERMIOS_H
     LOCAL_CFLAGS += -DHAVE_STRUCT_SYSINFO_TOTALRAM
Signature · 1 line
1.8.5.2
#3 lore raw

PATCH 3/5 android: Add makefile for the lib directory

In reply to [email protected]

From: Rafael Barbalho <[email protected]>

The lib directory should really be compiled as a static library on its own and be re-used by any tests or tools that require it.

---
 lib/Android.mk | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 lib/Android.mk
lib/Android.mk new file +31 -0
new file mode 100644
index 0000000..23c7d42
@@ -0,0 +1,31 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(LOCAL_PATH)/Makefile.sources
+
+skip_lib_list := \
+    igt_kms.c \
+    igt_kms.h
+
+lib_list := $(filter-out $(skip_lib_list),$(libintel_tools_la_SOURCES))
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(lib_list)
+
+LOCAL_C_INCLUDES +=              \
+	$(LOCAL_PATH)/..
+
+LOCAL_EXPORT_C_INCLUDE_DIRS += $(LOCAL_PATH)
+
+LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES
+LOCAL_CFLAGS += -DHAVE_STRUCT_SYSINFO_TOTALRAM
+LOCAL_CFLAGS += -DANDROID
+LOCAL_CFLAGS += -std=c99
+LOCAL_MODULE:= libintel_gpu_tools
+
+LOCAL_SHARED_LIBRARIES := libpciaccess  \
+			  libdrm        \
+			  libdrm_intel
+
+include $(BUILD_STATIC_LIBRARY)
+
Signature · 1 line
1.8.5.2
#4 lore raw

PATCH 4/5 android: Add the generation of vesion.h & config.h to lib

In reply to [email protected]

From: Rafael Barbalho <[email protected]>

The lib directory is used by all the tests & tools so it should really be the place where the generate files are created.

---
 lib/Android.mk | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
lib/Android.mk +33 -0
index 23c7d42..724d884 100644
@@ -1,5 +1,34 @@
 LOCAL_PATH := $(call my-dir)
 
+GPU_TOOLS_PATH := $(LOCAL_PATH)/..
+
+.PHONY: version.h.tmp
+
+$(GPU_TOOLS_PATH)/version.h.tmp:
+	@touch $@
+	@if test -d ../.git; then \
+		if which git > /dev/null; then git log -n 1 --oneline | \
+		        sed 's/^\([^ ]*\) .*/#define IGT_GIT_SHA1 "g\1"/' \
+		        >> $@ ; \
+		fi \
+	else \
+		echo '#define IGT_GIT_SHA1 "NOT-GIT"' >> $@ ; \
+	fi
+
+$(GPU_TOOLS_PATH)/version.h: $(GPU_TOOLS_PATH)/version.h.tmp
+	@echo "updating version.h"
+	@if ! cmp -s $(GPU_TOOLS_PATH)/version.h.tmp $(GPU_TOOLS_PATH)/version.h; then \
+		mv $(GPU_TOOLS_PATH)/version.h.tmp $(GPU_TOOLS_PATH)/version.h ; \
+	else \
+		rm $(GPU_TOOLS_PATH)/version.h.tmp ; \
+	fi
+
+# FIXME: autogenerate this info #
+$(GPU_TOOLS_PATH)/config.h:
+	@echo "updating config.h"
+	@echo '#define PACKAGE_VERSION "1.5"' >> $@ ; \
+	echo '#define TARGET_CPU_PLATFORM "android-ia"' >> $@ ;
+
 include $(LOCAL_PATH)/Makefile.sources
 
 skip_lib_list := \
@@ -12,6 +41,10 @@ include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(lib_list)
 
+LOCAL_GENERATED_SOURCES :=       \
+	$(GPU_TOOLS_PATH)/version.h  \
+	$(GPU_TOOLS_PATH)/config.h
+
 LOCAL_C_INCLUDES +=              \
 	$(LOCAL_PATH)/..
 
Signature · 1 line
1.8.5.2
#5 lore raw

PATCH 5/5 android: Change tests & tools directory to use the lib directory

In reply to [email protected]

From: Rafael Barbalho <[email protected]>

Instead of recompiling the lib directory for every tool or tests we can just re-use the static library. This also has the nice side effect of fixing the android "mm" command to allow android users to only rebuild the local changes in either the test or tools directory.

---
 Android.mk       |  5 +----
 lib/Android.mk   |  2 +-
 tests/Android.mk | 51 +++++----------------------------------------------
 tools/Android.mk | 19 +++++--------------
 4 files changed, 12 insertions(+), 65 deletions(-)
Android.mk +1 -4
index 7b42d10..8aeb2d4 100644
@@ -1,5 +1,2 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(LOCAL_PATH)/tests/Android.mk
-include $(LOCAL_PATH)/tools/Android.mk
+include $(call all-named-subdir-makefiles, lib tests tools)
 
lib/Android.mk +1 -1
index 724d884..6735255 100644
@@ -48,7 +48,7 @@ LOCAL_GENERATED_SOURCES :=       \
 LOCAL_C_INCLUDES +=              \
 	$(LOCAL_PATH)/..
 
-LOCAL_EXPORT_C_INCLUDE_DIRS += $(LOCAL_PATH)
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
 
 LOCAL_CFLAGS += -DHAVE_LIBDRM_ATOMIC_PRIMITIVES
 LOCAL_CFLAGS += -DHAVE_STRUCT_SYSINFO_TOTALRAM
tests/Android.mk +5 -46

67 lines not on this page · raw message

tools/Android.mk +5 -14
index 7227c89..a957ec1 100644
@@ -1,24 +1,13 @@
-include $(LOCAL_PATH)/tools/Makefile.sources
-include $(LOCAL_PATH)/lib/Makefile.sources
+LOCAL_PATH := $(call my-dir)
 
-skip_lib_list := \
-    igt_kms.c \
-    igt_kms.h
-
-lib_list := $(filter-out $(skip_lib_list),$(libintel_tools_la_SOURCES))
-LIB_SOURCES := $(addprefix lib/,$(lib_list))
+include $(LOCAL_PATH)/Makefile.sources
 
 #================#
 
 define add_tool
     include $(CLEAR_VARS)
 
-    LOCAL_SRC_FILES :=          \
-       tools/$1.c               \
-       $(LIB_SOURCES)
-
-    LOCAL_C_INCLUDES +=              \
-       $(LOCAL_PATH)/lib
+    LOCAL_SRC_FILES := $1.c
 
     LOCAL_CFLAGS += -DHAVE_TERMIOS_H
     LOCAL_CFLAGS += -DHAVE_STRUCT_SYSINFO_TOTALRAM
@@ -32,6 +21,8 @@ define add_tool
     LOCAL_MODULE := $1
     LOCAL_MODULE_TAGS := optional
 
+    LOCAL_STATIC_LIBRARIES := libintel_gpu_tools
+
     LOCAL_SHARED_LIBRARIES := libpciaccess  \
                               libdrm        \
                               libdrm_intel
Signature · 1 line
1.8.5.2
#6 lore raw
In reply to [email protected]
Quoted 13 lines · On Fri, Jan 31, 2014 at 02:57:35PM +0000, [email protected] wrote:

From: Rafael Barbalho <[email protected]>

IGT in android still had some hang-ups from the initial porting, we were re-compiling the lib directory every time for each tool or test binary. It also could get its include paths confused due to overloaded make variable names. It also wasn't possible to do the typical android thing of issuing the "mm" command inside either the tests or tools directory to only rebuild & install the binaries that you modified.

The patch series tries to clean all this up by using the new include path mechanism introduced in recent versions of android and making the lib directory as a static library in the same way that is it done in the autotools version.

Quoted 6 lines

Rafael Barbalho (5):
android: Handle the case when android doesn't have mmap64
android: Clean-up common makefile directives
android: Add makefile for the lib directory
android: Add the generation of vesion.h & config.h to lib
android: Change tests & tools directory to use the lib directory

Let's skip formal r-b tags for that series, the patches look reasonable to me and I'm sure someone will fix the issues should there be any.

So patches pushed, thanks.

Signature · 1 line
Damien