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

Avoid shelling *nix commands #2706

Merged
merged 2 commits into from
Apr 16, 2024
Merged

Avoid shelling *nix commands #2706

merged 2 commits into from
Apr 16, 2024

Conversation

ParadoxV5
Copy link
Contributor

Some of the commands used in the Makefile are not covered by RbConfig.
Coïncidentally, they’re all $(shell …) calls.

This PR replaces them with alternatives that do not assume the availability of *nix commands.

Reduces platform expectations; e.g., Windows building without specifying MSYS
@@ -6,7 +6,7 @@ Q1 = $(V:1=)
Q = $(Q1:0=@)
ECHO1 = $(V:1=@ :)
ECHO = $(ECHO1:0=@ echo)
FUZZ_OUTPUT_DIR = $(shell pwd)/fuzz/output
FUZZ_OUTPUT_DIR = $(CURDIR)/fuzz/output
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CURDIR is technically different from shell pwd in that the latter isn’t stuck constant if the Makefile somehow cds halfway in the script.
That said, do we really want the build to base on the working directory rather than fixed at the repo root?

Comment on lines +18 to +19
HEADERS := $(wildcard include/*.h include/*/*.h include/*/*/*.h')
SOURCES := $(wildcard src/*.c src/*/*.c)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makefile doesn’t support recursive wildcard, so shelling out was accustomed.
The alternative is to write a custom function.

I’m fine with abandoning this change if it’s not worth to not shell-out.

For reference, mkmf-generated Makefiles does not expand recursively; that is, mkmf does not support source code subfolders.

@ParadoxV5 ParadoxV5 marked this pull request as ready for review April 14, 2024 23:27
@kddnewton kddnewton merged commit 35fd5f5 into ruby:main Apr 16, 2024
54 checks passed
@ParadoxV5 ParadoxV5 deleted the shell-agnostic branch April 16, 2024 20:08
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.

None yet

2 participants