-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
Use Makefile's pattern rules for the intermediate assert/writeln translation #1590
Conversation
assert_writeln_magic.d
Outdated
{ | ||
auto tmpFile = File(destFile ~ ".tmp", "w"); | ||
writeLinesToFile(tmpFile); | ||
tmpFile.name.rename(destFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renaming an open file will fail on Windows. Do we care about that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think it won't. Renaming over an open file will. Never mind.
assert_writeln_magic.d
Outdated
if (inputDir.length == 0) | ||
parseFile(file.name, outputDir); | ||
else | ||
parseFile(file.name, file.name.replace(inputDir, outputDir)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tricky! What if inputDir
is "."
?
For my own use I have https://github.com/CyberShadow/ae/blob/13bc434ea12c90883f524818510f35970230becb/utils/path.d#L18-L23
posix.mak
Outdated
@@ -40,6 +40,10 @@ PHOBOS_STABLE_DIR=${PHOBOS_DIR}-${LATEST} | |||
GENERATED=.generated | |||
PHOBOS_DIR_GENERATED=$(GENERATED)/phobos-prerelease | |||
PHOBOS_STABLE_DIR_GENERATED=$(GENERATED)/phobos-release | |||
PHOBOS_FILES := $(shell find $(PHOBOS_DIR) -name '*.d' -o -name '*.mak' -o -name '*.ddoc') | |||
PHOBOS_FILES_GENERATED := $(subst $(PHOBOS_DIR), $(PHOBOS_DIR_GENERATED), $(PHOBOS_FILES)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it would be nice if more things in the makefile were documented.
I gave it a first shot. Nothing fancy, the biggest changes were to use the same |
if (inputDir.length == 0) | ||
parseFile(file.name, outputDir); | ||
else | ||
parseFile(file.name, file.name.rebasePath(inputDir, outputDir)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw I just kept this support because it might be nice "in a possible future". It's not needed anymore as the Makefile does the invocations with a single file.
@@ -33,13 +39,24 @@ [email protected]:data | |||
|
|||
# Last released versions | |||
DMD_STABLE_DIR=${DMD_DIR}-${LATEST} | |||
DMD_REL=$(DMD_STABLE_DIR)/src/dmd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imho it would be better to rename this existing variable to sth. like DMD_STABLE_BIN
################################################################################ | ||
|
||
$(GENERATED): | ||
mkdir -p $@ | ||
ASSERT_WRITELN_BIN = $(GENERATED)/assert_writeln_magic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yet another small cleanup - sorry that I didn't think about this earlier.
Great, thanks! |
BTW since I noticed |
HAS_RSYNC := $(shell command -v rsync 2> /dev/null) | ||
$(ASSERT_WRITELN_BIN): assert_writeln_magic.d $(DUB) | ||
@mkdir -p $(dir $@) | ||
$(DUB) build --single $< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, but I don't want to force-push during a review. The idea is that you only have to review the new changes ;-) |
|
Not sure if it makes a difference if we use Btw anything blocking this? I think this time I should do manual squashing to keep some commits, so please let me know. |
Actually, would be cool if dbot could auto-squash --fixup commits. |
Yes please. |
- only regeneration - removes the ugly rsync workaround
2f61f77
to
c9cf21e
Compare
Good idea - noted it here: (but the queue is currently a bit full).
Done :) |
Well, I was going to merge anyway :P |
rsync
workaround