Commit Graph

12 Commits

Author SHA1 Message Date
nhmall
b1cffe11f9 Cross-compiling on Windows 11 with Visual Studio
Cross-compiling NetHack with Visual Studio from an x64 platform to an ARM64
target presents some new build challenges.

In the current nethack.sln solution, the build attempts to execute the
several just-built tools during the build of various subprojects.

For example, when cross-compiling on a typical Windows 11 x64 machine
to build a target ARM64 Windows 11 package, the build process tries to
run the following just-built target tools:

(under a Debug build)
    "$(ToolsDir)\Debug\ARM64\uudecode.exe"
    "$(ToolsDir)\Debug\ARM64\makedefs.exe"
    "$(ToolsDir)\Debug\ARM64\tilemap.exe"
    "$(ToolsDir)\Debug\ARM64\tile2bmp.exe"
    "$(ToolsDir)\Debug\ARM64\dlb.exe"

(under a Release build)
    "$(ToolsDir)\Release\ARM64\uudecode.exe"
    "$(ToolsDir)\Release\ARM64\makedefs.exe"
    "$(ToolsDir)\Release\ARM64\tilemap.exe"
    "$(ToolsDir)\Release\ARM64\tile2bmp.exe"
    "$(ToolsDir)\Release\ARM64\dlb.exe"

Those fail to execute successfully on Intel x64 (or x86) since they
are actually ARM64 executables, and the build attempts to execute
them on the host Intel x64 hardware.

The situation is a little different if the cross-compile is carried out
on a Windows 11 ARM64 machine (such as SnapDragon).

On an ARM64 machine, the cross-compile to build a target Intel x64
Windows 11 package, tries to execute the following:

(under a Debug build)
    "$(ToolsDir)\Debug\x64\uudecode.exe"
    "$(ToolsDir)\Debug\x64\makedefs.exe"
    "$(ToolsDir)\Debug\x64\tilemap.exe"
    "$(ToolsDir)\Debug\x64\tile2bmp.exe"
    "$(ToolsDir)\Debug\x64\dlb.exe"

(under a Release build)
    "$(ToolsDir)\Release\x64\uudecode.exe"
    "$(ToolsDir)\Release\x64\makedefs.exe"
    "$(ToolsDir)\Release\x64\tilemap.exe"
    "$(ToolsDir)\Release\x64\tile2bmp.exe"
    "$(ToolsDir)\Release\x64\dlb.exe"

Those actual do succeed in executing on ARM64, because of the
"prism emulation" that is available on Windows 11 ARM64 operating
systems to allow x64 and x86 executables to run.

The following change adds some detection to build environment, leading
to the definition of a "HostTools" macro that leads to the native host
tools for those steps.

There is a catch:

It means that the native build of the interim tools for Windows 11 must
be executed prior to attempting a cross-compile build to a non-native
target. That ensures that the native x64 interim uudecode, makedefs,
tilemap, tile2bmp and dlb tools are available on the disk for use by
a subsequent cross-compile.

This change consistently switches to the use of the host-native
interim tools for uudecode, makedefs, tilemap, tile2bmp and dlb tools.

Technically, this change would not be strictly necessary on an
ARM64-hosted build that was targeting x64 or x86, because of the
available prism-emulation that allows ARM64, x64, and x86 images to
execute, but this maintains consistency of the build process on
either platform. It is also likely that the native host versions execute
more quickly than versions requiring the prism emulation, although
that isn't really a concern for a NetHack build.

The use of native host uudecode, makedefs, tilemap, tile2bmp and
dlb tools is done with the Unix-hosted cross-compiles to other
target platforms as well (on Linux or macOS).
2025-11-18 10:10:32 -05:00
nhmall
d7e4f2e2b1 Windows build support for Windows 11 arm64 (snapdragon) 2025-11-14 21:24:24 -05:00
nhmall
eb4496c575 vcxproj updates
define HAS_INTTYPES_H alongside HAS_STDINT_H in the visual studio projects
2025-11-13 09:11:49 -05:00
nhmall
d94f728a9f Windows visual studio: lualib as separate entity 2024-11-30 15:42:06 -05:00
nhmall
1d4aeb4f15 add some zip file packaging to visual studio proj 2024-03-31 20:37:56 -04:00
nhmall
5ee813091a remove specific Windows 10 sdk reference 2024-03-31 12:01:05 -04:00
nhmall
f71b0caecd visual studio project updates 2024-03-31 10:21:08 -04:00
nhmall
5e6e7c29b9 more visual studio project file updates 2024-03-07 19:11:56 -05:00
nhmall
f58c446aba visual studio project build updates 2024-03-07 17:02:17 -05:00
nhmall
11d83bbad3 retarget Visual Studio SDK 2023-03-02 22:06:14 -05:00
nhmall
aebf77ada1 update visual studio project files 2022-07-01 11:47:02 -04:00
nhmall
0a10bd632d change references from winnt to windows
rename sys/winnt to sys/windows
move vs (visual studio) folder out of win/win32 and into sys/windows
rename include/ntconf.h to include/windconf.h
rename winnt.c to windsys.c
place visual studio projects into individual subfolders.

This will hopefully resolve GitHub issue #484 as well.
2021-06-03 23:26:00 -04:00