From patchwork Fri Apr 13 22:19:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 152437 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1CC61B700B for ; Sat, 14 Apr 2012 08:53:14 +1000 (EST) Received: from localhost ([::1]:38684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIpMd-0005ft-II for incoming@patchwork.ozlabs.org; Fri, 13 Apr 2012 18:53:11 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIpM8-0004I6-31 for qemu-devel@nongnu.org; Fri, 13 Apr 2012 18:52:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SIpM5-00047a-Dc for qemu-devel@nongnu.org; Fri, 13 Apr 2012 18:52:39 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:56159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIpM5-000477-2q for qemu-devel@nongnu.org; Fri, 13 Apr 2012 18:52:37 -0400 Received: from gw.ac.upc.edu (gw.ac.upc.es [147.83.30.3]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id q3DMJ84E028045; Sat, 14 Apr 2012 00:19:08 +0200 Received: from localhost (unknown [84.88.53.92]) by gw.ac.upc.edu (Postfix) with ESMTP id 3F58D2D0024; Sat, 14 Apr 2012 00:19:08 +0200 (CEST) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Sat, 14 Apr 2012 00:19:08 +0200 Message-Id: <20120413221908.1079.50464.stgit@ginnungagap.bsc.es> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <20120413221856.1079.6193.stgit@ginnungagap.bsc.es> References: <20120413221856.1079.6193.stgit@ginnungagap.bsc.es> User-Agent: StGit/0.16 MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id q3DMJ84E028045 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 147.83.33.10 Cc: stefanha@gmail.com Subject: [Qemu-devel] [PATCH 2/2] [trivial] Simpler handling of tracetool-generated files in makefiles X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Adds 'tracetool-gen' to generate files with tracetool into a temporary file, and 'tracetool-ci' to "commit" the generation from the temporaty file into the actual destination file if there were any changes in the produced file. Signed-off-by: LluĂ­s Vilanova --- Makefile.objs | 19 +++++++++---------- rules.mak | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Makefile.objs b/Makefile.objs index 6d6f24d..b98e905 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -373,18 +373,17 @@ libdis-$(CONFIG_LM32_DIS) += lm32-dis.o # trace ifeq ($(TRACE_BACKEND),dtrace) -trace.h: trace.h-timestamp trace-dtrace.h -else -trace.h: trace.h-timestamp +TRACE_H_EXTRA_DEPS=trace-dtrace.h endif +trace.h: trace.h-timestamp $(TRACE_H_EXTRA_DEPS) trace.h-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/tracetool.py --format=h --backend=$(TRACE_BACKEND) < $< > $@," GEN trace.h") - @cmp -s $@ trace.h || cp $@ trace.h + $(call tracetool-gen,h,$(TRACE_BACKEND)) + $(call tracetool-ci) trace.c: trace.c-timestamp trace.c-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/tracetool.py --format=c --backend=$(TRACE_BACKEND) < $< > $@," GEN trace.c") - @cmp -s $@ trace.c || cp $@ trace.c + $(call tracetool-gen,c,$(TRACE_BACKEND)) + $(call tracetool-ci) trace.o: trace.c $(GENERATED_HEADERS) @@ -396,11 +395,11 @@ trace-dtrace.h: trace-dtrace.dtrace # rule file. So we use '.dtrace' instead trace-dtrace.dtrace: trace-dtrace.dtrace-timestamp trace-dtrace.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/tracetool.py --format=d --backend=$(TRACE_BACKEND) < $< > $@," GEN trace-dtrace.dtrace") - @cmp -s $@ trace-dtrace.dtrace || cp $@ trace-dtrace.dtrace + $(call tracetool-gen,d,$(TRACE_BACKEND)) + $(call tracetool-ci) trace-dtrace.o: trace-dtrace.dtrace $(GENERATED_HEADERS) - $(call quiet-command,dtrace -o $@ -G -s $<, " GEN trace-dtrace.o") + $(call quiet-command,dtrace -o $@ -G -s $<, " GEN trace-dtrace.o") ifeq ($(LIBTOOL),) trace-dtrace.lo: trace-dtrace.dtrace diff --git a/rules.mak b/rules.mak index c30093c..2cbceab 100644 --- a/rules.mak +++ b/rules.mak @@ -59,6 +59,23 @@ find-in-path = $(if $(find-string /, $1), \ $(wildcard $1), \ $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH))))) +# Generate files with tracetool + +TRACETOOL=$(SRC_PATH)/scripts/tracetool.py + +# Generate a file with tracetool. +# Assumes: +# * $@ : ends with "-timestamp" +# * $< : is the "trace-events" file +# Takes: +# * 1 : format +# * 2 : backend +# * 1 : extra tracetool arguments (optional) +tracetool-gen=$(call quiet-command,$(PYTHON) $(TRACETOOL) $(3) --format=$(1) --backend=$(2) < $< > $@," GEN $(subst -timestamp,,$@)") + +# "Commits" the file generated by tracetool with 'tracetool-gen' +tracetool-ci=@cmp -s $@ $(subst -timestamp,,$@) || cp $@ $(subst -timestamp,,$@) + # Generate timestamp files for .h include files %.h: %.h-timestamp