Skip to content

Commit

Permalink
Implement Win 9x platform and msvc compilers.
Browse files Browse the repository at this point in the history
  • Loading branch information
OmniBlade committed Jul 6, 2023
1 parent 3910797 commit adc182a
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 1 deletion.
5 changes: 5 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ RUN apt-get -y update && apt-get install -y \
binutils-powerpc-linux-gnu \
binutils-aarch64-linux-gnu \
binutils-sh-elf \
binutils-djgpp \
curl \
gcc-mips-linux-gnu \
git \
Expand All @@ -63,9 +64,11 @@ ARG ENABLE_PS1_SUPPORT
ARG ENABLE_WII_GC_SUPPORT
ARG ENABLE_SATURN_SUPPORT
ARG ENABLE_MSDOS_SUPPORT
ARG ENABLE_WIN9X_SUPPORT
RUN if [ "${ENABLE_NDS_SUPPORT}" = "YES" ] || \
[ "${ENABLE_PS1_SUPPORT}" = "YES" ] || \
[ "${ENABLE_MSDOS_SUPPORT}" = "YES" ] || \
[ "${ENABLE_WIN9X_SUPPORT}" = "YES" ] || \
[ "${ENABLE_WII_GC_SUPPORT}" = "YES" ]; then \
dpkg --add-architecture i386 && apt-get update && \
apt-get install -y -o APT::Immediate-Configure=false \
Expand Down Expand Up @@ -104,6 +107,7 @@ ENV ENABLE_PS1_SUPPORT=${ENABLE_PS1_SUPPORT}
ENV ENABLE_SWITCH_SUPPORT=${ENABLE_SWITCH_SUPPORT}
ENV ENABLE_SATURN_SUPPORT=${ENABLE_SATURN_SUPPORT}
ENV ENABLE_MSDOS_SUPPORT=${ENABLE_MSDOS_SUPPORT}
ENV ENABLE_WIN9X_SUPPORT=${ENABLE_WIN9X_SUPPORT}

RUN python3.10 -m pip install requests tqdm \
&& python3.10 /compilers/download.py \
Expand All @@ -129,6 +133,7 @@ USER user
RUN if [ "${ENABLE_PS1_SUPPORT}" = "YES" ] || \
[ "${ENABLE_WII_GC_SUPPORT}" = "YES" ] || \
[ "${ENABLE_MSDOS_SUPPORT}" = "YES" ] || \
[ "${ENABLE_WIN9X_SUPPORT}" = "YES" ] || \
[ "${ENABLE_NDS_SUPPORT}" = "YES" ]; then \
wineboot --init; \
fi
Expand Down
20 changes: 20 additions & 0 deletions backend/compilers/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,24 @@ def download_dos():
exe_path.chmod(exe_path.stat().st_mode | stat.S_IEXEC)


def download_win9x():
for compiler in [
"msvc6.0",
"msvc6.3",
"msvc6.4",
"msvc6.5",
"msvc6.5pp",
"msvc6.6",
"msvc7.0",
]:
url = (
"https://github.com/OmniBlade/decomp.me/releases/download/msvcwin9x/"
+ compiler
+ ".tar.gz"
)
download_tar(url=url, dest_name=compiler)


def main(args):
def should_download(platform):
# assume enabled unless explicitly disabled
Expand Down Expand Up @@ -946,6 +964,8 @@ def should_download(platform):
download_3ds()
if should_download("msdos"):
download_dos()
if should_download("win9x"):
download_win9x()

print("Compilers finished downloading!")

Expand Down
58 changes: 58 additions & 0 deletions backend/coreapp/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
COMMON_IDO_FLAGS,
COMMON_MWCC_FLAGS,
COMMON_GCC_SATURN_FLAGS,
COMMON_MSVC_FLAGS,
COMMON_WATCOM_FLAGS,
Flags,
Language,
Expand All @@ -36,6 +37,7 @@
PS2,
SWITCH,
SATURN,
WIN9X,
)

import platform as platform_stdlib
Expand Down Expand Up @@ -136,6 +138,11 @@ class MWCCCompiler(Compiler):
flags: ClassVar[Flags] = COMMON_MWCC_FLAGS


@dataclass(frozen=True)
class MSVCCompiler(Compiler):
flags: ClassVar[Flags] = COMMON_MSVC_FLAGS


@dataclass(frozen=True)
class WatcomCompiler(Compiler):
flags: ClassVar[Flags] = COMMON_WATCOM_FLAGS
Expand Down Expand Up @@ -953,6 +960,49 @@ def preset_from_name(name: str) -> Optional[Preset]:
cc=MWCCARM_CC,
)

CL_WIN = '${WINE} "${COMPILER_DIR}"/Bin/CL.EXE /c /nologo /IZ:"${COMPILER_DIR}"/Include/ ${COMPILER_FLAGS} /Fo"Z:${OUTPUT}" "Z:${INPUT}"'

MSVC60 = MSVCCompiler(
id="msvc6.0",
platform=WIN9X,
cc=CL_WIN,
)

MSVC63 = MSVCCompiler(
id="msvc6.3",
platform=WIN9X,
cc=CL_WIN,
)

