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 21EDEA04DD; Tue, 21 Jan 2020 14:22:42 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 788CCF90; Tue, 21 Jan 2020 14:22:41 +0100 (CET) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id EB93DF11 for ; Tue, 21 Jan 2020 14:22:39 +0100 (CET) Received: by mail-wr1-f67.google.com with SMTP id q10so3131306wrm.11 for ; Tue, 21 Jan 2020 05:22:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=VgfDfhKl3YIkxB4Ao8y3ZgseA9dy+v2ZgKXJmyQoo/o=; b=h0cURiMgIBiLj35DTA4yflYRvxnUL6JIByae36Ka1pVsqcDiMN508sCeR07eIzAwjX Gzk5RB7B1gDnrSo5eQEIW4qEF4tMxaka3CepB2vGndZgoLcyFDd4rk/4Y+awh6ldmGaZ IVvj5ZHYSqWZwXsQk7dDitiSBN9I77t3o2RubCxaE7BLGpAtzEm+b/smYMrsxybSudpW EGxFW75waZvcMRL5NZwxgimmWpDBTrZG2EjupHPNCEPhLavqRlDT+fVLDke2sGIRFpP3 wUOVvqbLerTuzdaErXkAuRQ1TcscCIQRik60tAWkTw85GvYeNwJyF/ZJZTJXKdE6ZLPJ PW8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=VgfDfhKl3YIkxB4Ao8y3ZgseA9dy+v2ZgKXJmyQoo/o=; b=b3wsoBxt+xLcb9lhGBFG7Df1fPqBOt2gAwYtnEHRYaxGcFKwsGaqtTEx14Dja5TqJ9 72CDb8WaXJ4Mg7t0+q/xKQfczamPQlPNOW9kteDNHN4u1Ct9dKoD3NryQ6vhvH42QQGz ZrJM66FxWNyL9CuCG0xkk/pnVmYJDH3UIbRGCWwXeb5+Bzrb13qFbXBWW6nOGQEnUjNw PFcJ8iiLWNMpDrd7Esw1KfuwXcjYeRUsS64Aezq61BnARTGsNpnuIGq7/9uLmVJ+JLeG Y1rcx4T4NGU8CvSRW9BCY7cUR8nJVSbADmWFVpms57e98sktKx7a7GTMDyAIEMYqWZOl cZng== X-Gm-Message-State: APjAAAURBceH3+zb+y4n7cp3oWzr2qRTaQ7lAMbnmvy/Zht+6MmSp6bF dKr285CvwUoiM/mcCo3xdY3U4yOial0= X-Google-Smtp-Source: APXvYqxzs4JTOdKtg9b0Pim4sr0aOcZ1Lpzt4p2uweO++KijlkkdrEgAL2ydTJg9S5Gd8OOjnirlbQ== X-Received: by 2002:a5d:50ce:: with SMTP id f14mr5522624wrt.254.1579612959488; Tue, 21 Jan 2020 05:22:39 -0800 (PST) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id k8sm51852757wrl.3.2020.01.21.05.22.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jan 2020 05:22:38 -0800 (PST) Date: Tue, 21 Jan 2020 14:22:38 +0100 From: Robin Jarry To: Bruce Richardson Cc: dev@dpdk.org, thomas@monjalon.net Message-ID: <20200121132238.zukav3ysrl3ijpor@6wind.com> References: <20200120173725.57529-1-bruce.richardson@intel.com> <20200121111228.5591-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200121111228.5591-1-bruce.richardson@intel.com> User-Agent: NeoMutt/20180716 Subject: Re: [dpdk-dev] [PATCH v2] 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" 2020-01-21, 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.py > @@ -0,0 +1,13 @@ > +#! /usr/bin/env python3 > +# SPDX-License-Identifier: BSD-3-Clause > +# Copyright(c) 2020 Intel Corporation > + > +import sys > +import os > +from glob import iglob # glob iterator No need to make it explicit. People can read the description in the official docs. > +from os.path import join, relpath, isdir You already imported 'os'. These functions are available under the 'os.path' namespace. No need to import them again. > +root = join(os.environ['MESON_SOURCE_ROOT'], os.environ['MESON_SUBDIR']) > +for path in sys.argv[1].split(','): Directly accessing sys.argv exposes you to ugly errors when the script is called with the wrong number of arguments. It would be better to use argparse which will handle the error reporting for you. > + relpaths = [relpath(p, root) for p in iglob(join(root, path)) if isdir(p)] > + print("\n".join(relpaths)) Using one-liner syntax like these really makes the code hard to understand. Explicit for loops with explicit if tests would be a lot nicer. Also, why use an intermediate variable to then, join each element with '\n' and print that? You can print the matching dirs as you iterate over them. Have a look at my previous reply for a complete example of what I mean. -- Robin