Skip to content

Commit b8e5815

Browse files
committed
Add support of macOS
1 parent 2b89259 commit b8e5815

6 files changed

Lines changed: 464 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,67 @@ jobs:
8484
path: |
8585
build/msfce.exe
8686
build/*.dll
87+
build-macos-x86-64:
88+
needs: clang-format
89+
runs-on: macos-11
90+
steps:
91+
- uses: actions/checkout@v1
92+
- uses: n1hility/cancel-previous-runs@v2
93+
with:
94+
token: ${{ secrets.GITHUB_TOKEN }}
95+
- name: Fetch submodules
96+
run: git submodule update --init --recursive
97+
- name: Install required system packages
98+
run: |
99+
brew install coreutils wget cmake pkg-config nasm meson ninja
100+
- name: Cache build dependencies
101+
uses: actions/cache@v2
102+
env:
103+
cache-name: cache-build-dependencies
104+
with:
105+
path: extras/apple-darwin-x86_64
106+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('extras/build-macos.sh') }}
107+
- name: Build dependencies
108+
run: (test -d extras/apple-darwin-x86_64 && echo Build dependencies found, skip rebuild) || ./extras/build-macos.sh
109+
- name: Run cmake
110+
run: |
111+
export PKG_CONFIG_LIBDIR=$(pwd)/extras/apple-darwin-x86_64/lib/pkgconfig
112+
mkdir build
113+
cd build
114+
cmake -DCMAKE_BUILD_TYPE=Release ..
115+
- name: Build
116+
run: |
117+
cd build
118+
make -j2
119+
build-macos-arm64:
120+
needs: clang-format
121+
runs-on: macos-11
122+
steps:
123+
- uses: actions/checkout@v1
124+
- uses: n1hility/cancel-previous-runs@v2
125+
with:
126+
token: ${{ secrets.GITHUB_TOKEN }}
127+
- name: Fetch submodules
128+
run: git submodule update --init --recursive
129+
- name: Install required system packages
130+
run: |
131+
brew install coreutils wget cmake pkg-config nasm meson ninja
132+
- name: Cache build dependencies
133+
uses: actions/cache@v2
134+
env:
135+
cache-name: cache-build-dependencies
136+
with:
137+
path: extras/apple-darwin-arm64
138+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('extras/build-macos.sh') }}
139+
- name: Build dependencies
140+
run: (test -d extras/apple-darwin-arm64 && echo Build dependencies found, skip rebuild) || ./extras/build-macos.sh -a arm64
141+
- name: Run cmake
142+
run: |
143+
export PKG_CONFIG_LIBDIR=$(pwd)/extras/apple-darwin-arm64/lib/pkgconfig
144+
mkdir build
145+
cd build
146+
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_BUILD_TYPE=Release ..
147+
- name: Build
148+
run: |
149+
cd build
150+
make -j2

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
build*
2-
extras/x86_64-w64-mingw32
2+
extras/apple-darwin-arm64
3+
extras/apple-darwin-x86_64
4+
extras/x86_64-w64-mingw32

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,37 @@ cmake -DCMAKE_TOOLCHAIN_FILE=../extras/mingw64-toolchain.cmake -DCMAKE_BUILD_TYP
162162
make
163163
```
164164

165+
### macOS
166+
167+
Both Mac Intel and Mac M1 targets are supported, but build has only been tested on Mac Intel.
168+
169+
Install required packages
170+
```
171+
brew install coreutils wget cmake pkg-config nasm meson ninja
172+
```
173+
174+
#### Build for Mac Intel
175+
176+
Build for Intel
177+
```
178+
./extras/build-macos.sh
179+
export PKG_CONFIG_LIBDIR=$(pwd)/extras/apple-darwin-x86_64/lib/pkgconfig
180+
mkdir build-x86_64
181+
cd build-x86_64
182+
cmake -DCMAKE_BUILD_TYPE=Release ..
183+
make
184+
```
185+
186+
#### Build for M1
187+
```
188+
./extras/build-macos.sh -a arm64
189+
export PKG_CONFIG_LIBDIR=$(pwd)/extras/apple-darwin-arm64/lib/pkgconfig
190+
mkdir build-arm64
191+
cd build-arm64
192+
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_BUILD_TYPE=Release ..
193+
make
194+
```
195+
165196
## Ressources
166197

167198
* [65C816 Opcodes by Bruce Clark](http://6502.org/tutorials/65c816opcodes.html)

app/frontend_sdl2/frontend_sdl2.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ int FrontendSdl2::init(const std::shared_ptr<msfce::core::Snes>& snes)
5757
assert(m_Window);
5858

5959
// Init OpenGl context
60+
SDL_GL_SetAttribute(
61+
SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
62+
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
63+
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
64+
6065
m_GlContext = SDL_GL_CreateContext(m_Window);
6166
assert(m_GlContext);
6267

0 commit comments

Comments
 (0)