Skip to content

Conversation

@Jassob
Copy link
Member

@Jassob Jassob commented Aug 13, 2024

This commit allows a user to run

cantool generate INPUT OUTPUT-DIRECTORY

where INPUT is either a path to a DBC file. Previously it was only
possible to provide INPUT as a directory containing DBC files.

N.B. When INPUT is a directory containing DBC files the generated
files are created in OUTPUT-DIRECTORY relative to where they are found
in INPUT.

As an example, given the following directory structure:

dbc/
   powertrain/pt.dbc
   steering/steer.dbc
   brake/brake.dbc

A cantool generate dbc/ gen/go call will generate the following
structure:

gen/go/
   powertrain/pt.dbc.go
   steering/steer.dbc.go
   brake/brake.dbc.go

However, when INPUT is a single DBC file it is generated directly in
OUTPUT-DIRECTORY with its basename as the stem.

cantool generate dbc/steering/steer.dbc gen/go/steering will
therefore generate the gen/go/steering/steer.dbc.go.

Inspired by #292 (thanks @bertaveira!)

This commit allows a user to run

    cantool generate INPUT OUTPUT-DIRECTORY

where INPUT is either a path to a DBC file. Previously it was only
possible to provide INPUT as a directory containing DBC files.

N.B. When INPUT is a directory containing DBC files the generated
files are created in OUTPUT-DIRECTORY relative to where they are found
in INPUT.

As an example, given the following directory structure:

    dbc/
       powertrain/pt.dbc
       steering/steer.dbc
       brake/brake.dbc

A `cantool generate dbc/ gen/go` call will generate the following
structure:

    gen/go/
       powertrain/pt.dbc.go
       steering/steer.dbc.go
       brake/brake.dbc.go

However, when INPUT is a single DBC file it is generated directly in
OUTPUT-DIRECTORY with its basename as the stem.

`cantool generate dbc/steering/steer.dbc gen/go/steering` will
therefore generate the gen/go/steering/steer.dbc.go.
@Jassob Jassob force-pushed the feat/allow-generate-single-files branch from 9a2c194 to b4ade07 Compare August 13, 2024 07:31
@Jassob Jassob marked this pull request as ready for review September 29, 2024 08:54
@Jassob Jassob requested a review from maxekman as a code owner September 29, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant