Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 1e5a875

Browse files
authored
Merge pull request #1825 from reicast/einsteinx2/fix-macos-building
Fixed the Mac version!
2 parents 6650ac8 + c6ebf7d commit 1e5a875

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4076
-2663
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ Building for iOS / MacOS
8989
---
9090
Requirements:
9191

92+
Due to the use of OpenMP, which is not included with the default Xcode LLVM compiler, you must first install LLVM and OpenMP using the Homebrew package manager: `brew install libomp llvm`
93+
94+
[Install Homebrew](https://brew.sh/)
95+
9296
[Latest Xcode](https://developer.apple.com/xcode/downloads/)
9397

9498
* [iOSOpenDev](http://iosopendev.com/download/) if developing without an official Apple certificate
@@ -103,11 +107,11 @@ From project root directory:
103107

104108
| iOS | Mac |
105109
| --------------- | ----------------------------- |
106-
| `cd shell/ios/` | `cd shell/apple/emulator-osx` |
110+
| `cd reicast-emulator/reicast/apple/emulator-ios` | `cd reicast-emulator/reicast/apple/emulator-osx` |
107111

108112
`xcodebuild -configuration Release`
109113

110-
Or open the .xcodeproj in Xcode and hit "Build".
114+
Or open the workspace `reicast-emulator/reicast/apple/reicast.xcworkspace` in Xcode, choose the target, and press Command + B to build.
111115

112116
Building for Linux
113117
------------------

azure-pipelines.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
stages:
2+
- stage: Linux
3+
jobs:
4+
- job: Build
5+
pool:
6+
vmImage: ubuntu-16.04
7+
steps:
8+
- script: sudo dpkg --add-architecture i386 && sudo apt-get clean && sudo apt-get update && sudo apt-get install -y build-essential pkgconf libasound2-dev libgl1-mesa-dev libx11-dev libudev-dev git && sudo apt-get install -y libasound2-dev:i386 libgl1-mesa-dev:i386 libx11-dev:i386 libudev-dev:i386 libc6:i386 g++-multilib gcc-multilib && sudo apt-get install -y g++-mingw-w64-x86-64 mingw-w64-x86-64-dev libz-mingw-w64-dev libnpth-mingw-w64-dev
9+
displayName: Install dependencies
10+
- script: gcc --version && x86_64-w64-mingw32-gcc --version
11+
displayName: Display toolchain info
12+
- script: make -C reicast/linux -j `nproc` platform=x64
13+
displayName: Linux x64 build
14+
- script: make -C reicast/linux -j `nproc` platform=x64 NAOMI=1
15+
displayName: Linux naomi x64 build
16+
- script: make -C reicast/linux -j `nproc` platform=x86
17+
displayName: Linux x86 build
18+
- script: make -C reicast/linux -j `nproc` platform=win32 CC_PREFIX=x86_64-w64-mingw32-
19+
displayName: Windows x64 (MinGW) build
20+
- script: make -C reicast/linux -j `nproc` platform="x64 noexceptions"
21+
displayName: Linux x64 (No Exceptions) build
22+
- script: make -C reicast/linux -j `nproc` platform="x64 norwxpages"
23+
displayName: Linux x64 (No RWX pages) build
24+
25+
- stage: Mac
26+
jobs:
27+
- job: Build
28+
pool:
29+
vmImage: macOS-10.14
30+
steps:
31+
- script: brew install libomp llvm
32+
displayName: Brew install dependencies
33+
- script: |
34+
sudo xcode-select -s /Applications/Xcode_11.3.1.app/Contents/Developer
35+
cd reicast/apple/emulator-osx && xcodebuild -configuration Release
36+
displayName: Select Xcode and Build

libswirl/build.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@
325325
#endif
326326

327327
#ifndef FEAT_HAS_SERIAL_TTY
328-
#define FEAT_HAS_SERIAL_TTY (HOST_OS == OS_LINUX && !defined(_ANDROID))
328+
#define FEAT_HAS_SERIAL_TTY (HOST_OS == OS_LINUX && !defined(_ANDROID)) || (HOST_OS == OS_DARWIN && !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR)
329329
#endif
330330

331331
//Depricated build configs
@@ -460,4 +460,4 @@
460460
#define AICA_SDRAM_CLOCK (GD_CLOCK*2) //[67737600] GD-> PLL 2 -> SDRAM
461461
#define SH4_MAIN_CLOCK (200*1000*1000) //[200000000] XTal(13.5) -> PLL (33.3) -> PLL 1:6 (200)
462462
#define SH4_RAM_CLOCK (100*1000*1000) //[100000000] XTal(13.5) -> PLL (33.3) -> PLL 1:3 (100) , also suplied to HOLLY chip
463-
#define G2_BUS_CLOCK (25*1000*1000) //[25000000] from Holly, from SH4_RAM_CLOCK w/ 2 2:1 plls
463+
#define G2_BUS_CLOCK (25*1000*1000) //[25000000] from Holly, from SH4_RAM_CLOCK w/ 2 2:1 plls

libswirl/deps/zlib/zlib.xcodeproj/project.pbxproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
developmentRegion = English;
100100
hasScannedForEncodings = 0;
101101
knownRegions = (
102+
English,
102103
en,
103104
);
104105
mainGroup = 87D776C01EF5623200E08B55;
@@ -114,23 +115,19 @@
114115
87D776C21EF5623200E08B55 /* Debug */ = {
115116
isa = XCBuildConfiguration;
116117
buildSettings = {
117-
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
118118
COPY_PHASE_STRIP = NO;
119119
GCC_WARN_ABOUT_RETURN_TYPE = YES;
120120
GCC_WARN_UNUSED_VARIABLE = YES;
121121
ONLY_ACTIVE_ARCH = YES;
122-
SDKROOT = macosx10.6;
123122
};
124123
name = Debug;
125124
};
126125
87D776C31EF5623200E08B55 /* Release */ = {
127126
isa = XCBuildConfiguration;
128127
buildSettings = {
129-
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
130128
COPY_PHASE_STRIP = YES;
131129
GCC_WARN_ABOUT_RETURN_TYPE = YES;
132130
GCC_WARN_UNUSED_VARIABLE = YES;
133-
SDKROOT = macosx10.6;
134131
};
135132
name = Release;
136133
};

libswirl/gui/gui_settings_advanced.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,4 @@ void gui_settings_advanced()
108108
ImGui::PopStyleVar();
109109
ImGui::EndTabItem();
110110
}
111-
}
111+
}

