Skip to content

Commit

Permalink
update to current upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Nov 29, 2024
1 parent 516c796 commit a55c20d
Show file tree
Hide file tree
Showing 23 changed files with 221 additions and 67 deletions.
2 changes: 0 additions & 2 deletions msvc/.gitignore

This file was deleted.

16 changes: 7 additions & 9 deletions msvc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

LABEL org.opencontainers.image.source https://github.com/DFHack/build-env

Expand All @@ -7,29 +7,27 @@ ARG BUILDER_UID=1001
# install dependencies and initialize the wine environment for root
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y wine64-development python3 msitools python3-simplejson python3-six ca-certificates \
&& apt-get install -y wine64 python3 msitools ca-certificates \
&& apt-get install -y git gcc-10 g++-10 ninja-build libxml-libxslt-perl make libssl-dev \
&& apt-get install -y dh-autoreconf libcurl4-gnutls-dev libexpat1-dev gettext libz-dev \
&& apt-get install -y wget curl unzip python3-pip \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install --compile sphinx \
&& pip3 install six \
&& useradd --uid $BUILDER_UID --create-home --shell /bin/bash buildmaster \
&& WINEDLLOVERRIDES="mscoree,mshtml=" wine64 wineboot --init \
&& while pgrep wineserver >/dev/null; do sleep 1; done
&& $(command -v wine64 || command -v wine || false) wineboot --init \
&& while pgrep wineserver > /dev/null; do sleep 1; done

# set up msvc
WORKDIR /opt/msvc
COPY lowercase fixinclude install.sh vsdownload.py msvctricks.cpp ./
COPY wrappers/* ./wrappers/

# This removes the arm and x86 bits to save space (around 5.5G)
RUN PYTHONUNBUFFERED=1 ./vsdownload.py --accept-license --dest /opt/msvc \
&& ./install.sh /opt/msvc \
&& rm lowercase fixinclude install.sh vsdownload.py \
&& rm -rf wrappers \
&& find /opt/msvc -depth -type d -iregex '.*/.*arm[0-9]*$' -exec rm -fr {} \; \
&& find /opt/msvc -depth -type d -iregex '.*/.*x86$' -exec rm -fr {} \;
&& rm -rf wrappers

COPY msvcenv-native.sh /opt/msvc

Expand Down Expand Up @@ -70,7 +68,7 @@ RUN mkdir /home/buildmaster/dfhack-native \
&& mv dfhack-native-bin dfhack-native

# set up wine and ccache for the buildmaster user
RUN WINEDLLOVERRIDES="mscoree,mshtml=" wine64 wineboot --init \
RUN $(command -v wine64 || command -v wine || false) wineboot --init \
&& wineserver -w \
&& ccache -C

Expand Down
4 changes: 2 additions & 2 deletions msvc/wrappers/armasm
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/armasm.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/armasm.exe "$@"
4 changes: 2 additions & 2 deletions msvc/wrappers/armasm64
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/armasm64.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/armasm64.exe "$@"
8 changes: 5 additions & 3 deletions msvc/wrappers/cl
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
. "$(dirname "$0")"/msvcenv.sh

# /showIncludes
unixify_path='/^Note: including file: /{ s/z:([\\/])/\1/i; s,\\,/,g; }'
# /E
unixify_line='/^[[:blank:]]*#[[:blank:]]*line[[:blank:]]/{ s/z:([\\/])/\1/i; s,\\\\,/,g; }'
# Warnings and Errors
unixify_note='/^[zZ]:.*\([[:digit:]]+\): (note|error C[[:digit:]]{4}|warning C[[:digit:]]{4}): /{ s/z:([\\/])/\1/ig; s,\\,/,g; }'

export WINE_MSVC_STDOUT_SED="$unixify_path;$unixify_line"
export WINE_MSVC_STDOUT_SED="$unixify_path;$unixify_line;$unixify_note"
export WINE_MSVC_STDERR_SED="$unixify_path"

$(dirname $0)/wine-msvc.sh $BINDIR/cl.exe "$@"
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/cl.exe "$@"

ec=$?
[ $ec -ne 0 ] && exit $ec
Expand Down
4 changes: 2 additions & 2 deletions msvc/wrappers/dumpbin
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
. "$(dirname "$0")"/msvcenv.sh

