Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1515812rwb; Thu, 19 Jan 2023 11:40:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXsI/LmMK+tzKL+JZ00hgojRBr+Vvi6Z0CRL0CXN79OKCypIAI7fkP1uVfff8tYfsRnwFPDz X-Received: by 2002:aa7:8c51:0:b0:58d:8d88:447b with SMTP id e17-20020aa78c51000000b0058d8d88447bmr10830435pfd.2.1674157220758; Thu, 19 Jan 2023 11:40:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674157220; cv=none; d=google.com; s=arc-20160816; b=j39dCoR4U8UV3CHsLl8++J5Y8pOX6H1EnZYLHEZe9FX6Y60WS3l+N8YJjYLvLgLWbd BeNpHlLArjrOAy2pb6HhbqJglCJiu+HP55l2MkaAfgC4D/9ewHml6j4K6nIJTpXE6RNc HQqf8bL0D4quMNYVTEaKsLP69ihmbbDcCLzgjnGXGKf8+LikmP379mrjdUke8XfzbAvn mww/EVq8TAyKCC4GXDuNnTrCX0Vo3zeIm8IrnESshMj+glaU9GI7YCGgbPwDjR++YEQI PCV884FDE02bitK3iuVeNsAaTPDrZJQg93bnQQo2/DhDN9I482z+51pJBkJupxxmLgym hUrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=f66M40S9HUafYr8hVajn8DVAsyr9TRcLXW/GMSQFYTg=; b=a7XxdhOk/SAbPQvbcamoT0PC82Le0pQ9zkWM2enSvFuaLIZReU1drBKYsl4CTRuNDq zwmaHR8jk+My8ijlWsIFU1+Tsgyx/113Yl8d1GMz0xSc/K2KNRgcRwE/H2rxrlS2RrUs YcMuH1wCe6DgKQWcfKCGBrCdIga/g/ceLyGXzuRins+maB3AQvw6Mf81HoPDsTUeRnGj SSCxsIbvLn7nwg6wuwMmMt/50j7XC5vNPhwNtiy64pWU49bnRmUMD79pNkInlw2ihf71 MG1lGhiYSMGw3ta5ngn6LZDddcUdCHG+OByh5Xk52y/tBaxfglAeZQL2tUhr5EaGOBS1 XWTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TfdQOo0L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a056a0022c700b0058de1c3118csi7451072pfj.325.2023.01.19.11.40.15; Thu, 19 Jan 2023 11:40:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=TfdQOo0L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231322AbjASTPh (ORCPT + 46 others); Thu, 19 Jan 2023 14:15:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231210AbjASTO3 (ORCPT ); Thu, 19 Jan 2023 14:14:29 -0500 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 057BF485B6; Thu, 19 Jan 2023 11:13:09 -0800 (PST) Received: by mail-yb1-xb34.google.com with SMTP id a9so3864049ybb.3; Thu, 19 Jan 2023 11:13:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=f66M40S9HUafYr8hVajn8DVAsyr9TRcLXW/GMSQFYTg=; b=TfdQOo0L5L7tRei4gTZQorDhEqkwLnIcUwjUkQ5nAUhG3adcGnD6aApx5mVazXjz8G BKhASFxhlmU79yGq2yYeB7ddF5FQzvqefzN90g3fCYjYV/9sFaZ0LDQ3hJo2xA6cu2GN lld1fXQg5qPS2DBEMwaxNTCpjmFZcbBeKU49OPbifSyy2uMi1ixSRTiydAInHXYJKKzE wvBavFk9xhLq2N00xTLR41SV4jXSPGVygDS47MqvDluRTjxkeRN0CfD1LQeH9FKLjLpZ dkLR7EexO2NPd68tPR7TjSKVS1btSYjLdr1QXKL8PGFhIoS9WrTU13eWGZ+1Yu/ekS5D t3sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=f66M40S9HUafYr8hVajn8DVAsyr9TRcLXW/GMSQFYTg=; b=3vWHd0KoPm0MXsBIRCgfb3mkYgcUEOr625g5xgNlXEQPUUpolnvyzZQB5F6LhU9Hcy iBs4Zh0G0jbw5FwTXUD/Nbm/gLwVXREV1kqP+PtSqr/ZARGc5nO9MPsvtOT0RDVAzcga p1katRQkK31f86P8N+YNe340dA1TDnMM5nopJzYwI8P8YPizA+Y7EpXoNSB6XmNjJ8md aEG1Ad0e0GytlAlX4VK8ewSg3bEBxkpofE6x6Ra0adLzzFUFpGk2YPta72qKCBqmCgcg B9468zNb3SXo0VhB32IvoDSN8XHHZiPP/0duluKqbkUJ5iyL3iwAQ9fiYL+bNhty96CV E1Og== X-Gm-Message-State: AFqh2krxkatH1mlK3u/CfOWLzKa7pTa8SitdRCPV1qtDcLMo0nPo0EtV SBUOm1ECmQZxwaukG7PnBTEm5iLBK57auHzB9GWcm0bvlc3w/SjGZ4M= X-Received: by 2002:a5b:688:0:b0:7e1:ed59:4e43 with SMTP id j8-20020a5b0688000000b007e1ed594e43mr1580106ybq.323.1674155587313; Thu, 19 Jan 2023 11:13:07 -0800 (PST) MIME-Version: 1.0 References: <20230118160220.776302-1-varmavinaym@gmail.com> In-Reply-To: <20230118160220.776302-1-varmavinaym@gmail.com> From: Miguel Ojeda Date: Thu, 19 Jan 2023 20:12:56 +0100 Message-ID: Subject: Re: [PATCH] scripts: `make rust-analyzer` for out-of-tree modules To: Vinay Varma Cc: Masahiro Yamada , Michal Marek , Nick Desaulniers , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 18, 2023 at 5:02 PM Vinay Varma wrote: > > Adds support for out-of-tree rust modules to use the `rust-analyzer` > make target to generate the rust-project.json file. Thanks for sending this! A few nits below... > When this parameter is passed, I have chosen > not to add the non-core modules (samples and drivers) into the result > since these are not expected to be used in third party modules. Sounds good to me. > changes are also made to the Makefile and rust/Makefile allowing the > `rust-analyzer` target to be used for out-of-tree modules as well. > > Signed-off-by: Vinay Varma A `Link: ` to the GitHub PR would be nice here: https://github.com/Rust-for-Linux/linux/pull/914. Possibly another one to the out-of-tree approach at https://github.com/Rust-for-Linux/rust-out-of-tree-module/pull/2. > import logging > import pathlib > import sys > +import os Please keep the `import`s sorted. > - for folder in ("samples", "drivers"): > + extra_src_dirs = ["samples", "drivers"] if external_src is None else [external_src] If you send a v2 for the above, this could be a tuple like in the original line, to minimize the diff. > + if os.path.exists(path.parent / "Makefile") and f"{name}.o" not in open(path.parent / "Makefile").read(): In Python one would typically go with the EAFP style instead (https://docs.python.org/3/glossary.html#term-EAFP), which would also reduce the duplication of the path computation. But it would take more lines... Not a big deal in any case. Thanks! Cheers, Miguel