From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7C3BD1F513 for ; Sun, 26 Nov 2023 02:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1700964666; bh=oB8N91EetAPZo8J+BEBQOKxgjd9YBfsUbqxaZN/EpSo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QVwTqwkYtLlaMicelkKmqiEMZ0xitES1+OHGTNj8I71YfG0AaIpxj1u7t0qR3of85 DuxBIwkFIDQ9RMKNUSc+b2WezkLWMoM1Z1JFUgvtgI3SBV1yhnm3L+busj+cc6zWD6 qZWZ9zup/NlkR996XUbsWQhEtgKXFuRGwve+WkZ4= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/7] xap_helper: allow PI_NO_CXX to disable C++ in more places Date: Sun, 26 Nov 2023 02:11:02 +0000 Message-ID: <20231126021105.408573-5-e@80x24.org> In-Reply-To: <20231126021105.408573-1-e@80x24.org> References: <20231126021105.408573-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This also reduces repetition in the setup code. --- lib/PublicInbox/XapClient.pm | 4 +--- lib/PublicInbox/XapHelperCxx.pm | 1 + t/xap_helper.t | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/PublicInbox/XapClient.pm b/lib/PublicInbox/XapClient.pm index 1f9ddccc..4dcbbe5d 100644 --- a/lib/PublicInbox/XapClient.pm +++ b/lib/PublicInbox/XapClient.pm @@ -28,12 +28,10 @@ sub mkreq { sub start_helper { my @argv = @_; socketpair(my $sock, my $in, AF_UNIX, SOCK_SEQPACKET, 0); - require PublicInbox::XapHelperCxx; my $cls = 'PublicInbox::XapHelperCxx'; my $env; - my $cmd = eval { PublicInbox::XapHelperCxx::cmd() }; + my $cmd = eval "require $cls; ${cls}::cmd()"; if ($@) { # fall back to Perl + XS|SWIG - require PublicInbox::XapHelper; $cls = 'PublicInbox::XapHelper'; # ensure the child process has the same @INC we do: $env = { PERL5LIB => join(':', @INC) }; diff --git a/lib/PublicInbox/XapHelperCxx.pm b/lib/PublicInbox/XapHelperCxx.pm index b1deb665..f421c7bc 100644 --- a/lib/PublicInbox/XapHelperCxx.pm +++ b/lib/PublicInbox/XapHelperCxx.pm @@ -110,6 +110,7 @@ sub check_build () { # returns spawn arg sub cmd { + die 'PI_NO_CXX set' if $ENV{PI_NO_CXX}; check_build(); my @cmd; if (my $v = $ENV{VALGRIND}) { diff --git a/t/xap_helper.t b/t/xap_helper.t index 02e5ec7d..e3abeded 100644 --- a/t/xap_helper.t +++ b/t/xap_helper.t @@ -149,7 +149,7 @@ unless ($ENV{TEST_XH_CXX_ONLY}) { SKIP: { require PublicInbox::XapHelperCxx; my $cmd = eval { PublicInbox::XapHelperCxx::cmd() }; - skip "XapHelperCxx build: $@", 1 if $@ || $ENV{PI_NO_CXX}; + skip "XapHelperCxx build: $@", 1 if $@; @NO_CXX = $ENV{TEST_XH_CXX_ONLY} ? (0) : (0, 1); my $ar = $test->(@$cmd, '-j0');