Skip to content

Commit c5328f9

Browse files
committed
Avoid the need to set MINGW32 or MINGW64 environment variables when using a standard MSYS environment on Windows.
1 parent aa3dc30 commit c5328f9

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

.github/workflows/ci-windows.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ jobs:
3131
os: windows-latest
3232
msys: MINGW64
3333
slug: mingw-w64-x86_64
34-
root: "/mingw64"
3534
cc: gcc
3635
cxx: g++
3736
subtarget: mame
@@ -40,7 +39,6 @@ jobs:
4039
os: windows-latest
4140
msys: MINGW64
4241
slug: mingw-w64-x86_64
43-
root: "/mingw64"
4442
cc: clang
4543
cxx: clang++
4644
subtarget: tiny
@@ -50,7 +48,6 @@ jobs:
5048
msys: CLANGARM64
5149
slug: mingw-w64-clang-aarch64
5250
extrapkg: mingw-w64-clang-aarch64-gcc-compat
53-
root: "/clangarm64"
5451
cc: clang
5552
cxx: clang++
5653
subtarget: mame
@@ -69,7 +66,6 @@ jobs:
6966
fetch-depth: 0
7067
- name: Build
7168
env:
72-
MINGW64: ${{ matrix.root }}
7369
OVERRIDE_AR: "llvm-ar"
7470
OVERRIDE_CC: ${{ matrix.cc }}
7571
OVERRIDE_CXX: ${{ matrix.cxx }}

docs/source/initialsetup/compilingmame.rst

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,8 @@ with MSYS2 and the **pacman** package manager.
150150
* To generate API documentation from source, you’ll need ``doxygen``.
151151
* If you plan to rebuild bgfx shaders and you want to rebuild the GLSL parser,
152152
you’ll need ``bison``.
153-
* For 64-bit builds, open **MSYS2 MinGW 64-bit** from the start menu, and set
154-
up the environment variables ``MINGW64`` to ``/mingw64`` and ``MINGW32`` to an
155-
empty string (e.g. using the command **export MINGW64=/mingw64 MINGW32=** in
156-
the Bash shell).
157-
* For 32-bit builds, open **MSYS2 MinGW 32-bit** from the start menu, and set
158-
up the environment variables ``MINGW32`` to ``/mingw32`` and ``MINGW64`` to an
159-
empty string (e.g. using the command **export MINGW32=/mingw32 MINGW64=** in
160-
the Bash shell).
153+
* For 64-bit builds, open **MSYS2 MinGW 64-bit** from the start menu.
154+
* For 32-bit builds, open **MSYS2 MinGW 32-bit** from the start menu.
161155

162156
For example you could use these commands to ensure you have the packages you
163157
need to compile MAME, omitting the ones for configurations you don’t plan to

makefile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,28 @@ $(error Unable to detect OS from uname -a: $(UNAME))
234234
endif
235235
endif
236236

237-
MINGW:=
237+
ifdef MSYSTEM
238+
MINGW := $(MINGW_PREFIX)
239+
ifeq ($(MSYSTEM),MINGW32)
240+
MINGW32 := $(MINGW_PREFIX)
241+
endif
242+
ifeq ($(MSYSTEM),MINGW64)
243+
MINGW64 := $(MINGW_PREFIX)
244+
endif
245+
ifeq ($(MSYSTEM),CLANGARM64)
246+
MINGW64 := $(MINGW_PREFIX)
247+
endif
248+
ifndef TOOLCHAIN
249+
TOOLCHAIN := $(MINGW_PREFIX)/bin/
250+
endif
251+
else # MSYSTEM
252+
MINGW :=
238253
ifdef MINGW64
239254
MINGW := $(MINGW64)
240-
else
255+
else # MINGW64
241256
MINGW := $(MINGW32)
242-
endif
257+
endif # MINGW64
258+
endif # MSYSTEM
243259

244260
#-------------------------------------------------
245261
# specify core target: mame, ldplayer

scripts/toolchain.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ function toolchain(_buildDir, _subDir)
163163
end
164164

165165
if "mingw32-gcc" == _OPTIONS["gcc"] then
166-
if not os.getenv("MINGW32") then
167-
print("Set MINGW32 envrionment variable.")
168-
end
169166
if toolchainPrefix == nil or toolchainPrefix == "" then
167+
if not os.getenv("MINGW32") then
168+
print("Set MINGW32 envrionment variable.")
169+
end
170170
toolchainPrefix = "$(MINGW32)/bin/i686-w64-mingw32-"
171171
end
172172
premake.gcc.cc = toolchainPrefix .. "gcc"
@@ -176,10 +176,10 @@ function toolchain(_buildDir, _subDir)
176176
end
177177

178178
if "mingw64-gcc" == _OPTIONS["gcc"] then
179-
if not os.getenv("MINGW64") then
180-
print("Set MINGW64 envrionment variable.")
181-
end
182179
if toolchainPrefix == nil or toolchainPrefix == "" then
180+
if not os.getenv("MINGW64") then
181+
print("Set MINGW64 envrionment variable.")
182+
end
183183
toolchainPrefix = "$(MINGW64)/bin/x86_64-w64-mingw32-"
184184
end
185185
premake.gcc.cc = toolchainPrefix .. "gcc"

0 commit comments

Comments
 (0)