From fdde825f9514c3411d4a6cec62c27a6172f6affc Mon Sep 17 00:00:00 2001 From: Ross Oldfield Date: Wed, 15 May 2013 12:57:31 +0100 Subject: Slight Android.mk improvements for generated files with some dependency tracking. Generates the JSON and dispatch files under /out rather than in tree. --- tests/util/Android.mk | 50 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/tests/util/Android.mk b/tests/util/Android.mk index 488325ae..2debdf46 100644 --- a/tests/util/Android.mk +++ b/tests/util/Android.mk @@ -10,6 +10,9 @@ piglit_patch_version := 0 LOCAL_MODULE := libpiglitutil_gles2 LOCAL_MODULE_TAG := eng +LOCAL_MODULE_CLASS := SHARED_LIBRARIES + +intermediates:= $(local-intermediates-dir) LOCAL_CFLAGS := -DPIGLIT_USE_WAFFLE \ -DPIGLIT_USE_OPENGL_ES2 \ @@ -22,14 +25,16 @@ LOCAL_C_INCLUDES := . \ $(piglit_top)/src \ $(piglit_top)/tests/util \ external/waffle/include/waffle \ + $(intermediates) + +# config.h is only used by piglit-util.h +# This is wrong in two ways: +# 1) still being generated in $(LOCAL_PATH) rather than $(intermediates) until I can fix up the dependencies for the user's #include +# 2) Can't use the target-specific late-evalutated variable style - my shell complains of missing quotes. -$(pigit_top)/tests/util/generated_dispatch.h: \ - $(piglit_top)/Android.mk \ - $(LOCAL_PATH)/config.h.in - @echo "target Generated dispatch tables" - python $(piglit_top)/glapi/parse_glspec.py $(piglit_top)/glapi/gl.tm $(piglit_top)/glapi/gl.spec $(piglit_top)/glapi/enumext.spec $(piglit_top)/glapi/glapi.json - python $(LOCAL_PATH)/gen_dispatch.py $(piglit_top)/glapi/glapi.json $(LOCAL_PATH)/generated_dispatch.c $(LOCAL_PATH)/generated_dispatch.h - @sed -e 's/#cmakedefine HAVE_STRCHRNUL/#define HAVE_STRCHRNUL/' \ +CONFIG_HEADER := $(LOCAL_PATH)/config.h +$(CONFIG_HEADER): $(LOCAL_PATH)/config.h.in + sed -e 's/#cmakedefine HAVE_STRCHRNUL/#define HAVE_STRCHRNUL/' \ -e 's/#cmakedefine HAVE_FOPEN_S//' \ -e 's/#cmakedefine HAVE_SETRLIMIT/#define HAVE_SETRLIMIT/' \ -e 's/#cmakedefine HAVE_FCNTL_H/#define HAVE_FCNTL_H/' \ @@ -37,9 +42,33 @@ $(pigit_top)/tests/util/generated_dispatch.h: \ -e 's/#cmakedefine HAVE_SYS_TYPES_H/#define HAVE_SYS_TYPES_H/' \ -e 's/#cmakedefine HAVE_SYS_TIME_H/#define HAVE_TIME_H/' \ -e 's/#cmakedefine HAVE_SYS_RESOURCE_H/#define HAVE_SYS_RESOURCE_H/' \ - -e 's/#cmakedefine HAVE_UNISTD_H/#define HAVE_UNISTD_H/' \ - $(LOCAL_PATH)/config.h.in \ - > $(LOCAL_PATH)/config.h + -e 's/#cmakedefine HAVE_UNISTD_H/#define HAVE_UNISTD_H/' $< > $@ + $(transform-generated-source) + +LOCAL_GENERATED_SOURCES += $(CONFIG_HEADER) + +# Use a pattern match rule to account for simulataneous .c and .h file creation +# Don't add the .c file to the generated sources list otherwise Android will also generate a .o rule for that as well +# Make the intermediates also depend on the scripts (so they get rebuilt is the .py files change as well) +# Ensure that the arguments for gen_dispatch are in the correct order (.c _then_ .h file) + +GEN_STUB := $(intermediates)/generated_dispatch +GEN_DISPATCH := $(intermediates)/%.h $(intermediates)/%.c + +GEN_JSON := $(GEN_STUB:%=%.json) +GEN_HEADER := $(GEN_STUB:%=%.h) + +$(GEN_JSON): PRIVATE_CUSTOM_TOOL = python $+ $@ +$(GEN_JSON): $(piglit_top)/glapi/parse_glspec.py $(piglit_top)/glapi/gl.tm $(piglit_top)/glapi/gl.spec $(piglit_top)/glapi/enumext.spec + $(transform-generated-source) + +$(GEN_DISPATCH): PRIVATE_CUSTOM_TOOL = python $+ $(addprefix $(GEN_STUB),.c .h) +$(GEN_DISPATCH): $(LOCAL_PATH)/gen_dispatch.py $(GEN_JSON) + $(transform-generated-source) + +LOCAL_GENERATED_SOURCES += $(GEN_JSON) $(GEN_HEADER) + + LOCAL_SRC_FILES := \ piglit-vbo.cpp \ @@ -91,7 +120,6 @@ LOCAL_COPY_HEADERS := \ piglit-framework-cl-program.h \ piglit-util-compressed-grays.h \ sized-internalformats.h \ - generated_dispatch.h \ LOCAL_COPY_HEADERS_TO := piglit-$(piglit_major_version) -- cgit v1.2.3