[Buildroot] [PATCH v2 1/1] utils/genrandconfig: make default toolchain_csv path absolute

James Hilliard james.hilliard1 at gmail.com
Wed Feb 15 21:57:50 UTC 2023


On Wed, Feb 15, 2023 at 2:46 PM Arnout Vandecappelle <arnout at mind.be> wrote:
>
>
>
> On 15/02/2023 22:29, James Hilliard wrote:
> > On Wed, Feb 15, 2023 at 2:20 PM Arnout Vandecappelle <arnout at mind.be> wrote:
> >>
> >>
> >>
> >> On 15/02/2023 22:15, James Hilliard wrote:
> >>> The default toolchain_csv path is a relative path to the buildroot
> >>> directory.
> >>>
> >>> If we run genrandconfig with a cwd that is not the buildroot directory
> >>> the default toolchain_csv path will be wrong.
> >>>
> >>> To fix this make the default toolchain_csv path absolute.
> >>>
> >>> Fixes:
> >>> FileNotFoundError: [Errno 2] No such file or directory: 'support/config-fragments/autobuild/toolchain-configs.csv'
> >>>
> >>> Signed-off-by: James Hilliard <james.hilliard1 at gmail.com>
> >>> ---
> >>> Changes v1 -> v2:
> >>>     - set default path as absolute
> >>> ---
> >>>    utils/genrandconfig | 4 +++-
> >>>    1 file changed, 3 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/utils/genrandconfig b/utils/genrandconfig
> >>> index b3576f8a51..3552b83694 100755
> >>> --- a/utils/genrandconfig
> >>> +++ b/utils/genrandconfig
> >>> @@ -801,7 +801,9 @@ if __name__ == '__main__':
> >>>                                    dest="toolchains_csv",
> >>>                                    help="Generate random toolchain configuration",
> >>>                                    action='store_false')
> >>> -    parser.set_defaults(toolchains_csv="support/config-fragments/autobuild/toolchain-configs.csv")
> >>> +    buildroot_abs = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
> >>> +    parser.set_defaults(toolchains_csv=os.path.join(buildroot_abs,
> >>> +                        "support/config-fragments/autobuild/toolchain-configs.csv"))
> >>
> >>    Sorry, that's not going to work either (if it was that easy I'd done it myself :-)
> >
> > Under what scenario would this break?
>
>   I have ~/src/buildroot/utils in my PATH, so I just run 'genrandconfig' from
> path. If I want to run it in a different worktree (e.g. ~/src/buildroot-next
> which tracks the next branch), I would go to that directory and run
> "genrandconfig", so it would use the one in ~/src/buildroot, not the one in
> ~/sr/buildroot-next. In that case, of course, I want to use the
> toolchain-configs.csv from the next branch, not the one from ~/src/buildroot.

Well you can still do that by passing the relative path via --toolchains-csv to
override the default abs path.

>
>
> >>    buildrootdir can be set to something else with the -b argument, and we want it
> >> relative to *that* one of course.
> >
> > Using buildrootdir is cwd dependent,
>
>   The default value is cwd dependent; the value you give with the -b option can
> be absolute or relative.

Yeah, but I think making it an abs path relative to the genrandconfig
file as the
default is less likely to cause unexpected issues. Having it relative
to cwd when
not passing an option is a bit unexpected IMO.

>
> > the approach I used is not as it uses the
> > absolute path of the genrandconfig file to compute the default toolchain_csv
> > abs path.
>
>   And my point is that it should be relative to the buildrootdir given with the
> commandline option, not relative to the place where genrandconfig happens to reside.

It's still relative to cwd when passing a relative path via
--toolchains-csv, just the
default is changed to be an abs path.

>
>   TBH, I think genrandonfig has too many options :-)
>
>   Regards,
>   Arnout
>
> >
> >>
> >>    Regards,
> >>    Arnout
> >>
> >>>
> >>>        args = parser.parse_args()
> >>>



More information about the buildroot mailing list