Skip to content

Commit

Permalink
vcbuild: add support for compiling Windows resource files
Browse files Browse the repository at this point in the history
Create a wrapper for the Windows Resource Compiler (RC.EXE)
for use by the MSVC=1 builds. This is similar to the CL.EXE
and LIB.EXE wrappers used for the MSVC=1 builds.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
  • Loading branch information
jeffhostetler authored and dscho committed Sep 18, 2024
1 parent af45d36 commit 96c1f69
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
7 changes: 7 additions & 0 deletions compat/vcbuild/find_vs_env.bat
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ REM ================================================================

SET sdk_dir=%WindowsSdkDir%
SET sdk_ver=%WindowsSDKVersion%
SET sdk_ver_bin_dir=%WindowsSdkVerBinPath%%tgt%
SET si=%sdk_dir%Include\%sdk_ver%
SET sdk_includes=-I"%si%ucrt" -I"%si%um" -I"%si%shared"
SET sl=%sdk_dir%lib\%sdk_ver%
Expand Down Expand Up @@ -130,6 +131,7 @@ REM ================================================================

SET sdk_dir=%WindowsSdkDir%
SET sdk_ver=%WindowsSDKVersion%
SET sdk_ver_bin_dir=%WindowsSdkVerBinPath%bin\amd64
SET si=%sdk_dir%Include\%sdk_ver%
SET sdk_includes=-I"%si%ucrt" -I"%si%um" -I"%si%shared" -I"%si%winrt"
SET sl=%sdk_dir%lib\%sdk_ver%
Expand Down Expand Up @@ -160,6 +162,11 @@ REM ================================================================
echo msvc_includes=%msvc_includes%
echo msvc_libs=%msvc_libs%

echo sdk_ver_bin_dir=%sdk_ver_bin_dir%
SET X1=%sdk_ver_bin_dir:C:=/C%
SET X2=%X1:\=/%
echo sdk_ver_bin_dir_msys=%X2%

echo sdk_includes=%sdk_includes%
echo sdk_libs=%sdk_libs%

Expand Down
46 changes: 46 additions & 0 deletions compat/vcbuild/scripts/rc.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/perl -w
######################################################################
# Compile Resources on Windows
#
# This is a wrapper to facilitate the compilation of Git with MSVC
# using GNU Make as the build system. So, instead of manipulating the
# Makefile into something nasty, just to support non-space arguments
# etc, we use this wrapper to fix the command line options
#
######################################################################
use strict;
my @args = ();
my @input = ();

while (@ARGV) {
my $arg = shift @ARGV;
if ("$arg" =~ /^-[dD]/) {
# GIT_VERSION gets passed with too many
# layers of dquote escaping.
$arg =~ s/\\"/"/g;

push(@args, $arg);

} elsif ("$arg" eq "-i") {
my $arg = shift @ARGV;
# TODO complain if NULL or is dashed ??
push(@input, $arg);

} elsif ("$arg" eq "-o") {
my $arg = shift @ARGV;
# TODO complain if NULL or is dashed ??
push(@args, "-fo$arg");

} else {
push(@args, $arg);
}
}

push(@args, "-nologo");
push(@args, "-v");
push(@args, @input);

unshift(@args, "rc.exe");
printf("**** @args\n");

exit (system(@args) != 0);
3 changes: 2 additions & 1 deletion config.mak.uname
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ ifeq ($(uname_S),Windows)
# link.exe next to, and required by, cl.exe, we have to prepend this
# onto the existing $PATH.
#
SANE_TOOL_PATH ?= $(msvc_bin_dir_msys)
SANE_TOOL_PATH ?= $(msvc_bin_dir_msys):$(sdk_ver_bin_dir_msys)
HAVE_ALLOCA_H = YesPlease
NO_PREAD = YesPlease
NEEDS_CRYPTO_WITH_SSL = YesPlease
Expand Down Expand Up @@ -508,6 +508,7 @@ endif
# See https://msdn.microsoft.com/en-us/library/ms235330.aspx
EXTLIBS = user32.lib advapi32.lib shell32.lib wininet.lib ws2_32.lib invalidcontinue.obj kernel32.lib ntdll.lib
PTHREAD_LIBS =
RC = compat/vcbuild/scripts/rc.pl
lib =
BASIC_CFLAGS += $(vcpkg_inc) $(sdk_includes) $(msvc_includes)
ifndef DEBUG
Expand Down

0 comments on commit 96c1f69

Please sign in to comment.