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

Move all config handling into a single place – a config.h file, do not clutter the command line with these additional project-wide defines. #5102

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

asl
Copy link
Contributor

@asl asl commented Jan 16, 2025

There are multiple reasons for this:

  • Control fine-grained inclusion. If option changed, not the whole project need to be rebuilt
  • CONFIG_PKGDATADIR / CONFIG_PREFIX are paths and might contain special symbols that might be not so good on command line
  • Overall uniformity

@asl asl requested review from vlstill, fruffy and qobilidop January 16, 2025 17:41
@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Jan 16, 2025
Copy link
Collaborator

@fruffy fruffy left a comment

Choose a reason for hiding this comment

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

Great!

…t clutter

the command line with these additional project-wide defines.

Signed-off-by: Anton Korobeynikov <[email protected]>
@asl asl force-pushed the cleanup-config branch 2 times, most recently from 2398728 to 7c98550 Compare January 16, 2025 17:57
Copy link
Contributor

@ChrisDodd ChrisDodd left a comment

Choose a reason for hiding this comment

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

Seems good, though changes to config.h will probably trigger rebuilding most everything.

BUILD.bazel Outdated
cmd = "sed -e 's|cmakedefine|define|g' \
-e 's|define HAVE_LIBGC 1|undef HAVE_LIBGC|g' \
-e 's|define HAVE_LIBBACKTRACE 1|undef HAVE_LIBBACKTRACE|g' \
-e 's|define HAVE_MM_MALLOC_H 1|undef HAVE_MM_MALLOC_H|g' \
< $(SRCS) > $(OUTS)",
-e 's|define HAVE_MM_MALLOC_H 1|undef HAVE_MM_MALLOC_H|g' \
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicating this line is not necessary (but not harmful, either).


#cmakedefine CONFIG_PKGDATADIR "@CONFIG_PKGDATADIR@"

#cmakedefine CONFIG_PREFIX "@CONFIG_PREFIX@"
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't @CONFIG_PREFIX@ need to be substituted in the the sed command in BUILD.bazel above?

Copy link
Contributor Author

@asl asl Jan 16, 2025

Choose a reason for hiding this comment

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

In fact it is unused in the whole codebase, so it is the question if it is needed at all. I do not know what the value should be in Bazel case, so I decided to leave it as-is, so first usage will trigger an error for Bazel and one would need to determine the proper value.

Signed-off-by: Anton Korobeynikov <[email protected]>
@asl
Copy link
Contributor Author

asl commented Jan 16, 2025

Seems good, though changes to config.h will probably trigger rebuilding most everything.

Well, same as cmdline changes, there are no changes here. Though, we can limit inclusion of config and control this

@asl asl enabled auto-merge January 16, 2025 23:14
@asl asl added this pull request to the merge queue Jan 17, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 17, 2025
@asl asl added this pull request to the merge queue Jan 17, 2025
Merged via the queue into p4lang:main with commit fa9dc08 Jan 17, 2025
19 checks passed
@asl asl deleted the cleanup-config branch January 17, 2025 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Topics concerning the core segments of the compiler (frontend, midend, parser)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants