Skip to contentSkip to conversation

intel-gpu-tools: fix version.h creation in android

PATCH Superseded [email protected] 2 participants 3 messages Jul 24, 2014 Library code

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 intel-gpu-tools: fix version.h creation in android

From: Tim Gore <[email protected]>

commit 743dc7997aa9f5210055896940d87c88983dcda6 breaks the build under Android because version.h is not created. This happens because the android make executes from the ANDROID_BUILD_TOP directory rather than from the directory containing the source files, so we need Android specific make instructions to generate version.h

---
 lib/Android.mk | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
lib/Android.mk +27 -1
index 6f444a0..d6b181d 100644
@@ -1,6 +1,7 @@
 LOCAL_PATH := $(call my-dir)
 
 GPU_TOOLS_PATH := $(LOCAL_PATH)/..
+IGT_LIB_PATH := $(LOCAL_PATH)
 
 # FIXME: autogenerate this info #
 $(GPU_TOOLS_PATH)/config.h:
@@ -13,7 +14,7 @@ include $(LOCAL_PATH)/Makefile.sources
 include $(CLEAR_VARS)
 
 LOCAL_GENERATED_SOURCES :=       \
-	$(GPU_TOOLS_PATH)/lib/version.h  \
+	$(IGT_LIB_PATH)/version.h  \
 	$(GPU_TOOLS_PATH)/config.h
 
 LOCAL_C_INCLUDES +=              \
@@ -45,5 +46,30 @@ endif
 
 LOCAL_SRC_FILES := $(filter-out $(skip_lib_list),$(libintel_tools_la_SOURCES))
 
+.PHONY: version.h.tmp
+
+$(IGT_LIB_PATH)/version.h.tmp:
+	@touch $@
+	@if test -d $(GPU_TOOLS_PATH)/.git; then \
+		if which git > /dev/null 2>&1; then cd $(@D); \
+			git log -n 1 --oneline | \
+			sed 's/^\([^ ]*\) .*/#define IGT_GIT_SHA1 "g\1"/' \
+			>> $(@F) ; \
+		else \
+			echo '#define IGT_GIT_SHA1 "NO-GIT"' >> $@ ; \
+		fi \
+	else \
+		echo '#define IGT_GIT_SHA1 "NOT-GIT"' >> $@ ; \
+	fi
+
+
+$(IGT_LIB_PATH)/version.h: $(IGT_LIB_PATH)/version.h.tmp
+	@if ! cmp -s $(IGT_LIB_PATH)/version.h.tmp $(IGT_LIB_PATH)/version.h; then \
+		mv $(IGT_LIB_PATH)/version.h.tmp $(IGT_LIB_PATH)/version.h ; \
+	else \
+		rm $(IGT_LIB_PATH)/version.h.tmp ; \
+	fi
+
+
 include $(BUILD_STATIC_LIBRARY)
 
Signature · 1 line
1.9.2
#1 lore raw
Quoted 9 lines · On 24 July 2014 15:40, <[email protected]> wrote:

From: Tim Gore <[email protected]>

commit 743dc7997aa9f5210055896940d87c88983dcda6 breaks the build under Android because version.h is not created. This happens because the android make executes from the ANDROID_BUILD_TOP directory rather than from the directory containing the source files, so we need Android specific make instructions to generate version.h

Could this also be fixed by defining the various paths (as below) in Makefile.am as well and still re-use the same rule from Makefile.sources, which gets included by both Android.mk and Makefile.am anyway?

Quoted 76 lines
---
 lib/Android.mk | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
lib/Android.mk +27 -2
index 6f444a0..d6b181d 100644
@@ -1,6 +1,7 @@
 LOCAL_PATH := $(call my-dir)
 
 GPU_TOOLS_PATH := $(LOCAL_PATH)/..
+IGT_LIB_PATH := $(LOCAL_PATH)
 
 # FIXME: autogenerate this info #
 $(GPU_TOOLS_PATH)/config.h:
@@ -13,7 +14,7 @@ include $(LOCAL_PATH)/Makefile.sources
 include $(CLEAR_VARS)
 
 LOCAL_GENERATED_SOURCES :=       \
-       $(GPU_TOOLS_PATH)/lib/version.h  \
+       $(IGT_LIB_PATH)/version.h  \
        $(GPU_TOOLS_PATH)/config.h
 
 LOCAL_C_INCLUDES +=              \
@@ -45,5 +46,30 @@ endif
 
 LOCAL_SRC_FILES := $(filter-out $(skip_lib_list),$(libintel_tools_la_SOURCES))
 
