From patchwork Fri Mar 4 05:40:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 8498711 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 91F12C0553 for ; Fri, 4 Mar 2016 05:58:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C46FE201EC for ; Fri, 4 Mar 2016 05:58:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DCFEE201CE for ; Fri, 4 Mar 2016 05:58:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751114AbcCDF5W (ORCPT ); Fri, 4 Mar 2016 00:57:22 -0500 Received: from alt22.smtp-out.videotron.ca ([70.80.0.73]:50494 "EHLO alt22.smtp-out.videotron.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751088AbcCDFz5 (ORCPT ); Fri, 4 Mar 2016 00:55:57 -0500 Received: from yoda.home ([96.23.157.65]) by Videotron with SMTP id biZ7ahUuhg8R4biZ8aEpfS; Fri, 04 Mar 2016 00:46:18 -0500 X-Authority-Analysis: v=2.1 cv=b8ISmoyx c=1 sm=1 tr=0 a=keA3yYpnlypCNW5BNWqu+w==:117 a=keA3yYpnlypCNW5BNWqu+w==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=7OsogOcEt9IA:10 a=KKAkSRfTAAAA:8 a=DR8aRbLO010_Rlgsu9YA:9 Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 6EFBA2DA05EA; Fri, 4 Mar 2016 00:40:54 -0500 (EST) From: Nicolas Pitre To: Michal Marek Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/8] fixdep: accept extra dependencies on stdin Date: Fri, 4 Mar 2016 00:40:45 -0500 Message-Id: <1457070050-1564-4-git-send-email-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1457070050-1564-1-git-send-email-nicolas.pitre@linaro.org> References: <1457070050-1564-1-git-send-email-nicolas.pitre@linaro.org> X-CMAE-Envelope: MS4wfL7wpRjI8PIXvkWJ3AC7eDIDkVZF0KeKtbZ+KKiS/ezxCx1QKUt0cfTPA2hCLGM7GomLofUayy+FZz2IxhTR9DSXF0Sv78KiaMZx8deioq1xLrSNqnXQ dCZv6hL7c0I/KdSTwT8v7ICJimTwty7FLvSQvqH08gdbD/uElSDznxX+yME6LKq2CTkTzMfpBMxMLIxbJrdAJxxqRhs2u4fLPfXPaw01l1GmYJiVn7t7DJ5K ZeATrTmpk4H61W2Bt+FMog== Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ... and merge them in the list of parsed dependencies. Signed-off-by: Nicolas Pitre --- scripts/basic/fixdep.c | 60 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 15 deletions(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 5b327c67a8..d984deb120 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -120,13 +120,15 @@ #define INT_NFIG ntohl(0x4e464947) #define INT_FIG_ ntohl(0x4649475f) +int insert_extra_deps; char *target; char *depfile; char *cmdline; static void usage(void) { - fprintf(stderr, "Usage: fixdep \n"); + fprintf(stderr, "Usage: fixdep [-e] \n"); + fprintf(stderr, " -e insert extra dependencies given on stdin\n"); exit(1); } @@ -138,6 +140,40 @@ static void print_cmdline(void) printf("cmd_%s := %s\n\n", target, cmdline); } +/* + * Print out a dependency path from a symbol name + */ +static void print_config(const char *m, int slen) +{ + int c, i; + + printf(" $(wildcard include/config/"); + for (i = 0; i < slen; i++) { + c = m[i]; + if (c == '_') + c = '/'; + else + c = tolower(c); + putchar(c); + } + printf(".h) \\\n"); +} + +static void do_extra_deps(void) +{ + if (insert_extra_deps) { + char buf[80]; + while(fgets(buf, sizeof(buf), stdin)) { + int len = strlen(buf); + if (len < 2 || buf[len-1] != '\n') { + fprintf(stderr, "fixdep: bad data on stdin\n"); + exit(1); + } + print_config(buf, len-1); + } + } +} + struct item { struct item *next; unsigned int len; @@ -197,23 +233,12 @@ static void define_config(const char *name, int len, unsigned int hash) static void use_config(const char *m, int slen) { unsigned int hash = strhash(m, slen); - int c, i; if (is_defined_config(m, slen, hash)) return; define_config(m, slen, hash); - - printf(" $(wildcard include/config/"); - for (i = 0; i < slen; i++) { - c = m[i]; - if (c == '_') - c = '/'; - else - c = tolower(c); - putchar(c); - } - printf(".h) \\\n"); + print_config(m, slen); } static void parse_config_file(const char *map, size_t len) @@ -250,7 +275,7 @@ static void parse_config_file(const char *map, size_t len) } } -/* test is s ends in sub */ +/* test if s ends in sub */ static int strrcmp(const char *s, const char *sub) { int slen = strlen(s); @@ -374,6 +399,8 @@ static void parse_dep_file(void *map, size_t len) exit(1); } + do_extra_deps(); + printf("\n%s: $(deps_%s)\n\n", target, target); printf("$(deps_%s):\n", target); } @@ -430,7 +457,10 @@ int main(int argc, char *argv[]) { traps(); - if (argc != 4) + if (argc == 5 && !strcmp(argv[1], "-e")) { + insert_extra_deps = 1; + argv++; + } else if (argc != 4) usage(); depfile = argv[1];