MSVC64 = MSVCCompiler(
id="msvc6.4",
platform=WIN9X,
cc=CL_WIN,
)

MSVC65 = MSVCCompiler(
id="msvc6.5",
platform=WIN9X,
cc=CL_WIN,
)

MSVC65PP = MSVCCompiler(
id="msvc6.5pp",
platform=WIN9X,
cc=CL_WIN,
)

MSVC66 = MSVCCompiler(
id="msvc6.6",
platform=WIN9X,
cc=CL_WIN,
)

MSVC70 = MSVCCompiler(
id="msvc7.0",
platform=WIN9X,
cc=CL_WIN,
)
# Watcom doesn't like '/' in paths passed to it so we need to replace them.
WATCOM_ARGS = ' -zq -i="Z:${COMPILER_DIR}/h" -i="Z:${COMPILER_DIR}/h/nt" ${COMPILER_FLAGS} -fo"Z:${OUTPUT}" "Z:${INPUT}"'
WATCOM_CC = (
Expand Down Expand Up @@ -1150,6 +1200,14 @@ def preset_from_name(name: str) -> Optional[Preset]:
XCODE_GCC400_C,
XCODE_GCC400_CPP,
PBX_GCC3,
# WIN9X
MSVC60,
MSVC63,
MSVC64,
MSVC65,
MSVC65PP,
MSVC66,
MSVC70,
# Watcom, DOS and Win9x
WATCOM_105_C,
WATCOM_105_CPP,
Expand Down
15 changes: 15 additions & 0 deletions backend/coreapp/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ def to_json(self) -> Dict[str, Union[str, List[str]]]:
FlagSet(id="gcc_arch", flags=["-m2"]),
]

COMMON_MSVC_FLAGS: Flags = [
FlagSet(
id="msvc_opt_level", flags=["/Od", "/O1", "/O2", "/Os", "/Ot", "/Og", "/Ox"]
),
FlagSet(id="msvc_codegen", flags=["/GB", "/G3", "/G4", "/G5", "/G6"]),
Checkbox("msvc_compile_cpp", "/TP"),
Checkbox("msvc_use_rtti", "/GR"),
Checkbox("msvc_use_ehsc", "/GX"),
Checkbox("msvc_disable_stack_checking", "/Gs"),
Checkbox("msvc_runtime_debug_checks", "/GZ"),
Checkbox("msvc_cdecl", "/Gd"),
Checkbox("msvc_fastcall", "/Gr"),
Checkbox("msvc_stdcall", "/Gz"),
]

COMMON_WATCOM_FLAGS: Flags = [
FlagSet(
id="watcom_codegen",
Expand Down
12 changes: 12 additions & 0 deletions backend/coreapp/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ def from_id(platform_id: str) -> Platform:
""",
)

WIN9X = Platform(
id="win9x",
name="Windows 9x",
description="x86 (32bit)",
arch="i686",
assemble_cmd='i386-pc-msdosdjgpp-as --32 -o "$OUTPUT" "$INPUT"',
objdump_cmd="i386-pc-msdosdjgpp-objdump",
nm_cmd="i386-pc-msdosdjgpp-nm",
asm_prelude="",
)

SWITCH = Platform(
id="switch",
name="Nintendo Switch",
Expand Down Expand Up @@ -742,5 +753,6 @@ def from_id(platform_id: str) -> Platform:
"macosx": MACOSX,
"msdos": MSDOS,
"n3ds": N3DS,
"win9x": WIN9X,
}
)
4 changes: 3 additions & 1 deletion backend/coreapp/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ def sandbox_command(self, mounts: List[Path], env: Dict[str, str]) -> List[str]:
"--rlimit_fsize", "soft",
"--rlimit_nofile", "soft",
# the following are settings that can be removed once we are done with wine
"--bindmount_ro", f"{settings.WINEPREFIX}:/wine",
"--bindmount", f"{settings.WINEPREFIX}:/wine",
# This would be better but doesn't work?
# "--bindmount", f"{self.path}:/wine/drive_c/users/{os.getlogin()}/TEMP",
"--env", "WINEDEBUG=-all",
"--env", "WINEPREFIX=/wine",
]
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ services:
ENABLE_PS1_SUPPORT: "NO"
ENABLE_WII_GC_SUPPORT: "NO"
ENABLE_MSDOS_SUPPORT: "NO"
ENABLE_WIN9X_SUPPORT: "NO"
# dont install clang by default
ENABLE_SWITCH_SUPPORT: "NO"
ENABLE_SATURN_SUPPORT: "NO"
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/PlatformSelect/PlatformIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import LogoPS2 from "./ps2.svg"
import LogoSaturn from "./saturn.svg"
import LogoSwitch from "./switch.svg"
import UnknownIcon from "./unknown.svg"
import LogoWin9x from "./win9x.svg"

/** In release-date order */
const ICONS = {
"msdos": LogoMSDOS,
"irix": LogoIRIX,
"win9x": LogoWin9x,
"macos9": LogoMacOS,
"macosx": LogoMacOSX,
"n64": LogoN64,
Expand Down
Loading

0 comments on commit adc182a

Please sign in to comment.