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

Factor out some file-generation machinery #181

Merged
merged 9 commits into from May 17, 2024

Conversation

mabruzzo
Copy link
Collaborator

@mabruzzo mabruzzo commented Mar 6, 2024

Overview:

EDIT: I decided to overhaul this PR significantly. When reviewing it, it should be easier to review the net change rather than the individual commits)

This PR is nominally focused on refactoring some of the machinery related to autogenerating files. We now use more conventional "template" files (this pattern is used in cmake projects, autotools projects, and I've seen it projects with more atypicial build-systems like Athena++).

We now have template files called src/clib/auto_general.c.in and src/clib/grackle_float.h.in. The build system executes the python-script called config/configure_file.py in order to create copies and perform variable substitution. Any name enclosed by a pair of @ symbols in the template file is identified as the variable name. In the output file, it will be replaced by the associated value (specified as command-line argument of config/configure_file.py).

This change should make the codebase a lot more approachable. (It also helps pave the way for generating stuff like pkg-config files in a future PR - these files can help downstream applications automatically infer the required compiler args)

Another included change: We also now track the current grackle version number in a dedicated file called VERSION.

@mabruzzo
Copy link
Collaborator Author

mabruzzo commented Mar 6, 2024

Now that I've overhauled this PR, this comment is no longer needed

@mabruzzo mabruzzo added the build-system Related to the build-system label Mar 17, 2024
@brittonsmith brittonsmith modified the milestones: 3.2, 3.3 Mar 22, 2024
…s. Autogeneration should now be a lot more transparent.
@mabruzzo
Copy link
Collaborator Author

mabruzzo commented Apr 9, 2024

I reimplemented the core-logic in terms of regex expressions

This was achieved by tweaking `doc/source/conf.py`.

This triggered a few cascading changes:
1. I needed to rename `config/query-version.py` to `config/query_version.py` so that it's contents could be properly imported
2. I needed to slightly tweak the internals of `config/query_version.py` so that the function returned values (instead of directly printing the value). To reflect this change in behavior, I changed a function name from `show_version` to `query_version`
3. While doing this, I also fixed a bug in some functionality from `config/query_version.py` that was intended to strip off a trailing '\n' character from the result of a shell command. In some cases, a trailing line-break might not be present and the functionality accidentally striped off a different character instead.
4. I needed to adjust a path in `src/clib/Makefile` to reflect the new name of the `config/query_version.py` script
Copy link
Contributor

@brittonsmith brittonsmith left a comment

Choose a reason for hiding this comment

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

This looks great. I have just a couple comments.

config/query_version.py Outdated Show resolved Hide resolved
src/clib/Makefile Outdated Show resolved Hide resolved
Previously, `LIB_RELEASE_VERSION` was defined in `src/clib/Make.config.assemble`.
- This was fine, when `LIB_RELEASE_VERSION` was assigned a hardcoded value
- however, after we started to use a script to retrieve this value, error messages were printed whenever we invoked the `src/example/Makefile` (to build code-examples)
- The error messages arise because the path to the script was encoded within the `QUERY_VERSION` variable and that variable was not defined when `src/example/Makefile` included `src/clib/Make.config.assemble`
- Since script-path is only defined within `src/clib/Makefile` I decided to move the definition of `LIB_RELEASE_VERSION` to that file.

NOTE: since the `LIB_RELEASE_VERSION` wasn't actually used by `src/example/Makefile` the error-messages before this commit were entirely benign.
The required logic to fetch the last line of the file is now implemented in python. The logic loops over all lines from the VERSION file (from beginning to end) and returns the final non-empty line. This is fine for the VERSION file which should really just be 1 line (but is suboptimal for large files)
@brittonsmith brittonsmith merged commit 58dcca2 into grackle-project:main May 17, 2024
3 checks passed
mabruzzo added a commit to mabruzzo/grackle that referenced this pull request May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-system Related to the build-system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants