Added support for windows MinGW build (#800)

This commit is contained in:
Denis Kopyrin
2024-07-02 09:45:36 +08:00
committed by GitHub
parent 92822c6412
commit 252a900b91
8 changed files with 61 additions and 59 deletions

View File

@@ -177,9 +177,15 @@ def main():
# presence of the correct roms automatically
# Make sure tools exist
subprocess.check_call(
["make", "-s", "-C", "tools/", "n64graphics", "skyconv", "mio0", "aifc_decode"]
)
tools = [ "n64graphics", "skyconv", "mio0", "aifc_decode" ]
if os.name == 'nt':
tools = [tool + ".exe" for tool in tools]
make = "mingw32-make"
else:
make = "make"
cmd = [make, "-s", "-C", "tools/"] + tools
subprocess.check_call(cmd)
# Go through the assets in roughly alphabetical order (but assets in the same
# mio0 file still go together).

16
sm64.ld
View File

@@ -175,9 +175,9 @@ SECTIONS
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.text*);
#endif
*/ULTRALIB.a:*.o(.text*);
*ULTRALIB.a:*.o(.text*);
*/libnustd.a:*.o(.text*);
*/libgcc.a:*.o(.text*);
*libgcc.a:*.o(.text*);
*/libz.a:*.o(.text*);
*/libhvqm2.a:*.o(.text*);
lib/rspboot.o(.text*);
@@ -197,7 +197,7 @@ SECTIONS
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.*data*);
#endif
*/ULTRALIB.a:*.o(.data*);
*ULTRALIB.a:*.o(.data*);
*/libhvqm2.a:*.o(.data*);
*/libz.a:*.o(.data*);
#include "rspdata.inc.ld"
@@ -215,8 +215,8 @@ SECTIONS
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.rodata*);
#endif
*/ULTRALIB.a:*.o(.rodata*);
*/libgcc.a:*.o(.rodata*);
*ULTRALIB.a:*.o(.rodata*);
*libgcc.a:*.o(.rodata*);
*/libz.a:*.o(.rodata*);
lib/PR/hvqm/hvqm2sp1.o(.rodata*);
@@ -234,9 +234,9 @@ SECTIONS
#ifdef LIBPL
BUILD_DIR/lib/libpl*.o(.*bss*);
#endif
*/ULTRALIB.a:*.o(COMMON);
*/ULTRALIB.a:*.o(.scommon);
*/ULTRALIB.a:*.o(.*bss*);
*ULTRALIB.a:*.o(COMMON);
*ULTRALIB.a:*.o(.scommon);
*ULTRALIB.a:*.o(.*bss*);
*/libhvqm2.a:*.o(.bss*);
*/libz.a:*.o(.bss*);
. = ALIGN(0x8);

View File

@@ -109,30 +109,6 @@ public:
#define flipsversion "Floating IPS"
#if defined(FLIPS_WINDOWS)
#define UNICODE
#define _WIN32_WINNT 0x0501
#define _WIN32_IE 0x0600
#define NOMINMAX // this seems automatically on in C++ - crazy.
#ifdef __MINGW32__
#include <stdlib.h>
#undef __USE_MINGW_ANSI_STDIO // must remove this, to avoid a libgcc_s_sjlj-1.dll dependency on 32bit
#endif // comments say libstdc++ demands a POSIX printf, but I'm not using that, so I don't care
#include <windows.h>
#include <windowsx.h>
#include <shlobj.h>
#include <wchar.h>
#include <stdio.h>
#include <commctrl.h>
#include <ctype.h>
#define wcsicmp _wcsicmp // wcsicmp deprecated? okay, have a define
#define wcsdup _wcsdup
#define wtoi _wtoi
#else
#include <string.h>
#include <strings.h>
#include <stdlib.h>
@@ -190,7 +166,6 @@ static inline char* strdup(const char * in)
memcpy(ret, in, len+1);
return ret;
}
#endif
#ifndef __cplusplus
@@ -341,11 +316,7 @@ void bpsdeltaEnd();
int GUIShow(LPCWSTR filename);
void GUILoadConfig();
//LPCWSTR GUIGetFileFor(uint32_t crc32); // use FindRomForPatch instead
#ifdef FLIPS_WINDOWS
void GUIClaimConsole();
#else
#define GUIClaimConsole() // all other platforms have consoles already
#endif
#define GUIClaimConsole()
//the OS port is responsible for main()
//Module name: crc32

View File