libswirl/hw/sh4/modules/scif.cpp

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,24 @@ SCIF_SCFDR2_type SCIF_SCFDR2;
2222
#include <fcntl.h>
2323
#include <unistd.h>
2424
#include <sys/ioctl.h>
25+
#include <errno.h>
2526
extern int pty_master;
2627
#endif
2728

28-
int SerialHasPendingData() {
29-
int bytes_avaiable = 0;
30-
#if FEAT_HAS_SERIAL_TTY
31-
if (pty_master != -1) {
32-
ioctl(pty_master, FIONREAD, &bytes_avaiable);
33-
return bytes_avaiable;
34-
}
35-
#endif
36-
return bytes_avaiable;
37-
}
38-
39-
void SerialReadData(u8* buffer, size_t nbytes) {
40-
u8 rd = 0;
41-
#if FEAT_HAS_SERIAL_TTY
42-
if (pty_master != -1){
43-
while(read(pty_master, buffer, nbytes) != nbytes)
44-
printf("SERIAL: PTY read failed, %d\n", errno);
45-
}
46-
#endif
29+
int SerialReadData(u8* buffer, size_t nbytes) {
30+
#if FEAT_HAS_SERIAL_TTY
31+
if (pty_master != -1) {
32+
int bytes_read = (int)read(pty_master, buffer, nbytes);
33+
if (bytes_read >= 0) {
34+
return bytes_read;
35+
} else if (bytes_read < 0 && errno != EAGAIN) {
36+
// Some error other than "no data available" occurred during read
37+
printf("SERIAL: PTY read failed, %s\n", strerror(errno));
38+
}
39+
}
40+
#endif
41+
42+
return -1;
4743
}
4844

4945
void SerialWriteData(u8 data) {
@@ -53,7 +49,7 @@ void SerialWriteData(u8 data) {
5349
#if FEAT_HAS_SERIAL_TTY
5450
if (pty_master != -1) {
5551
while(write(pty_master, &data, 1) != 1)
56-
printf("SERIAL: PTY write failed, %d\n", errno);
52+
printf("SERIAL: PTY write failed, %s\n", strerror(errno));
5753
}
5854
#endif
5955
}
@@ -99,20 +95,13 @@ struct Sh4ModScif_impl : Sh4ModScif
9995

10096
bool FifoRefill()
10197
{
102-
auto bytes = SerialHasPendingData();
103-
if (!bytes)
104-
return false;
105-
106-
if (bytes > 64)
107-
bytes = 64;
108-
10998
u8 temp[64];
110-
SerialReadData(temp, bytes);
111-
for (int i = 0; i<bytes; i++) {
99+
int bytes_read = SerialReadData(temp, 64);
100+
for (int i = 0; i<bytes_read; i++) {
112101
fifo.push(temp[i]);
113102
}
114103

115-
return true;
104+
return bytes_read > 0;
116105
}
117106

118107
u8 FifoRead()
@@ -241,4 +230,4 @@ struct Sh4ModScif_impl : Sh4ModScif
241230

242231
Sh4ModScif* Sh4ModScif::Create(SuperH4Mmr* sh4mmr) {
243232
return new Sh4ModScif_impl(sh4mmr);
244-
}
233+
}

libswirl/linux-dist/main.cpp

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ void os_CreateWindow()
194194
#endif
195195
}
196196

197-
void common_linux_setup();
198-
199197
#ifdef TARGET_PANDORA
200198

201199
void clean_exit(int sig_num)
@@ -405,13 +403,13 @@ void os_gl_term()
405403
#endif
406404
}
407405

