Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better autogen #247

Merged
merged 7 commits into from
Jan 14, 2024
Merged

Better autogen #247

merged 7 commits into from
Jan 14, 2024

Conversation

ShiCheng-Lu
Copy link
Collaborator

@ShiCheng-Lu ShiCheng-Lu commented Dec 13, 2023

change the autogen to be called only once to generate all the can files for one project

autogenner -f {source_dir} -t {all source templates...} -f {header dir} -t {all header templates}

changed test_runner auto-generator to use jinja

added a python template to generate some cansend functions for can (just preliminary)

@ShiCheng-Lu ShiCheng-Lu marked this pull request as ready for review December 14, 2023 03:35
@@ -10,7 +10,7 @@

---
Messages:
uv_cutoff_notification:
uv_cutoff_notification1:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are two uv_cutoffs, from power-distribution and uw_cutoff, both to telemetry, and autogen can't handle this, so slight name change. Previously, one of them is just ignored, but this is in fact a different message with different id.

"receiver": message["target"],
})

return {"Boards": boards, "Messages": messages}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autogen will now read all board yamls once, all necessary message info is stored in this dictionary (list of boards to generate board id, and list of messages which is then filtered by the board at jinja generation)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

def main():
parser = OptionParser()
# TODO: Get rid of -y option or -b option, redundant
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got rid of -y option, can't get rid of -b option unless we want to infer the board from the output path, which is a bit ugly. Maybe later with better_better_autogen

@@ -1,16 +1,16 @@
{% set board = data["Board"] -%}
{% set messages = data["Messages"] | selectattr("receiver", "contains", board) | list -%}
Copy link
Collaborator Author

@ShiCheng-Lu ShiCheng-Lu Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this bit filters the messages to contain only the relevant ones for the specific board.

@@ -2,5 +2,6 @@
"libs": [
"FreeRTOS",
"ms-common"
]
],
"no_lint": true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are some python lint issues in this library, it's annoying to fix, make a ticket for this.

@ShiCheng-Lu
Copy link
Collaborator Author

ShiCheng-Lu commented Dec 16, 2023

eventually, I want to have all autogeneration stuff in one place, for can autogen, test auto gen, and new project autogen.

better_better_autogen:

something like

-autogen
    - can
        - src
            - {{board}}_tx.c.jinja
            - {{board}}_rx.c.jinja
        - inc
            - {{board}}_struct.h.jinja
            - ...
    - test
        - test_runner.c.jinja
    - new_project
        - config.json
        - src
            - main.c
        - inc
      ....

then specifying autogen can -o <folder> will generate all the templates in the can folder into the output folder. each folder will possibly have some function that retrieves the data needed to generate it.

SConstruct Outdated Show resolved Hide resolved
"receiver": message["target"],
})

return {"Boards": boards, "Messages": messages}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

libraries/codegen/templates/can.py.jinja Outdated Show resolved Hide resolved
py/can.py Outdated Show resolved Hide resolved
@ShiCheng-Lu ShiCheng-Lu merged commit 7be5949 into main Jan 14, 2024
1 check passed
@ShiCheng-Lu ShiCheng-Lu deleted the better_autogen branch January 14, 2024 03:42
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.

3 participants