# /PDBPATH
unixify_path='/^(Dump of file | PDB file found at )/{ s/z:([\\/])/\1/i; s,\\,/,g; }'

export WINE_MSVC_STDOUT_SED="$unixify_path"

$(dirname $0)/wine-msvc.sh $BINDIR/dumpbin.exe "$@"
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/dumpbin.exe "$@"
17 changes: 17 additions & 0 deletions msvc/wrappers/findstr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
#
# Copyright (c) 2024 Huang Qinjin
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

exec grep "$@"
1 change: 1 addition & 0 deletions msvc/wrappers/findstr.exe
4 changes: 2 additions & 2 deletions msvc/wrappers/lib
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/lib.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/lib.exe "$@"
4 changes: 2 additions & 2 deletions msvc/wrappers/link
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/link.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/link.exe "$@"
18 changes: 18 additions & 0 deletions msvc/wrappers/mc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
#
# Copyright (c) 2018 Martin Storsjo
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$SDKBINDIR"/mc.exe "$@"
1 change: 1 addition & 0 deletions msvc/wrappers/mc.exe
18 changes: 18 additions & 0 deletions msvc/wrappers/midl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
#
# Copyright (c) 2018 Martin Storsjo
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$SDKBINDIR"/midl.exe "$@"
1 change: 1 addition & 0 deletions msvc/wrappers/midl.exe
4 changes: 2 additions & 2 deletions msvc/wrappers/ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/ml.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/ml.exe "$@"
4 changes: 2 additions & 2 deletions msvc/wrappers/ml64
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/ml64.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/ml64.exe "$@"
96 changes: 96 additions & 0 deletions msvc/wrappers/msbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash
#
# Copyright (c) 2024 Sergey Kvachonok
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. "$(dirname "$0")"/msvcenv.sh

# By default, the platform-specific settings for the current project override
# the PATH, INCLUDE, LIB, LIBPATH, CONFIGURATION, and PLATFORM environment
# variables. Set the 'UseEnv' property to true to guarantee that the environment
# variables don't get overridden.
#
# https://learn.microsoft.com/en-us/cpp/build/reference/msbuild-visual-cpp-overview?view=msvc-170#useenv-property
#export UseEnv=true

# Do not try to find the VC and Windows SDK install paths in the Registry.
export DisableRegistryUse=true

# Set these MSBuild properties using environment variables so that MSVC project
# builds work the same with both `UseEnv=true` and `UseEnv=false`.
#
# These properties are used in various .props files found in `MSBuild/Microsoft/VC/v170`.
export VCToolsVersion="$MSVCVER"
export VCInstallDir_170="${MSVCBASE}\\"
export VCToolsInstallDir_170="${MSVCDIR}\\"

export MicrosoftKitRoot="${BASE}\\"
export SDKReferenceDirectoryRoot="$MicrosoftKitRoot"
export SDKExtensionDirectoryRoot="$MicrosoftKitRoot"

# These environment variables are used by the native API
# `[Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion()`.
# See https://learn.microsoft.com/en-us/dotnet/api/microsoft.build.utilities.toollocationhelper.getlatestsdktargetplatformversion?view=msbuild-17-netcore
export MSBUILDSDKREFERENCEDIRECTORY="$MicrosoftKitRoot"
export MSBUILDMULTIPLATFORMSDKREFERENCEDIRECTORY="$MicrosoftKitRoot"

# Set these manually because the above kit search does not always work.
export WindowsSdkDir_10="${SDKBASE}\\"
export UniversalCRTSdkDir_10="$WindowsSdkDir_10"
export WindowsSdkDir="$WindowsSdkDir_10"
export UniversalCRTSdkDir="$UniversalCRTSdkDir_10"
export WindowsTargetPlatformVersion="$SDKVER"
export UCRTContentRoot="$UniversalCRTSdkDir_10"
# These should point to the NETFX SDK, which may or may not be located
# in the common Windows SDK directory.
export NETFXKitsDir="$WindowsSdkDir"
export NETFXSDKDir="$WindowsSdkDir"

# WDK-specific properties:
export WDKKitVersion="10"
# No spectre-mitigated libraries in this SDK.
export Driver_SpectreMitigation=false
# Driver signing does not work with WINE crypto libraries.
export SignMode=off
export Inf2CatNoCatalog=true
# API Validator crashes in WINE.
export ApiValidator_Enable=False

