From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E746DA04DD; Tue, 21 Jan 2020 11:17:16 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2A99F2C6D; Tue, 21 Jan 2020 11:17:16 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 4B71A2BF5 for ; Tue, 21 Jan 2020 11:17:14 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Jan 2020 02:17:13 -0800 X-IronPort-AV: E=Sophos;i="5.70,345,1574150400"; d="scan'208";a="219910596" Received: from bricha3-mobl.ger.corp.intel.com ([10.237.221.97]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 21 Jan 2020 02:17:11 -0800 Date: Tue, 21 Jan 2020 10:17:09 +0000 From: Bruce Richardson To: Robin Jarry Cc: Thomas Monjalon , dev@dpdk.org Message-ID: <20200121101709.GB1747@bricha3-MOBL.ger.corp.intel.com> References: <20200120173725.57529-1-bruce.richardson@intel.com> <2317106.JBEolbzBkm@xps> <20200121091133.qfbdrlcnmbmzd7jq@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200121091133.qfbdrlcnmbmzd7jq@6wind.com> User-Agent: Mutt/1.12.1 (2019-06-15) Subject: Re: [dpdk-dev] [PATCH] build: allow using wildcards to disable drivers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Jan 21, 2020 at 10:11:33AM +0100, Robin Jarry wrote: > 2020-01-20, Bruce Richardson: > > Rather than having to explicitly list each and every driver to disable in a > > build, we can use a small python script and the python glob library to > > expand out the wildcards. This means that we can configure meson using e.g. > > > > meson -Ddisable_drivers=crypto/*,event/* build > > > > to do a build omitting all the crypto and event drivers. Explicitly > > specified drivers e.g. net/i40e, work as before, and can be mixed with > > wildcarded drivers as required. > > > > Signed-off-by: Bruce Richardson > > --- > [snip] > > +++ b/buildtools/list-dir-globs.sh > > @@ -0,0 +1,15 @@ > > +#! /usr/bin/env python > > +# SPDX-License-Identifier: BSD-3-Clause > > +# Copyright(c) 2020 Intel Corporation > > + > > +from __future__ import print_function > > +from os import chdir, environ > > +from sys import argv > > +from glob import iglob # glob iterator > > +from os.path import isdir, join > > + > > +chdir(join(environ['MESON_SOURCE_ROOT'], environ['MESON_SUBDIR'])) > > +dirs = [] > > +for path in argv[1].split(','): > > + dirs.extend([entry for entry in iglob(path) if isdir(entry)]) > > I do not fancy changing the current directory in scripts. This can lead > to unexpected behavior. You don't need to, you can achieve the same > result with the following code: First version indeed did not use chdir, but it seemed simpler to just chdir and work off that than try and get back to relative paths. However, I'll fix as you suggest below. > > from __future__ import print_function > import argparse > import os > import glob > > parser = argparse.ArgumentParser() > parser.add_argument('disable_drivers', type=lambda s: s.split(',')) > args = parser.parse_args() > root = os.path.join(os.environ['MESON_SOURCE_ROOT'], > os.environ['MESON_SUBDIR']) > dirs = [] > for driver in args.disable_drivers: > driver_path = os.path.join(root, driver) > for path in glob.iglob(driver_path): > if os.path.isdir(path): > dirs.append(os.path.relpath(path, root)) > print(','.join(dirs)) > > I did not see why you used iglob instead of glob. iglob is case > insensitive. Is that for windows support? No, iglob returns an iterator rather than a full list. It's just slightly more efficient if there are a large number of items. > > > +++ b/drivers/meson.build > > @@ -17,7 +17,8 @@ dpdk_driver_classes = ['common', > > 'event', # depends on common, bus, mempool and net. > > 'baseband'] # depends on common and bus. > > > > -disabled_drivers = get_option('disable_drivers').split(',') > > +disabled_drivers = run_command(list_dir_globs, get_option('disable_drivers'), > > + ).stdout().strip().split(',') > > Why adding commas again? Since you are processing the option value > through a script, you might as well print one folder per line and use > the .splitlines() meson function. It will make the code simpler as you > do not need to use an intermediate list to store the disabled drivers > before printing them. > Good point. Will update. /Bruce