406+
void common_linux_setup();
408407
#if FEAT_HAS_SERIAL_TTY
409-
int pty_master;
408+
bool common_serial_pty_setup();
410409
#endif
411410

412411
int main(int argc, wchar* argv[])
413412
{
414-
415413
#ifdef TARGET_PANDORA
416414
signal(SIGSEGV, clean_exit);
417415
signal(SIGKILL, clean_exit);
@@ -446,46 +444,10 @@ int main(int argc, wchar* argv[])
446444

447445
if (reicast_init(argc, argv))
448446
die("Reicast initialization failed\n");
449-
450-
#if FEAT_HAS_SERIAL_TTY
451-
bool cleanup_pty_symlink = false;
452-
if (settings.debug.VirtualSerialPort) {
453-
int slave;
454-
char slave_name[2048];
455-
pty_master = -1;
456-
if (openpty(&pty_master, &slave, slave_name, nullptr, nullptr) >= 0)
457-
{
458-
// Turn ECHO off, we don't want to loop-back
459-
struct termios tp;
460-
tcgetattr(pty_master, &tp);
461-
tp.c_lflag &= ~ECHO;
462-
tcsetattr(pty_master, TCSAFLUSH, &tp);
463-
464-
printf("Serial: Created virtual serial port at %s\n", slave_name);
465-
466-
if (settings.debug.VirtualSerialPortFile.size())
467-
{
468-
if (symlink(slave_name, settings.debug.VirtualSerialPortFile.c_str()) == 0)
469-
{
470-
cleanup_pty_symlink = true;
471-
printf("Serial: Created symlink to %s\n", settings.debug.VirtualSerialPortFile.c_str());
472-
}
473-
else
474-
{
475-
printf("Serial: Failed to create symlink to %s, %d\n", settings.debug.VirtualSerialPortFile.c_str(), errno);
476-
}
477-
}
478-
// not for us to use, we use master
479-
// do not close to avoid EIO though
480-
// close(slave);
481-
}
482-
else
483-
{
484-
printf("Serial: Failed to create PTY: %d\n", errno);
485-
}
486-
487-
}
488-
#endif
447+
448+
#if FEAT_HAS_SERIAL_TTY
449+
bool cleanup_pty_symlink = common_serial_pty_setup();
450+
#endif
489451

490452
#if FEAT_HAS_NIXPROF
491453
install_prof_handler(1);

0 commit comments

Comments
 (0)