From patchwork Mon Oct 31 22:28:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13026429 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F14FFA3744 for ; Mon, 31 Oct 2022 22:28:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230024AbiJaW2r (ORCPT ); Mon, 31 Oct 2022 18:28:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbiJaW2l (ORCPT ); Mon, 31 Oct 2022 18:28:41 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 768701038 for ; Mon, 31 Oct 2022 15:28:40 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id ud5so32990940ejc.4 for ; Mon, 31 Oct 2022 15:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SE9K1apIxuPKquinciAjWSnjiKcu3E01uUAQ91GKJ4A=; b=kMgh32jFJ/u6dhCR0695VCLyhT1fHo9DZh7QvJlI7L4/sR+YVdyT6rWvKMrZqj2qJ6 f1SK53YNMlE3X+8H1LtJS5SI838MNl08LxDJ8K2rpcc3qy4qURIu/fn/qd+FEyiJuCIX H5k6635dz45gQyVGr25uxgmVSWaqd/W39avHSsK32+vFVS5XY0mGhfmp8kSDchG+dMJO CZ/UrLMtrlpj5h0ncASaJyA4EnlIECn8AKOj3m3/vWLyVRQ2/F8qZjHfMHwbEUHMH/PJ hzLuVy8VXj0/Md58+qIX86Ph5jp6ktjGdGA/EdQV5C4bhsbCReZCT3huYCQTu4UJwf8q vKjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SE9K1apIxuPKquinciAjWSnjiKcu3E01uUAQ91GKJ4A=; b=54BgrJ8KJFw5X3qxaaW8+KNJecfrXNTpa/MqNlNCRcNeuNvMK5VAfCsYXC2hDqObkF fb8ZvaTaYakEUPWymHiukolBqZv0+FcBlEqgfKwqbt8a2TuEIC+Y+cuV/1fXlZSvXNPk gEO64SHdnp0nZcwTCAdcc/uBl1Ig/QFOhJK2czP1aQ3RR9zqNWqPuxG+AWBtklLrv6DQ K2TsFeormL+7+v6h0B/ZvBS99HCu7TgtQGNvRaZu6NZ984IcRAxoA5Ir/qGx8ElaUGl3 SgzrHGOUpy3OHSsxGFS66UbdFR5ER24tmIKDIfEzuLKT+1TzC2fdbRV/n34WsjwAfFod gjsQ== X-Gm-Message-State: ACrzQf3g/A/hf+R9c3n0VIX2brd2MmX5sSnAfNNhWLBXqpEb+McCRGXh k4Mt6bSmyk5nqp798SnYLF7E58Z59c5REA== X-Google-Smtp-Source: AMsMyM7azrMBWkka4wZQlEK+qKkhdozGdzUeVDIuljDE726m98i6zFEDkGuRhWsKZ21Xwi1L1Bl4Fg== X-Received: by 2002:a17:907:980e:b0:78d:b6d8:f53c with SMTP id ji14-20020a170907980e00b0078db6d8f53cmr15400224ejc.70.1667255318711; Mon, 31 Oct 2022 15:28:38 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a14-20020a1709066d4e00b00781e7d364ebsm3503668ejt.144.2022.10.31.15.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 15:28:37 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Victoria Dye , Derrick Stolee , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 1/4] Makefile: factor sed-powered '#!/bin/sh' munging into a variable Date: Mon, 31 Oct 2022 23:28:06 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1280.g8136eb6fab2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Reduce the amount of magical copy/pasting in the Makefile by factoring the munging of "#!/bin/sh" on the first line of a shellscript into a variable we can re-use in the various rules that need to do so. Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 4927379184c..679c24377f4 100644 --- a/Makefile +++ b/Makefile @@ -2347,8 +2347,12 @@ GIT-SCRIPT-DEFINES: FORCE echo "$$FLAGS" >$@; \ fi +define cmd_munge_script_sed_shell_path_arg +'1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' +endef + define cmd_munge_script -sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ +sed -e $(call cmd_munge_script_sed_shell_path_arg) \ -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \ -e 's|@@DIFF@@|$(DIFF_SQ)|' \ -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \ @@ -2450,7 +2454,7 @@ git-instaweb: git-instaweb.sh GIT-SCRIPT-DEFINES else # NO_PERL $(SCRIPT_PERL_GEN) git-instaweb: % : unimplemented.sh $(QUIET_GEN) \ - sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ + sed -e $(call cmd_munge_script_sed_shell_path_arg) \ -e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \ unimplemented.sh >$@+ && \ chmod +x $@+ && \ @@ -2471,7 +2475,7 @@ $(SCRIPT_PYTHON_GEN): % : %.py else # NO_PYTHON $(SCRIPT_PYTHON_GEN): % : unimplemented.sh $(QUIET_GEN) \ - sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ + sed -e $(call cmd_munge_script_sed_shell_path_arg) \ -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \ unimplemented.sh >$@+ && \ chmod +x $@+ && \ @@ -3065,7 +3069,7 @@ all:: $(TEST_PROGRAMS) $(test_bindir_programs) bin-wrappers/%: wrap-for-bin.sh $(call mkdir_p_parent_template) - $(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ + $(QUIET_GEN)sed -e $(call cmd_munge_script_sed_shell_path_arg) \ -e 's|@@BUILD_DIR@@|$(shell pwd)|' \ -e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \ chmod +x $@ From patchwork Mon Oct 31 22:28:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13026431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C50D8FA3744 for ; Mon, 31 Oct 2022 22:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229756AbiJaW2v (ORCPT ); Mon, 31 Oct 2022 18:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbiJaW2n (ORCPT ); Mon, 31 Oct 2022 18:28:43 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A8D51088 for ; Mon, 31 Oct 2022 15:28:41 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id f5so11418703ejc.5 for ; Mon, 31 Oct 2022 15:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VXcGFeeALGqfOQbBxQbL1ElWCEfY5nfsUVD0emqRqZI=; b=EhYkt/kTc06sP5kzvAPpuex69m7GxKGtml4phk3qRt2UXtouawFts8aqNMpv3zldHB R+w4Yy0WQEUMd/cH1FyNkPSPmRxRrvJAUMoxwrP+N0F4ToG8dsdhevS/W/+C5CfNndwS CwnmpQbSqKiCwx2+2hESm0ALbDmN5K3RpqzQfpD+4gqnS5GwCMRDI5AAcCT4RP+GEvNX Yhi7On5M0JVqo0EyMUmaI4GMPc6KREVLxbN1UCfNiWNxfBWbBTjvZ/cgYLMsQyaVrvZS 3fxtdcleERgoR3tq4X4nF5cAS3T6L75wFwPQ7YQPwAJUafhQz2zu19+807ntZdrebsTX 3UYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VXcGFeeALGqfOQbBxQbL1ElWCEfY5nfsUVD0emqRqZI=; b=zVB3w42O3NgM2EWyYn2nWvixGdp6sy7gyqdLR10YXz91BKfD+vcvmL+2qKgjGiAMTJ bSSjPXxI6Lx/Bj+P65jT0s+ELvRm7iXqKygJCMDhMCmIqo+pdZ7Q/6Sewl85mI8r+0CL /l3uLwAcbxexhh8nSKVdq/0oXjGu0jlnxQCwo2EJAwvNXlxOGg2TvUNr+HDDQ/YPm8cs Od0oTuIyHLZSwWfToj2lTNcRmQr/lcihhkcYg4tK/8avQSn4jewYw9r05LvcFSrHgIvM Z6zMfJ/DyZxEMs/1dt+rhsHgxBMaXMsQkPvwDuMDZD4JVJBeCdtW/99nm8PgA3FYDdyM FFOQ== X-Gm-Message-State: ACrzQf35ZH3dlAoRqvE0vdvagSEV/MN7zJUP4Jc5fAZTiMvfZcPDYO0x p9/jo54WE4uumWpQdinWl/21S3eGCuNjcg== X-Google-Smtp-Source: AMsMyM43YjYBS1p581tgSK7aPQVJ7mvDT1oZ0+eUyxZQlf9+9uQ6Qg3eZ0foNU1ZPc/kKyZ9vizf7w== X-Received: by 2002:a17:907:72d3:b0:791:a4fa:c4ac with SMTP id du19-20020a17090772d300b00791a4fac4acmr15242593ejc.391.1667255319693; Mon, 31 Oct 2022 15:28:39 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a14-20020a1709066d4e00b00781e7d364ebsm3503668ejt.144.2022.10.31.15.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 15:28:39 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Victoria Dye , Derrick Stolee , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 2/4] Makefile: define "TEST_{PROGRAM,OBJS}" variables earlier Date: Mon, 31 Oct 2022 23:28:07 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1280.g8136eb6fab2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Define the variables that make up TEST_OBJS earlier, and don't go back & forth in their definition. Before we'd first append $X to $(TEST_PROGRAMS), and then substitute $X back out of it to define $(TEST_OBJS). Let's instead add a new $(TEST_PROGRAM_OBJS) variable, which avoids this needless back & forth substitution. See daa99a91729 (Makefile: make sure test helpers are rebuilt when headers change, 2010-01-26) for how we ended up with the original $(TEST_OBJS). Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 679c24377f4..911cce6d487 100644 --- a/Makefile +++ b/Makefile @@ -617,7 +617,8 @@ SCRIPT_PYTHON = SCRIPT_SH = SCRIPT_LIB = TEST_BUILTINS_OBJS = -TEST_OBJS = +TEST_PROGRAMS = +TEST_PROGRAM_OBJS = TEST_PROGRAMS_NEED_X = THIRD_PARTY_SOURCES = @@ -796,6 +797,7 @@ TEST_BUILTINS_OBJS += test-wildmatch.o TEST_BUILTINS_OBJS += test-windows-named-pipe.o TEST_BUILTINS_OBJS += test-write-cache.o TEST_BUILTINS_OBJS += test-xml-encode.o +TEST_PROGRAM_OBJS += $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) # Do not add more tests here unless they have extra dependencies. Add # them in TEST_BUILTINS_OBJS above. @@ -803,6 +805,9 @@ TEST_PROGRAMS_NEED_X += test-fake-ssh TEST_PROGRAMS_NEED_X += test-tool TEST_PROGRAMS = $(patsubst %,t/helper/%$X,$(TEST_PROGRAMS_NEED_X)) +all:: $(TEST_PROGRAMS) +TEST_PROGRAM_OBJS += $(patsubst %,t/helper/%.o,$(TEST_PROGRAMS_NEED_X)) +.PRECIOUS: $(TEST_PROGRAM_OBJS) # List built-in command $C whose implementation cmd_$C() is not in # builtin/$C.o but is linked in as part of some other command. @@ -2546,10 +2551,8 @@ REFTABLE_TEST_OBJS += reftable/stack_test.o REFTABLE_TEST_OBJS += reftable/test_framework.o REFTABLE_TEST_OBJS += reftable/tree_test.o -TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) - .PHONY: test-objs -test-objs: $(TEST_OBJS) +test-objs: $(TEST_PROGRAM_OBJS) GIT_OBJS += $(LIB_OBJS) GIT_OBJS += $(BUILTIN_OBJS) @@ -2565,7 +2568,7 @@ scalar-objs: $(SCALAR_OBJS) OBJECTS += $(GIT_OBJS) OBJECTS += $(SCALAR_OBJS) OBJECTS += $(PROGRAM_OBJS) -OBJECTS += $(TEST_OBJS) +OBJECTS += $(TEST_PROGRAM_OBJS) OBJECTS += $(XDIFF_OBJS) OBJECTS += $(FUZZ_OBJS) OBJECTS += $(REFTABLE_OBJS) $(REFTABLE_TEST_OBJS) @@ -3065,7 +3068,7 @@ endif test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X)) -all:: $(TEST_PROGRAMS) $(test_bindir_programs) +all:: $(test_bindir_programs) bin-wrappers/%: wrap-for-bin.sh $(call mkdir_p_parent_template) @@ -3091,8 +3094,6 @@ perf: all .PHONY: test perf -.PRECIOUS: $(TEST_OBJS) - t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS)) t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS) $(REFTABLE_TEST_LIB) From patchwork Mon Oct 31 22:28:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13026430 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E01DECAAA1 for ; Mon, 31 Oct 2022 22:28:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbiJaW2t (ORCPT ); Mon, 31 Oct 2022 18:28:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230000AbiJaW2n (ORCPT ); Mon, 31 Oct 2022 18:28:43 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BED51093 for ; Mon, 31 Oct 2022 15:28:42 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id f7so13763812edc.6 for ; Mon, 31 Oct 2022 15:28:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fp8LNHtK6ECRC+itXEipWDjDGnB6C5m4j2BS6dEmZLQ=; b=g54EX7rbUZY/PMze3XOF6bBHXQkMKOBwEzaxyJEe5cc82dh9llnUfuPbJWvGCuX1aH Mq4puPle/S7sDXcPdQdteleZqzYEX9p4nhxk/iCaCrC8NL0voDAUJlaqib4jLFdW971a 777DhQG/cHG9ypfiKWD0zbT4BgJ/Fd4ZS0Cv63YRrrdFOIPU8E2ZMQT+0xmMsknFeJ90 3A9jdL7IpjXJrrV5ZDnVm1VAS7aKN1MeOeE2HRcmLQEELkbfivvCzpUgJAgA8/TFFFGf PUdMRLwepMSNWRfsPhfoS3xHGgk0CPu1Lk8Pu4KhbLzoC9Zj8r2ba4AQmwSxVt0knuuz w6hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fp8LNHtK6ECRC+itXEipWDjDGnB6C5m4j2BS6dEmZLQ=; b=O7KBDFQYh5Vgt/gIVfThJD8kasgfPVW8MEm659fg84yrJvT6EJM6klC50TSMiuYS3/ H4LCARKltn6u36nBAjGItupv0rcih3WdpJoQ8V6Tfs52uw2bRUbCk+TgB/WI2ubbPtqk f0G+8Kx/yk2Yn4/xCg36e2o3cRNj2VvhHwwYkRhZLXlUCMr5bynDEcX3C26qrL1A9kDr V7mtnD6NczkQdM22CcG0chFBiJGxAwpeS9J6jGMSLipPOJa+IdKxX4MW9XQFBMbRO9IU dk4mN/MaL/3ipShry+0TJUZIHE5aRGAi3fUDGAkrmr7X0IFzs6bo+vamU35gFRvEHVbx o5ZA== X-Gm-Message-State: ACrzQf1KWfwQXXdIyCUzbV25pnlWeKN+eRo7/AD2k9P2yK6A9LHdh2JA OOUpRTCgu6obLdLEeC1bgYuFGsH9uUOQ+Q== X-Google-Smtp-Source: AMsMyM7ElGhogoAcmY5FNswYXgNv/yRSSNjWpPPvLqDppjT+5+heXGpp0vVuF+AypM6Yer39BgAHTw== X-Received: by 2002:a05:6402:26ca:b0:462:7f27:a0dd with SMTP id x10-20020a05640226ca00b004627f27a0ddmr15871629edd.132.1667255320732; Mon, 31 Oct 2022 15:28:40 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a14-20020a1709066d4e00b00781e7d364ebsm3503668ejt.144.2022.10.31.15.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 15:28:39 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Victoria Dye , Derrick Stolee , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 3/4] Makefile: rename "test_bindir_programs" variable, pre-declare Date: Mon, 31 Oct 2022 23:28:08 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1280.g8136eb6fab2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Pre-declare the "BIN-WRAPPERS" variable, renamed from "test_bindir_programs", which is more in line with our usual naming conventions in the Makefile. There's also no reason to use a "simply expanded variable" here, so let's use a normal "=" assignment. It doesn't make a difference in the end as we're about to use to to define a rule, so it'll have "IMMEDIATE" expansion here. See ea925196f1b (build dashless "bin-wrappers" directory similar to installed bindir, 2009-12-02) for the introduction of "test_bindir_programs". Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 911cce6d487..032654640c5 100644 --- a/Makefile +++ b/Makefile @@ -595,6 +595,7 @@ export TCL_PATH TCLTK_PATH PTHREAD_LIBS = -lpthread # Guard against environment variables +BIN_WRAPPERS = BUILTIN_OBJS = BUILT_INS = COMPAT_CFLAGS = @@ -3066,9 +3067,9 @@ GIT-PYTHON-VARS: FORCE fi endif -test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X)) +BIN_WRAPPERS = $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X)) -all:: $(test_bindir_programs) +all:: $(BIN_WRAPPERS) bin-wrappers/%: wrap-for-bin.sh $(call mkdir_p_parent_template) @@ -3408,7 +3409,7 @@ OTHER_PROGRAMS += $(shell echo *.dll t/helper/*.dll) endif artifacts-tar:: $(ALL_COMMANDS_TO_INSTALL) $(SCRIPT_LIB) $(OTHER_PROGRAMS) \ - GIT-BUILD-OPTIONS $(TEST_PROGRAMS) $(test_bindir_programs) \ + GIT-BUILD-OPTIONS $(TEST_PROGRAMS) $(BIN_WRAPPERS) \ $(MOFILES) $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) \ SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)' From patchwork Mon Oct 31 22:28:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 13026432 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42FF9FA3741 for ; Mon, 31 Oct 2022 22:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230039AbiJaW2w (ORCPT ); Mon, 31 Oct 2022 18:28:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbiJaW2o (ORCPT ); Mon, 31 Oct 2022 18:28:44 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79EA21094 for ; Mon, 31 Oct 2022 15:28:43 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id y14so32960402ejd.9 for ; Mon, 31 Oct 2022 15:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VRZbMWIeG0ZQd7cP5Bk/J3hFHudDvHnhwDyVqoFTsnc=; b=qKMOLnQOYi/l3Zo12RBQKsaZWdgiyQgdPjpsXUt5eNee53u9OUm7NW4+G+xEOJZVPa eiWIQN3GYqUj2EankUKE2o+YSfGjU5QGyR1r8ogMxVY914bzJfvAW3iwwX3AapB2meR+ o57p0BBlONvpnCgLPDrfusd9cmYWRQtQXO4zqugry/sozvkI7sLCY/ulTL9Z9A4QW0OI LGPgTdFrlIlAaiHKRuw5CFBjw0ZpFeqmk6zxctrpeTvwJH/Gwd/JHWD5DYSyrWnPYlMB w5epb3HMIg+bWYPeuQByQsTXTZnknvKUQ9hq4ckQJtlghtTa888r1SfW674tCbLMl+Ec 0BvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VRZbMWIeG0ZQd7cP5Bk/J3hFHudDvHnhwDyVqoFTsnc=; b=1oQz4Lqf6VlU3Zj8O2rIK3DCdO2Gl+QLbWgeOMt++KSQvhlTapJFc79QPKrEeqtlVe 5J5Ebnh7/BRirYHDbZ45ho9Ja4xtI+a/rEykDpTjr8aYYjAnJHtclc8Z5+Cw3F1uSHKg sya82DgHLjp0qVzwbHsgpICX6xOAJte2lN9eBBP2Xkd2ZUmpCXpK8Zzkgxawe1sELapp qJsY9lwNeZGsuzwz+C0V6KRYwaxCjNVYsGG9tU7zUQZibGCIQkLLBjOdAbVbvSnnjp94 n0aoFwZSYTGVkdYJoXKy/vQliiqA2/5ObN9Wbfrwh5+dXSGrl/zFekoNSFOCTRRjX3Kz hv+A== X-Gm-Message-State: ACrzQf3UDWhI1E/xa/+jnAidd+o5yB7mHRrJK07DdrYJiyN7jHR05WSz xhQok/obgJTYIKdm1Jv26eoxSJw84iKrGg== X-Google-Smtp-Source: AMsMyM7bSQn3Fvfdz53Sdu84Pz8i0ywDsBf7be4MZqLVdX5aWyqwePssxG5T5KBMnB54LEQbXU31uw== X-Received: by 2002:a17:906:a4a:b0:782:686d:a1b6 with SMTP id x10-20020a1709060a4a00b00782686da1b6mr15260715ejf.232.1667255321605; Mon, 31 Oct 2022 15:28:41 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id a14-20020a1709066d4e00b00781e7d364ebsm3503668ejt.144.2022.10.31.15.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 15:28:40 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Victoria Dye , Derrick Stolee , Taylor Blau , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFz?= =?utf-8?b?b24=?= Subject: [PATCH v3 4/4] Makefile: simplify $(test_bindir_programs) rule by splitting it up Date: Mon, 31 Oct 2022 23:28:09 +0100 Message-Id: X-Mailer: git-send-email 2.38.0.1280.g8136eb6fab2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When the @@PROG@@ substitution was added in [1] it was a simple matter of doing a: 's|@@PROG@@|$(@F)|' Then when t/helpers were added in [2] followed by the ".exe" needing to be appended in [3] this previously simple rule ended up as a dense one-liner. It has been pointed out that this is hard to read[4], but the problem isn't the "design of the Makefile syntax". It's we now have to after-the-fact determine if we were dealing with a bin-wrapper/ that needed to have $(X) appended, a t/helper/, or a non-binary (currently only git-cvsserver). That would be a problem in any language. We're starting out with three lists, and then end up having to heuristically determine given a member of any of those lists which list that member came from. Let's just stop doing that and keep track of what member belongs to which list. We can do this by splitting up the single "bin-wrappers/%" rule into a rule for each of the three lists. With the "cmd_munge_script_sed_shell_path_arg" define added in a preceding commit this is easy, we just need to add a sister template to the existing "cmd_munge_script" added in [5]. The "filter-out" added in [6] has now become unnecessary per the above, it was an artifact of us losing track of what was in which of our lists to begin with. This change can be tested with e.g.: git checkout master && make SHELL_PATH=/bin/bash X=.exe && mv bin-wrappers bin-wrappers.master && && make SHELL_PATH=/bin/bash X=.exe && diff -ru bin-wrappers{.master,} Which will show an empty diff, i.e. we've correctly dealt with the combination of $(SHELL_PATH), $(X) and these three variables here. This also fixes an issue with the "bin-wrappers/" scripts have never had properly declared dependency information, i.e. this has never worked: make clean && make bin-wrappers/git && # the script is there, but no "./git" is built ./bin-wrappers/git There was no reason not to have that work, just as most things generated by the Makefile have proper dependency information. Before this commit doing this would have been painful, but now it's easy to pass this as a parameter to our "bin_wrappers_template" 1. ea925196f1b (build dashless "bin-wrappers" directory similar to installed bindir, 2009-12-02) 2. e6e7530d10b (test helpers: move test-* to t/helper/ subdirectory, 2016-04-13) 3. 3a94cb31d52 (bin-wrappers: append `.exe` to target paths if necessary, 2019-07-29) 4. https://lore.kernel.org/git/sso99so6-n28s-rq86-8q20-4456r3pn869r@tzk.qr/ 5. 46bac904581 (Do not install shell libraries executable, 2010-01-31) 6. 7b5c93c6c68" (scalar: include in standard Git build & installation, 2022-09-02) Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 032654640c5..d7ab68e3db8 100644 --- a/Makefile +++ b/Makefile @@ -3067,16 +3067,42 @@ GIT-PYTHON-VARS: FORCE fi endif -BIN_WRAPPERS = $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X)) +define cmd_munge_bin_wrappers_script +sed \ + -e $(call cmd_munge_script_sed_shell_path_arg) \ + -e 's|@@BUILD_DIR@@|$(shell pwd)|' \ + -e 's|@@PROG@@|$(2)$(1)$(3)|' \ + <$< >$@ && \ + chmod +x $@ +endef -all:: $(BIN_WRAPPERS) +define bin_wrappers_template + +### bin_wrappers_template; Parameters: +## E.g. "BINDIR_PROGRAMS_NEED_X": Variable reference +# 1='$(1)' +## E.g. "$(@F)": Passed as $$(1)) to "cmd_munge_bin_wrappers_script" +# 2='$(2)' +## E.g. "" or "t/helper": Directory prefix for the wrapped binary +# 3='$(3)' +## E.g. "" or "$$X": If $$X: wrapped binary needs X=.exe (for Windows) +# 4='$(4)' +BW_$(1) = $$($(1):%=bin-wrappers/%) +BIN_WRAPPERS += $$(BW_$(1)) +$$(BW_$(1)): bin-wrappers/% : $(3)%$(4) +$$(BW_$(1)): wrap-for-bin.sh + $$(call mkdir_p_parent_template) + $$(QUIET_GEN)$$(call cmd_munge_bin_wrappers_script,$(2),$(3),$(4)) +endef -bin-wrappers/%: wrap-for-bin.sh - $(call mkdir_p_parent_template) - $(QUIET_GEN)sed -e $(call cmd_munge_script_sed_shell_path_arg) \ - -e 's|@@BUILD_DIR@@|$(shell pwd)|' \ - -e 's|@@PROG@@|$(patsubst test-%,t/helper/test-%,$(@F))$(if $(filter-out $(BINDIR_PROGRAMS_NO_X),$(@F)),$(X),)|' < $< > $@ && \ - chmod +x $@ +define bin_wrappers_templates +$(call bin_wrappers_template,BINDIR_PROGRAMS_NEED_X,'$$(@F)',,$$X) +$(call bin_wrappers_template,BINDIR_PROGRAMS_NO_X,'$$(@F)') +$(call bin_wrappers_template,TEST_PROGRAMS_NEED_X,'$$(@F)',t/helper/,$$X) +endef +$(eval $(call bin_wrappers_templates)) + +all:: $(BIN_WRAPPERS) # GNU make supports exporting all variables by "export" without parameters. # However, the environment gets quite big, and some programs have problems