+.PHONY: version.h.tmp
+
+$(IGT_LIB_PATH)/version.h.tmp:
+       @touch $@
+       @if test -d $(GPU_TOOLS_PATH)/.git; then \
+               if which git > /dev/null 2>&1; then cd $(@D); \
+                       git log -n 1 --oneline | \
+                       sed 's/^\([^ ]*\) .*/#define IGT_GIT_SHA1 "g\1"/' \
+                       >> $(@F) ; \
+               else \
+                       echo '#define IGT_GIT_SHA1 "NO-GIT"' >> $@ ; \
+               fi \
+       else \
+               echo '#define IGT_GIT_SHA1 "NOT-GIT"' >> $@ ; \
+       fi
+
+
+$(IGT_LIB_PATH)/version.h: $(IGT_LIB_PATH)/version.h.tmp
+       @if ! cmp -s $(IGT_LIB_PATH)/version.h.tmp $(IGT_LIB_PATH)/version.h; then \
+               mv $(IGT_LIB_PATH)/version.h.tmp $(IGT_LIB_PATH)/version.h ; \
+       else \
+               rm $(IGT_LIB_PATH)/version.h.tmp ; \
+       fi
+
+
 include $(BUILD_STATIC_LIBRARY)
 
--

1.9.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

author
#2 lore raw
Quoted 16 lines

-----Original Message-----
From: Thomas Wood [mailto:[email protected]]
Sent: Thursday, July 24, 2014 4:27 PM
To: Gore, Tim
Cc: Intel Graphics Development
Subject: Re: [Intel-gfx] [PATCH] intel-gpu-tools: fix version.h creation in android

Quoted 5 lines · On 24 July 2014 15:40, <[email protected]> wrote:

From: Tim Gore <[email protected]>

commit 743dc7997aa9f5210055896940d87c88983dcda6
breaks the build under Android because version.h is not created. This happens because the android make executes from the

Quoted 8 lines

ANDROID_BUILD_TOP

Quoted 2 lines

directory rather than from the directory containing the source files, so we need Android specific make instructions to generate version.h

Could this also be fixed by defining the various paths (as below) in Makefile.am as well and still re-use the same rule from Makefile.sources, which gets included by both Android.mk and Makefile.am anyway?

That may be possible, I have not tried it. I'm something of a novice with Autotools but I'll give it a go.

Quoted 78 lines
Quoted 42 lines
---
 lib/Android.mk | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
lib/Android.mk index 6f444a0..d6b181d renamed from lib/Android.mk +0 -0

100644

lib/Android.mk +11 -1
@@ -1,6 +1,7 @@
 LOCAL_PATH := $(call my-dir)
 
 GPU_TOOLS_PATH := $(LOCAL_PATH)/..
+IGT_LIB_PATH := $(LOCAL_PATH)
 
 # FIXME: autogenerate this info #
 $(GPU_TOOLS_PATH)/config.h:
@@ -13,7 +14,7 @@ include $(LOCAL_PATH)/Makefile.sources  include
 $(CLEAR_VARS)
 
 LOCAL_GENERATED_SOURCES :=       \
-       $(GPU_TOOLS_PATH)/lib/version.h  \
+       $(IGT_LIB_PATH)/version.h  \
        $(GPU_TOOLS_PATH)/config.h
 
 LOCAL_C_INCLUDES +=              \
@@ -45,5 +46,30 @@ endif
 
 LOCAL_SRC_FILES := $(filter-out
 $(skip_lib_list),$(libintel_tools_la_SOURCES))
 
+.PHONY: version.h.tmp
+
+$(IGT_LIB_PATH)/version.h.tmp:
+       @touch $@
+       @if test -d $(GPU_TOOLS_PATH)/.git; then \
+               if which git > /dev/null 2>&1; then cd $(@D); \
+                       git log -n 1 --oneline | \
+                       sed 's/^\([^ ]*\) .*/#define IGT_GIT_SHA1 "g\1"/' \
+                       >> $(@F) ; \

lib/Android.mk endif · line 68

Quoted 10 lines
lib/Android.mk +10 -0
+               else \
+                       echo '#define IGT_GIT_SHA1 "NO-GIT"' >> $@ ; \
+               fi \
+       else \
+               echo '#define IGT_GIT_SHA1 "NOT-GIT"' >> $@ ; \
+       fi
+
+
+$(IGT_LIB_PATH)/version.h: $(IGT_LIB_PATH)/version.h.tmp
+       @if ! cmp -s $(IGT_LIB_PATH)/version.h.tmp

$(IGT_LIB_PATH)/version.h; then \

Quoted 25 lines
lib/Android.mk +6 -1
+               mv $(IGT_LIB_PATH)/version.h.tmp $(IGT_LIB_PATH)/version.h ; \
+       else \
+               rm $(IGT_LIB_PATH)/version.h.tmp ; \
+       fi
+
+
 include $(BUILD_STATIC_LIBRARY)
 
--

1.9.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.