Skip to content

Added option to pass custom C postprocessor #1331

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

czgdp1807
Copy link
Collaborator

cc: @certik

add_custom_command(
OUTPUT ${name}.c
COMMAND lpython --show-c ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py
--custom-c-postprocessor ${CMAKE_CURRENT_SOURCE_DIR}/${custom_c_postprocessor} > ${name}.c
Copy link
Contributor

Choose a reason for hiding this comment

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

I think as part of this change, let's not do --show-c, but rather save the result to a file ourselves, so no need for ">" which is quite fragile in build systems.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree. Will do this on Thursday.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. Please check the latest diff and let me know if you have any questions.

@certik
Copy link
Contributor

certik commented Nov 29, 2022

Thanks for this, the other thing we need is to allow passing arguments to the script. I have just refactored such a script so that it accepts an argument of a some_file.inc that gets included at the top of the generated file as a header, instead of heaving the header hardwired in the script. I also need to add another argument with a file with a list of functions to modify.

@czgdp1807
Copy link
Collaborator Author

czgdp1807 commented Dec 5, 2022

Well what do you think about this - Instead of passing a bunch of arguments to the post processor via LPython, can we just create a json file specifying all the configuration and the post processor can read this json file and do the necessary things. We can pass the path to this json file to the post processor via command line argument. So LPython will only call, python post_processor.py path_to_json_config_file and not python post_processor.py some_headers some_other_information some_more_information.

@certik
Copy link
Contributor

certik commented Dec 5, 2022

Yes, the JSON approach is fine.

@certik
Copy link
Contributor

certik commented Dec 5, 2022

I will test this PR manually and see if it satisfies our use case.

@certik certik mentioned this pull request Mar 23, 2023
38 tasks
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.

2 participants