Received: by 10.213.65.68 with SMTP id h4csp1066808imn; Wed, 28 Mar 2018 19:44:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/SIySvOVzjkXFvm7oqk1/pEI7J32Oo8XWiJjTv5ZKPcPnsIx1MxYr6EQtVhjh3zJ6Nmzyg X-Received: by 10.99.145.193 with SMTP id l184mr4151306pge.394.1522291449570; Wed, 28 Mar 2018 19:44:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522291449; cv=none; d=google.com; s=arc-20160816; b=YLPA9TkoXiZl8sZSId+fvw9elhROP2iLPJyRDzJ/LFV5l4eRQvDVvK7G5nW4OpPNoE 8flDGJzm5/t39r0zucnR2FhR6UyEDR2uzTZv0ZnVhcU50h9RTPVI90IuUP9ODNXdcFyF aKjyQyykiAhsQ0xSEzKWPipVwq9rF1LqQ/pGOzvn+3oO5c4b7bJRTOLr9NWpOpC4Fe5f fx4Y3hsRkL8vNokQclfRYwREIB/ma6H+RW/IZYbaJJg3gPUcco9QiwzSYZN2OX16bPao t7o7sKXvWzizIqXFC0dC5DP1p5JzIWrkKSoeCS/HRHKvOkaTgNI44ZIwrmqAm3OlIleI kuig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=1qtvs/spKjdZyIHnqRMR0TbQlPPIlx4KyxUwXwcqHP0=; b=vlH2yi7GXZRT92Cu0oRMK7V/eDBVRqTqajPe6J2DkbR4EQCt/A3KMwryAADqrTdxlQ MB9eQk2k6NO8c2OEG9GogI8miWJcveW0uAs7YACSKiOZBUadAB34uPwDpZhwFNi0FW23 8BrYGXyGT4b2R7rhWah66izQmQMF2FeB2ygIlL/Hlwpl9ay3BmEm0UwSs6bt0l6Jtun4 CNzVlySUR+yLM+cUY0XD6w4IpnC+a7LA6z+OcsN6culkMwFU8s3QbnxN7dlQdBpvKEqH vISaUZDRgCeo6AWht8v6hNN3WGECzXsMl3mcJx30USZusQijUEiTjV05Ewzm6FS3yBfY 2HFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IOFgozOf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14si3637046pfn.313.2018.03.28.19.43.55; Wed, 28 Mar 2018 19:44:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IOFgozOf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751398AbeC2Cmp (ORCPT + 99 others); Wed, 28 Mar 2018 22:42:45 -0400 Received: from mail-vk0-f66.google.com ([209.85.213.66]:36945 "EHLO mail-vk0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751210AbeC2Cmn (ORCPT ); Wed, 28 Mar 2018 22:42:43 -0400 Received: by mail-vk0-f66.google.com with SMTP id u200so2595307vke.4; Wed, 28 Mar 2018 19:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=1qtvs/spKjdZyIHnqRMR0TbQlPPIlx4KyxUwXwcqHP0=; b=IOFgozOfaSxpVqOc99kCs0+Rogh+rRwCAR0B/jXPXORvoWupeI4xaNJzKEhug1Fyip ZCdGER7sAchdcGpIup5GvnW43SDNMFcyPFGynsXPDWGSL3fz2NqEqQMgB2b82N7ifpHY 4KJxTKp0u5teLW5MmORfP8boqgQoyzko5QSkuP/9SrBgnVIqXeGPr0dyu5yYup9QvLcl YNnX1C9azB50SrbruMu7kOIyaiWBwsyarWTtBUZXwqNNuGJ+Q8AVygwl67sUV4X2ZJSI NaN9H0C5+hjzokSw4qqQW+fS0UbAv3F+FAVBACn3H+gjivla8JWpxr86JJNqovuBluPC jreg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=1qtvs/spKjdZyIHnqRMR0TbQlPPIlx4KyxUwXwcqHP0=; b=PC4YWK2Mr23MznywJ0REXahvW1ToRnKSmt6TJW/QbEJVoT6Qpjy3g+Q/hj/CkSt/0O 3IGaD2sJq46flEddp/UxHPeGT5SJ9wmjmTASdAMi481nlVyEENQYSdyrAZZO2IJNojT4 BRYwErtJzolmDSfuuVWTzP+dR6bwr7oetXhPdGa3WpLu9y0i2aQ+75SXY5IcjZb5EvN6 RJ1MClFt0ncBwmXUhrkVYbVCRKVCiyuq1qwB+Sd89Cyj0aKjWK5SW9R0mbje2KqBIBpc zPXgL9J99yckQ9yP+ke6qlOZG1RqJhUty4qLQwLHn8mTEwkTE+pLSPBFUxhGURNYwDiL 8zeQ== X-Gm-Message-State: AElRT7F37W89a5icLK41IdqXE4n+C6ZGVyvdUMQVI6giI5jgzELw8Pkn 03hhlbRd/cShJ1SWEDgtGnXx/OKoMXJrtFO1P3U= X-Received: by 10.31.199.65 with SMTP id x62mr3974553vkf.189.1522291363114; Wed, 28 Mar 2018 19:42:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.206.5 with HTTP; Wed, 28 Mar 2018 19:42:42 -0700 (PDT) In-Reply-To: <1522128575-5326-8-git-send-email-yamada.masahiro@socionext.com> References: <1522128575-5326-1-git-send-email-yamada.masahiro@socionext.com> <1522128575-5326-8-git-send-email-yamada.masahiro@socionext.com> From: Ulf Magnusson Date: Thu, 29 Mar 2018 04:42:42 +0200 Message-ID: Subject: Re: [PATCH v2 07/21] kconfig: add function support and implement 'shell' function To: Masahiro Yamada Cc: Linux Kbuild mailing list , Sam Ravnborg , Linus Torvalds , Arnd Bergmann , Kees Cook , Thomas Gleixner , Greg Kroah-Hartman , Randy Dunlap , "Luis R . Rodriguez" , Nicolas Pitre , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 27, 2018 at 7:29 AM, Masahiro Yamada wrote: > This commit adds a new concept 'function' to do more text processing > in Kconfig. > > A function call looks like this: > > $(function arg1, arg2, arg3, ...) > > (Actually, this syntax was inspired by make.) > > Real examples will look like this: > > $(shell echo hello world) > $(cc-option -fstackprotector) > > This commit adds the basic infrastructure to add, delete, evaluate > functions, and also the first built-in function $(shell ...). This > accepts a single command to execute. It returns the standard output > from it. > > [Example code] > > config HELLO > string > default "$(shell echo hello world)" > > config Y > def_bool $(shell echo y) > > [Result] > > $ make -s alldefconfig && tail -n 2 .config > CONFIG_HELLO="hello world" > CONFIG_Y=y > > Caveat: > Like environments, functions are expanded in the lexer. You cannot > pass symbols to function arguments. This is a limitation to simplify > the implementation. I want to avoid the dynamic function evaluation, > which would introduce much more complexity. > > Signed-off-by: Masahiro Yamada > --- > > Reminder for myself: > Update Documentation/kbuild/kconfig-language.txt > > > Changes in v2: > - Use 'shell' for getting stdout from the comment. > It was 'shell-stdout' in the previous version. > - Symplify the implementation since the expansion has been moved to > lexer. > > scripts/kconfig/function.c | 170 ++++++++++++++++++++++++++++++++++++++++++++ > scripts/kconfig/lkc_proto.h | 5 ++ > scripts/kconfig/util.c | 46 +++++++++--- > scripts/kconfig/zconf.y | 9 +++ > 4 files changed, 222 insertions(+), 8 deletions(-) > create mode 100644 scripts/kconfig/function.c > The gotcha from 04/21 ("kconfig: reference environments directly and remove 'option env=' syntax") applies here too. For example, the following will work: config A bool "A" default $(shell echo "B && C") Some people might argue that that's a feature (I sense a mess down the road if people start depending on it), but just in case you hadn't thought of it. Similarly, the following will only work as expected if 'cmd' outputs the name of an undefined Kconfig symbol: config A string default $(shell cmd) You could argue that people should add quotes there though (though that's broken at the moment if the output from 'cmd' includes a quote). Quotes in Kconfig speak just mean "constant value". Problem is it's undocumented, and no one would intuitively expect it. Cheers, Ulf