# Set MSBuild-specific Platform property via an environment variable.
# 'Platform' property names do not match ARCH names exactly.
#
# https://learn.microsoft.com/en-us/cpp/build/reference/msbuild-visual-cpp-overview?view=msvc-170#support-file-directories
# https://learn.microsoft.com/en-us/cpp/build/reference/vcxproj-file-structure?view=msvc-170#projectconfiguration-elements
case ${ARCH} in
x86)
export Platform=Win32
;;
arm)
export Platform=ARM
;;
arm64)
export Platform=ARM64
;;
*)
export Platform=${ARCH}
;;
esac

if [[ "${MSBUILDBINDIR}" == *amd64 ]]; then
# Prefer x86_64 build tools for any target arch.
export PreferredToolArchitecture=x64
fi

export WINE_MSVC_RAW_STDOUT=1
"$(dirname "$0")"/wine-msvc.sh "${MSBUILDBINDIR}"/MSBuild.exe "$@"
1 change: 1 addition & 0 deletions msvc/wrappers/msbuild.exe
13 changes: 8 additions & 5 deletions msvc/wrappers/msvcenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ BASE=z:${BASE_UNIX//\//\\}
MSVCVER=14.13.26128
SDKVER=10.0.16299.0
ARCH=x86
MSVCDIR="$BASE\\vc\\tools\\msvc\\$MSVCVER"
SDKINCLUDE="$BASE\\$SDK\\include\\$SDKVER"
SDKLIB="$BASE\\$SDK\\lib\\$SDKVER"
MSVCBASE="$BASE\\vc"
SDKBASE="$BASE\\$SDK"
MSVCDIR="$MSVCBASE\\tools\\msvc\\$MSVCVER"
SDKINCLUDE="$SDKBASE\\include\\$SDKVER"
SDKLIB="$SDKBASE\\lib\\$SDKVER"
BINDIR=$BASE_UNIX/vc/tools/msvc/$MSVCVER/bin/Hostx64/$ARCH
SDKBINDIR=$BASE_UNIX/$SDK_UNIX/bin/$SDKVER/x64
export INCLUDE="$MSVCDIR\\include;$SDKINCLUDE\\shared;$SDKINCLUDE\\ucrt;$SDKINCLUDE\\um;$SDKINCLUDE\\winrt"
export LIB="$MSVCDIR\\lib\\$ARCH;$SDKLIB\\ucrt\\$ARCH;$SDKLIB\\um\\$ARCH"
MSBUILDBINDIR=$BASE_UNIX/MSBuild/Current/Bin/amd64
export INCLUDE="$MSVCDIR\\atlmfc\\include;$MSVCDIR\\include;$SDKINCLUDE\\shared;$SDKINCLUDE\\ucrt;$SDKINCLUDE\\um;$SDKINCLUDE\\winrt;$SDKINCLUDE\\km"
export LIB="$MSVCDIR\\atlmfc\\lib\\$ARCH;$MSVCDIR\\lib\\$ARCH;$SDKLIB\\ucrt\\$ARCH;$SDKLIB\\um\\$ARCH;$SDKLIB\\km\\$ARCH"
export LIBPATH="$LIB"
# "$MSVCDIR\\bin\\Hostx64\\x64" is included in PATH for DLLs.
export WINEPATH="${BINDIR//\//\\};${SDKBINDIR//\//\\};$MSVCDIR\\bin\\Hostx64\\x64"
Expand Down
4 changes: 2 additions & 2 deletions msvc/wrappers/mt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $SDKBINDIR/mt.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$SDKBINDIR"/mt.exe "$@"
4 changes: 2 additions & 2 deletions msvc/wrappers/nmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $BINDIR/nmake.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$BINDIR"/nmake.exe "$@"
4 changes: 2 additions & 2 deletions msvc/wrappers/rc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

. $(dirname $0)/msvcenv.sh
$(dirname $0)/wine-msvc.sh $SDKBINDIR/rc.exe "$@"
. "$(dirname "$0")"/msvcenv.sh
"$(dirname "$0")"/wine-msvc.sh "$SDKBINDIR"/rc.exe "$@"
Loading

0 comments on commit a55c20d

Please sign in to comment.