@@ -10,6 +10,14 @@ LDFLAGS := -lm
ALL_PROGRAMS := armips filesizer rncpack n64graphics n64graphics_ci mio0 slienc n64cksum textconv aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv flips
LIBAUDIOFILE := audiofile/libaudiofile.a
ifeq ($(OS),Windows_NT)
EXT := .exe
OUTPUTS := $(ALL_PROGRAMS:=.exe)
else
EXT :=
OUTPUTS := $(ALL_PROGRAMS)
endif
# Only build armips from tools if it is not found on the system
ifeq ($(call find-command,armips),)
BUILD_PROGRAMS := $(ALL_PROGRAMS)
@@ -43,7 +51,7 @@ aifc_decode_SOURCES := aifc_decode.c
aiff_extract_codebook_SOURCES := aiff_extract_codebook.c
tabledesign: $(LIBAUDIOFILE)
tabledesign$(EXT): $(LIBAUDIOFILE)
tabledesign_SOURCES := sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/tabledesign.c
tabledesign_CFLAGS := -Iaudiofile -Wno-uninitialized
tabledesign_LDFLAGS := -Laudiofile -laudiofile -lstdc++
@@ -56,22 +64,30 @@ extract_data_for_mio_SOURCES := extract_data_for_mio.c
skyconv_SOURCES := skyconv.c n64graphics.c utils.c
skyconv_CFLAGS := -g -I../include
armips: CC := $(CXX)
armips$(EXT): CC := $(CXX)
armips_SOURCES := armips.cpp
armips_CFLAGS := -std=c++11 -fno-exceptions -fno-rtti -pipe
armips_CFLAGS := -std=gnu++11 -fno-exceptions -fno-rtti -pipe
armips_LDFLAGS := -pthread
ifeq ($(HOST_ENV),MinGW)
armips_LDFLAGS += -municode
endif
flips: CC := $(CXX)
flips$(EXT): CC := $(CXX)
flips_SOURCES := FlipsSrc/Flips.cpp
ifeq ($(OS),Windows_NT)
flips_CFLAGS := -Wall -Wextra -fopenmp -Os -flto -fuse-linker-plugin -fomit-frame-pointer -fmerge-all-constants \
-fvisibility=hidden -fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables \
-ffunction-sections -fdata-sections -Wl,--gc-sections
else
flips_CFLAGS := -Wall -Wextra -fopenmp -Os -flto -fuse-linker-plugin -fomit-frame-pointer -fmerge-all-constants \
-fvisibility=hidden -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables \
-ffunction-sections -fdata-sections -Wl,--gc-sections \
-fvisibility=hidden -fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables \
-ffunction-sections -fdata-sections -Wl,--gc-sections \
-Wl,-z,relro,-z,now,--as-needed,--hash-style=gnu,--relax
endif
all-except-recomp: $(LIBAUDIOFILE) $(BUILD_PROGRAMS)
all-except-recomp: $(LIBAUDIOFILE) $(OUTPUTS)
all: all-except-recomp
@@ -83,8 +99,8 @@ clean:
distclean: clean
define COMPILE
$(1): $($1_SOURCES)
$$(CC) $(CFLAGS) $($1_CFLAGS) $$^ -o $$@ $($1_LDFLAGS) $(LDFLAGS)
$(1)$$(EXT): $($1_SOURCES)
$$(CC) $(CFLAGS) $($1_CFLAGS) $$^ -o $(1) $($1_LDFLAGS) $(LDFLAGS)
endef
$(foreach p,$(BUILD_PROGRAMS),$(eval $(call COMPILE,$(p))))

View File

@@ -15496,7 +15496,7 @@ int64_t fileSize(const std::wstring& fileName)
{
#ifdef _WIN32
WIN32_FILE_ATTRIBUTE_DATA attr;
if (!GetFileAttributesEx(fileName.c_str(),GetFileExInfoStandard,&attr)
if (!GetFileAttributesExW(fileName.c_str(),GetFileExInfoStandard,&attr)
|| (attr.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
return 0;
return ((int64_t) attr.nFileSizeHigh << 32) | (int64_t) attr.nFileSizeLow;
@@ -15514,10 +15514,10 @@ bool fileExists(const std::wstring& strFilename)
{
#ifdef _WIN32
#ifdef ARMIPS_WINDOWS_UWP
return GetFileAttributes(strFilename.c_str()) != INVALID_FILE_ATTRIBUTES;
return GetFileAttributesW(strFilename.c_str()) != INVALID_FILE_ATTRIBUTES;
#else
int OldMode = SetErrorMode(SEM_FAILCRITICALERRORS);
bool success = GetFileAttributes(strFilename.c_str()) != INVALID_FILE_ATTRIBUTES;
bool success = GetFileAttributesW(strFilename.c_str()) != INVALID_FILE_ATTRIBUTES;
SetErrorMode(OldMode);
return success;
#endif
@@ -19877,8 +19877,6 @@ int wmain(int argc, wchar_t* argv[])
return runFromCommandLine(arguments);
}
#ifndef _WIN32
int main(int argc, char* argv[])
{
// convert input to wstring
@@ -19901,6 +19899,3 @@ int main(int argc, char* argv[])
delete[] wargv;
return result;
}
#endif

View File

@@ -1,4 +1,17 @@
#include <byteswap.h>
#ifndef _WIN32
#include <byteswap.h>
#else
#define __bswap_constant_32(x) \
((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
(((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
static __inline unsigned int
__bswap_32 (unsigned int __bsx)
{
return __bswap_constant_32 (__bsx);
}
#endif
#include <stdlib.h>
#include <string.h>
#include <stdint.h>

View File

@@ -45,7 +45,7 @@ lightStructs = {}
# FIRST PASS: COLLECT LIGHT STRUCT INFO, REMOVE LIGHT STRUCTS
for file in lightFiles:
changed = False
with open(file, "r") as f:
with open(file, "r", encoding='utf-8') as f:
fileLines = f.readlines()
index = 0
@@ -96,7 +96,7 @@ def index_delta(mat_name, orig_index, delta):
# SECOND PASS - CHANGE LIGHT COMMANDS
for file in lightFiles:
changed = False
with open(file, "r") as f:
with open(file, "r", encoding='utf-8') as f:
fileLines = f.readlines()
index = 0
dl_index = -1

View File

@@ -21,6 +21,7 @@
#define SCALE_3_8(VAL_) ((VAL_) * 0x24)
#define SCALE_8_3(VAL_) ((VAL_) / 0x24)
#define bcopy(s1, s2, n) memcpy((s2), (s1), (n))
typedef struct
{