public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH] allow src/tools/msvc/*.bat files to be called from the root of the source tree
2+ messages / 2 participants
[nested] [flat]

* [PATCH] allow src/tools/msvc/*.bat files to be called from the root of the source tree
@ 2021-12-29 10:16  Anton Voloshin <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Anton Voloshin @ 2021-12-29 10:16 UTC (permalink / raw)
  To: pgsql-hackers

Hello,

currently, on Windows/MSVC, src\tools\msvc\*.bat files mostly require 
being in that src\tools\msvc directory first.

I suggest an obvious fix:

diff --git a/src/tools/msvc/build.bat b/src/tools/msvc/build.bat
index 4001ac1d0d1..407b6559cfb 100755
--- a/src/tools/msvc/build.bat
+++ b/src/tools/msvc/build.bat
@@ -3,4 +3,4 @@ REM src/tools/msvc/build.bat
  REM all the logic for this now belongs in build.pl. This file really
  REM only exists so you don't have to type "perl build.pl"
  REM Resist any temptation to add any logic here.
-@perl build.pl %*
+@perl %~dp0\build.pl %*
diff --git a/src/tools/msvc/install.bat b/src/tools/msvc/install.bat
index d03277eff2b..98edf6bdffb 100644
--- a/src/tools/msvc/install.bat
+++ b/src/tools/msvc/install.bat
@@ -3,4 +3,4 @@ REM src/tools/msvc/install.bat
  REM all the logic for this now belongs in install.pl. This file really
  REM only exists so you don't have to type "perl install.pl"
  REM Resist any temptation to add any logic here.
-@perl install.pl %*
+@perl %~dp0\install.pl %*
diff --git a/src/tools/msvc/vcregress.bat b/src/tools/msvc/vcregress.bat
index a981d3a6aa1..0d65c823e13 100644
--- a/src/tools/msvc/vcregress.bat
+++ b/src/tools/msvc/vcregress.bat
@@ -3,4 +3,4 @@ REM src/tools/msvc/vcregress.bat
  REM all the logic for this now belongs in vcregress.pl. This file really
  REM only exists so you don't have to type "perl vcregress.pl"
  REM Resist any temptation to add any logic here.
-@perl vcregress.pl %*
+@perl %~dp0\vcregress.pl %*

This patch uses standard windows cmd's %~dp0 to get the complete path 
(drive, "d", and path, "p") of the currently executing .bat file to get 
proper path of a .pl file to execute. I find the following link useful 
whenever I need to remember details on cmd's %-substitution rules: 
https://ss64.com/nt/syntax-args.html

With this change, one can call those .bat files, e.g. 
src\tools\msvc\build.bat, without leaving the root of the source tree.

Not sure if similar change should be applied to pgflex.bat and 
pgbison.bat -- never used them on Windows and they seem to require being 
called from the root, but perhaps they deserve a similar change.

If accepted, do you think this change is worthy of back-porting?

Please advise if you think this change is a beneficial one.

P.S. Yes, I am aware of very probable upcoming move to meson, but until 
then this little patch really helps me whenever I have to deal with 
Windows and MSVC from the command line. Besides, it could help old 
branches as well.

-- 
Anton Voloshin

https://postgrespro.ru
Postgres Professional, The Russian Postgres Company

Attachments:

  [text/x-patch] msvc-bat-path-fix.patch (1.3K, ../../[email protected]/2-msvc-bat-path-fix.patch)
  download | inline diff:
diff --git a/src/tools/msvc/build.bat b/src/tools/msvc/build.bat
index 4001ac1d0d1..407b6559cfb 100755
--- a/src/tools/msvc/build.bat
+++ b/src/tools/msvc/build.bat
@@ -3,4 +3,4 @@ REM src/tools/msvc/build.bat
 REM all the logic for this now belongs in build.pl. This file really
 REM only exists so you don't have to type "perl build.pl"
 REM Resist any temptation to add any logic here.
-@perl build.pl %*
+@perl %~dp0\build.pl %*
diff --git a/src/tools/msvc/install.bat b/src/tools/msvc/install.bat
index d03277eff2b..98edf6bdffb 100644
--- a/src/tools/msvc/install.bat
+++ b/src/tools/msvc/install.bat
@@ -3,4 +3,4 @@ REM src/tools/msvc/install.bat
 REM all the logic for this now belongs in install.pl. This file really
 REM only exists so you don't have to type "perl install.pl"
 REM Resist any temptation to add any logic here.
-@perl install.pl %*
+@perl %~dp0\install.pl %*
diff --git a/src/tools/msvc/vcregress.bat b/src/tools/msvc/vcregress.bat
index a981d3a6aa1..0d65c823e13 100644
--- a/src/tools/msvc/vcregress.bat
+++ b/src/tools/msvc/vcregress.bat
@@ -3,4 +3,4 @@ REM src/tools/msvc/vcregress.bat
 REM all the logic for this now belongs in vcregress.pl. This file really
 REM only exists so you don't have to type "perl vcregress.pl"
 REM Resist any temptation to add any logic here.
-@perl vcregress.pl %*
+@perl %~dp0\vcregress.pl %*


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [PATCH] allow src/tools/msvc/*.bat files to be called from the root of the source tree
@ 2021-12-29 14:48  Andrew Dunstan <[email protected]>
  parent: Anton Voloshin <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Andrew Dunstan @ 2021-12-29 14:48 UTC (permalink / raw)
  To: Anton Voloshin <[email protected]>; pgsql-hackers


On 12/29/21 05:16, Anton Voloshin wrote:
> Hello,
>
> currently, on Windows/MSVC, src\tools\msvc\*.bat files mostly require
> being in that src\tools\msvc directory first.
>
> I suggest an obvious fix:
[...]

> This patch uses standard windows cmd's %~dp0 to get the complete path
> (drive, "d", and path, "p") of the currently executing .bat file to
> get proper path of a .pl file to execute. I find the following link
> useful whenever I need to remember details on cmd's %-substitution
> rules: https://ss64.com/nt/syntax-args.html
>
> With this change, one can call those .bat files, e.g.
> src\tools\msvc\build.bat, without leaving the root of the source tree.
>
> Not sure if similar change should be applied to pgflex.bat and
> pgbison.bat -- never used them on Windows and they seem to require
> being called from the root, but perhaps they deserve a similar change.
>
> If accepted, do you think this change is worthy of back-porting?
>
> Please advise if you think this change is a beneficial one.
>
> P.S. Yes, I am aware of very probable upcoming move to meson, but
> until then this little patch really helps me whenever I have to deal
> with Windows and MSVC from the command line. Besides, it could help
> old branches as well.
>


Seems reasonable. I don't see any reason not to do it for pgbison.bat
and pgflex.bat, just for the sake of consistency.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2021-12-29 14:48 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-12-29 10:16 [PATCH] allow src/tools/msvc/*.bat files to be called from the root of the source tree Anton Voloshin <[email protected]>
2021-12-29 14:48 ` Andrew Dunstan <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox