Skip to content

Conversation

@zuiderkwast
Copy link
Contributor

@zuiderkwast zuiderkwast commented Jan 1, 2022

With this rule, the script to generate commands.c from JSON runs whenever commands.o is built if any of commands/*.json are modified. Without such rule, it's easy to forget to run the script when updating the JSON files.

It's a follow-up on #9656 and #9951.

@zuiderkwast zuiderkwast requested a review from guybe7 January 1, 2022 23:37
@oranagra
Copy link
Member

oranagra commented Jan 2, 2022

@zuiderkwast we didn't want to add python as a dependency for building redis, that's why we're packaging commands.c as part of the project source code.
i.e. people who just download the source package and build it.

Arguably, your suggestion doesn't break that, but i'm not sure i trust file system modification time.
i.e. there could be some cases that somehow the command json files will get a newer timestamp than commands.c.

@yossigo WDYT?

@zuiderkwast
Copy link
Contributor Author

If not, then let's at least add the rule for commands.c so I can write make commands.c to update it, so I don't need to remember the name of the script.

@oranagra
Copy link
Member

oranagra commented Jan 3, 2022

that we can certainly do.. we actually had it, and i asked to remove it (together with the rule for building help.h).

i'm still not confident we can't take your PR as is.. maybe i'm just paranoid, and in practice there's no way that the json files will have a newer time than command.c for naive users that just wanna build redis from a tar file or a git clone.

p.s i do have some ideas about some GH action around commands.c generations or validations (e.g. it can generate it and compare to the copy in the branch).
and also some action to automatically make a PR to redis-doc when changes are merged to redis.

@yossigo
Copy link
Collaborator

yossigo commented Jan 4, 2022

@oranagra I think the problem won't be the filesystem but inexperienced users who somehow get the files modified and don't have the Python dependency.

@zuiderkwast
Copy link
Contributor Author

If don't want to depend on Python and we're going to use JSON more, perhaps it's time to include a minimal C JSON library? There are some in ~400 LOC. For commands.c, we can even use one without Unicode support.

Then we can rewrite the python script in C or we can let redis-server load the JSON files directly.

@yossigo
Copy link
Collaborator

yossigo commented Jan 4, 2022

@zuiderkwast I don't feel very comfortable doing this in C (and certainly not at runtime) only because of toolchain issues.

Maybe we can adopt a middle way - include commands.c as part of the source tree, so you don't have to generate it. Add Make rules to re-generate it if necessary, but don't fail compilation if we lack Python to do that. Does this make sense?

@zuiderkwast
Copy link
Contributor Author

This PR is already a middle way, leaving commands.c checked in. I can add some make ifdefs based on which python, skipping the rule if there's no python.

Copy link
Member

@oranagra oranagra left a comment

Choose a reason for hiding this comment

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

fine by me.

@oranagra oranagra requested a review from yossigo January 4, 2022 13:31
Co-authored-by: Yossi Gottlieb <yossigo@gmail.com>
@yossigo yossigo merged commit e88f6ac into redis:unstable Jan 6, 2022
@zuiderkwast zuiderkwast deleted the build-commands-in-makefile branch January 6, 2022 22:19
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