Skip to content

win32: use tmp file when creating config.sh #20110

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

Merged
merged 1 commit into from
Sep 5, 2022

Conversation

bram-perl
Copy link

When config_sh.PL failed then it created an empty '..\config.sh' file.
This is unwanted since if make is then re-run it detects a '..\config.sh'
file and skips the target which leads to completely different errors.

After adding a die "Foobar"; in win32/config_sh.PL:

$ gmake INST_TOP=... CCHOME=...
...
..\miniperl.exe -I..\lib config_sh.PL ... > ..\config.sh
Foobar at config_sh.PL line 5.
gmake: *** [GNUmakefile:1175: ..\config.sh] Error 255

Re-running the make command:

$ gmake INST_TOP=... CCHOME=...
..\miniperl.exe -I..\lib ..\configpm --chdir=..
Use of uninitialized value $t in string eq at ..\configpm line 345.
...
written lib/Config.pod
updated lib/Config.pm
updated lib/Config_heavy.pl
syntax error at lib/Config_heavy.pl line 165, near "x;"
Compilation failed in require at ..\configpm line 1144.
gmake: *** [GNUmakefile:1190: ..\lib\Config.pm] Error 255

When gmake was re-run it started with the '$(CONFIGPM)' target instead
of the '..\config.sh' target.

The fix: instead of creating '..\config.sh' it now first creates '..\config.sh.tmp' and then renames1 it to '..\config.sh'

Tested the GNUmakefile on Windows 10 using GNU Make v4.2.1,
I did not test the Makefile (no nmake installed).

Footnotes

  1. rename on windows only takes a path in the first argument.
    That is: rename ..\config.sh.tmp config.sh can be considered
    the same as move ..\config.sh.tmp ..\config.sh.

When `config_sh.PL` failed then it created an empty '..\config.sh' file.
This is unwanted since if make is then re-run it detects a '..\config.sh'
file and skips the target which leads to completely different errors.

After adding a `die "Foobar";` in win32/config_sh.PL:

	$ gmake INST_TOP=... CCHOME=...
	...
	..\miniperl.exe -I..\lib config_sh.PL ... > ..\config.sh
	Foobar at config_sh.PL line 5.
	gmake: *** [GNUmakefile:1175: ..\config.sh] Error 255

Re-running the make command:

	$ gmake INST_TOP=... CCHOME=...
	..\miniperl.exe -I..\lib ..\configpm --chdir=..
	Use of uninitialized value $t in string eq at ..\configpm line 345.
	...
	written lib/Config.pod
	updated lib/Config.pm
	updated lib/Config_heavy.pl
	syntax error at lib/Config_heavy.pl line 165, near "x;"
	Compilation failed in require at ..\configpm line 1144.
	gmake: *** [GNUmakefile:1190: ..\lib\Config.pm] Error 255

When `gmake` was re-run it started with the '$(CONFIGPM)' target instead
of the '..\config.sh' target.

The fix: instead of creating '..\config.sh' it now first creates
         '..\config.sh.tmp' and then renames[^1] it to '..\config.sh'

Tested the GNUmakefile on Windows 10 using GNU Make v4.2.1,
I did *not* test the Makefile (no nmake installed).

[^1]: `rename` on windows only takes a path in the first argument.
      That is: `rename ..\config.sh.tmp config.sh` can be considered
      the same as `move ..\config.sh.tmp ..\config.sh`.
@bram-perl bram-perl force-pushed the bram/win32-makefile-config.sh branch from 13dd85c to f36a072 Compare September 4, 2022 13:03
@demerphq demerphq merged commit 8d845d9 into Perl:blead Sep 5, 2022
@bram-perl bram-perl deleted the bram/win32-makefile-config.sh branch September 11, 2022 16:26
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.

2 participants