Skip to content

Commit 7c2e046

Browse files
authored
Merge pull request #30 from Diesel-Net/develop
Improve Builds
2 parents dea1c65 + 8cb6231 commit 7c2e046

File tree

10 files changed

+85
-70
lines changed

10 files changed

+85
-70
lines changed

.github/workflows/build-reusable.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
- name: Build macOS (x86_64 + arm64)
2424
run: |
2525
cd MacOS
26+
make clean
2627
make
2728
2829
- name: Upload macOS build artifact
@@ -43,7 +44,7 @@ jobs:
4344
path: external/sdl/build
4445
key: sdl-2.32.10-windows-2022-${{ runner.arch }}
4546

46-
- name: Configures build environment for AMD64
47+
- name: Configures build environment for x86-64
4748
uses: ilammy/msvc-dev-cmd@v1
4849
with:
4950
arch: amd64
@@ -52,6 +53,7 @@ jobs:
5253
shell: cmd
5354
run: |
5455
cd Windows
56+
nmake clean
5557
nmake
5658
5759
- name: Upload Windows build artifact

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ on:
44
pull_request: {}
55

66
jobs:
7-
core-lint:
7+
shared-lint:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v4
11-
- name: Run Core no-OO linter
11+
- name: Run no-OO linter
1212
run: |
13-
bash tools/check_no_oo.sh Core
13+
bash tools/check_no_oo.sh shared

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Generated files
88
shared/license.h
99
shared/bootrom.h
10+
macos/src/Info.plist
1011

1112
# External dependencies (downloaded at build time)
1213
external/sdl/

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,26 @@ in C-style C++ using SDL2, ImGui, and OpenGL.
2727
- Command line support
2828
- No SCHIP support
2929

30+
## Controls
31+
32+
33+
controls <--> keybindings
34+
35+
1 2 3 C 1 2 3 4
36+
4 5 6 D q w e r
37+
7 8 9 E a s d f
38+
A 0 B F z x c v
39+
increase speed page up
40+
decrease speed page down
41+
quit esc
42+
toggle fullscreen enter
43+
toggle menu left alt
44+
show fps right alt
45+
soft reset f5
46+
pause p
47+
mute m
48+
49+
3050
## Usage
3151

3252
Kiwi8 [filename] [-FMLSV]
@@ -36,26 +56,6 @@ in C-style C++ using SDL2, ImGui, and OpenGL.
3656
-S Disable shift quirk
3757
-V Disable vertical wrapping
3858

39-
## Controls
40-
```
41-
controls <--> keybindings
42-
43-
1 2 3 C 1 2 3 4
44-
4 5 6 D q w e r
45-
7 8 9 E a s d f
46-
A 0 B F z x c v
47-
increase speed page up
48-
decrease speed page down
49-
quit esc
50-
toggle fullscreen enter
51-
toggle menu left alt
52-
show fps right alt
53-
soft reset f5
54-
pause p
55-
mute m
56-
57-
```
58-
5959
## Building on Windows
6060

6161
The following must be installed and added to your **PATH**:

macos/makefile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
APP_NAME = Kiwi8
22

3-
# Auto-detect version: use GITHUB_REF_NAME if set (CI), else git describe, else git branch
4-
ifeq ($(origin GITHUB_REF_NAME), environment)
5-
VERSION := $(GITHUB_REF_NAME)
6-
else
7-
VERSION := $(shell git describe --tags --exact-match 2>/dev/null || git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
3+
# Use GITHUB_REF_NAME from GitHub Actions, or default values for local builds
4+
VERSION ?= $(GITHUB_REF_NAME)
5+
ifeq ($(VERSION),)
6+
VERSION = unknown
87
endif
98

10-
APP_NAME_VERSION = $(APP_NAME) $(VERSION)
11-
APP_EXE = $(APP_NAME)
9+
COMMIT_HASH := $(if $(GITHUB_SHA),$(GITHUB_SHA),unknown)
10+
11+
APP_MANIFEST = src/Info.plist
1212
APP_BUNDLE = $(APP_NAME).app
13+
APP_EXE = $(APP_NAME)
1314

1415
CC = clang++
15-
CFLAGS = -std=c++17 -Wall -mmacosx-version-min=11.0 -arch x86_64 -arch arm64 -MMD -MP -DAPPNAME_VERSION='"$(APP_NAME_VERSION)"'
16+
CFLAGS = -std=c++17 -Wall -mmacosx-version-min=11.0 -arch x86_64 -arch arm64 -MMD -MP -DAPP_NAME='"$(APP_NAME)"' -DVERSION='"$(VERSION)"' -DCOMMIT_HASH='"$(COMMIT_HASH)"'
1617
LFLAGS = -mmacosx-version-min=11.0
1718
INCS = -I../external/sdl/build/include/ -I../external/imgui/ -I../shared/
1819
LIBS = -L../external/sdl/build/lib/ -lSDL2-2.0.0 -framework Cocoa -framework OpenGL
@@ -60,6 +61,10 @@ $(LICENSE_HEADER): ../LICENSE
6061
$(BOOTROM_HEADER): $(BOOTROM_SOURCE)
6162
python3 ../tools/generate_bootrom_header.py $(BOOTROM_SOURCE) $(BOOTROM_HEADER)
6263

64+
# Generate Info.plist from template with version substitution
65+
$(APP_MANIFEST): $(APP_MANIFEST).in
66+
sed -e 's/@APP_NAME@/$(APP_NAME)/g' -e 's/@VERSION@/$(VERSION)/g' -e 's/@COMMIT_HASH@/$(COMMIT_HASH)/g' $< > $@
67+
6368
# Pattern rules for incremental compilation
6469
%.o: ../shared/%.cc $(LICENSE_HEADER) $(BOOTROM_HEADER)
6570
$(CC) $(CFLAGS) $(INCS) -c $< -o $@
@@ -88,15 +93,15 @@ release/$(APP_BUNDLE)/Contents/MacOS/$(APP_EXE): $(SDL_LIB) $(OBJS)
8893
$(CC) $(CFLAGS) $(LIBS) $(INCS) $(OBJS) -o $@ $(LFLAGS)
8994

9095
# .app bundle
91-
release/$(APP_BUNDLE): release/$(APP_BUNDLE)/Contents/MacOS/$(APP_EXE) $(SDL_LIB) resources/Kiwi8.icns src/Info.plist
96+
release/$(APP_BUNDLE): release/$(APP_BUNDLE)/Contents/MacOS/$(APP_EXE) $(SDL_LIB) resources/Kiwi8.icns $(APP_MANIFEST)
9297
mkdir -p release/$(APP_BUNDLE)/Contents/{Resources,Frameworks}
9398

9499
# Copying the frameworks into .app bundle
95100
cp $(SDL_LIB) release/$(APP_BUNDLE)/Contents/Frameworks/libSDL2-2.0.0.dylib
96101

97102
# Moving other files into .app bundle
98103
cp resources/Kiwi8.icns release/$(APP_BUNDLE)/Contents/Resources/Kiwi8.icns
99-
cp src/Info.plist release/$(APP_BUNDLE)/Contents/Info.plist
104+
cp $(APP_MANIFEST) release/$(APP_BUNDLE)/Contents/Info.plist
100105

101106
# Set the dylib's install name to be relative to the bundle
102107
install_name_tool -id @executable_path/../Frameworks/libSDL2-2.0.0.dylib release/$(APP_BUNDLE)/Contents/Frameworks/libSDL2-2.0.0.dylib
@@ -119,6 +124,7 @@ clean:
119124
$(RM) -r debug
120125
$(RM) -r release
121126
$(RM) $(LICENSE_HEADER) $(BOOTROM_HEADER)
127+
$(RM) $(APP_MANIFEST)
122128

123129
# Removes everything including SDL installation and build artifacts (full reset)
124130
distclean: clean
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@
33
<plist version="1.0">
44
<dict>
55
<key>CFBundleExecutable</key>
6-
<string>Kiwi8</string>
6+
<string>@APP_NAME@</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>net.kiwi-labs.kiwi8</string>
79
<key>CFBundleIconFile</key>
810
<string>Kiwi8.icns</string>
911
<key>CFBundleInfoDictionaryVersion</key>
1012
<string>1.0</string>
1113
<key>CFBundlePackageType</key>
1214
<string>APPL</string>
13-
<key>CFBundleSignature</key>
14-
<string>kiwi</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>@VERSION@</string>
1517
<key>CFBundleVersion</key>
16-
<string>1.03</string>
18+
<string>@SUB_VERSION@</string>
19+
<key>LSMinimumSystemVersion</key>
20+
<string>11.0</string>
1721
<key>NSHighResolutionCapable</key>
1822
<true/>
1923
<key>NSHumanReadableCopyright</key>
20-
<string>Copyright © 2016 Thomas Daley.</string>
24+
<string>Copyright © 2016-2026 Kiwi Labs.</string>
25+
<key>NSSupportsAutomaticGraphicsSwitching</key>
26+
<true/>
2127

2228
</dict>
2329
</plist>

shared/Chip8.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,22 @@
66
#include "Input.h"
77
#include "Audio.h"
88

9-
// APPNAME_VERSION is defined by the compiler via -DAPPNAME_VERSION="..."
9+
// APP_NAME is defined by the compiler via -DAPP_NAME="..."
1010
// Falls back to generic name if not defined (shouldn't happen in normal builds)
11-
#ifndef APPNAME_VERSION
12-
#define APPNAME_VERSION "Kiwi8"
11+
#ifndef APP_NAME
12+
#define APP_NAME "Kiwi8"
13+
#endif
14+
15+
// VERSION is defined by the compiler via -DVERSION="..."
16+
// Falls back to unknown if not defined (shouldn't happen in normal builds)
17+
#ifndef VERSION
18+
#define VERSION "unknown"
19+
#endif
20+
21+
// COMMIT_HASH is defined by the compiler via -DCOMMIT_HASH="..."
22+
// Falls back to generic name if not defined (shouldn't happen in normal builds)
23+
#ifndef COMMIT_HASH
24+
#define COMMIT_HASH "unknown"
1325
#endif
1426

1527
#define MEM_SIZE 4096

shared/Gui.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "Display.h"
33
#include "Gui.h"
44
#include "license.h" // Generated at build time from LICENSE
5+
#include <stdio.h>
56

67
Gui::Gui() {
78
soft_reset_flag = 0;
@@ -220,13 +221,18 @@ void Gui::HelpWindows() {
220221
ImGui::SetNextWindowPosCenter(ImGuiSetCond_Appearing);
221222
ImGui::Begin("About", &show_about);
222223

224+
// Truncate COMMIT_HASH to first 7 characters for display
225+
char short_hash[8];
226+
snprintf(short_hash, sizeof(short_hash), "%.7s", COMMIT_HASH);
227+
223228
ImGui::TextWrapped(
224-
APPNAME_VERSION "\n"
229+
APP_NAME " " VERSION " (%s)\n"
225230
"\n"
226231
"A cross-platform Chip-8 interpreter written\n"
227232
"in C-Style C++ using SDL2, ImGui, and OpenGL.\n"
228233
"\n"
229-
"<https://github.com/Diesel-Net/kiwi-8>\n"
234+
"<https://github.com/Diesel-Net/kiwi-8>\n",
235+
short_hash
230236
);
231237

232238
ImGui::End();

shared/main.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
/*
2-
Author: Thomas Daley
3-
Date: September 8, 2016
4-
5-
Usage: Kiwi8 [filename] [-FMLSV]
6-
-F Launch in fullscreen
7-
-M Launch with audio muted
8-
-L Disable load/store quirk
9-
-S Disable shift quirk
10-
-V Disable vertical wrapping
11-
*/
12-
131
#include "Chip8.h"
142
#include <string.h>
153

windows/makefile

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
APP_NAME = Kiwi8
22

3-
# Auto-detect version: use GITHUB_REF_NAME if set (CI), else git describe, else git branch
4-
!IFNDEF GITHUB_REF_NAME
5-
# Try git describe for exact tag match
6-
!IF [git describe --tags --exact-match > .version.tmp 2>nul] == 0
7-
!INCLUDE .version.tmp
8-
# Try git branch name
9-
!ELSE IF [git rev-parse --abbrev-ref HEAD > .version.tmp 2>nul] == 0
10-
!INCLUDE .version.tmp
3+
# Use GITHUB_REF_NAME from GitHub Actions, or default values for local builds
4+
!IFDEF GITHUB_REF_NAME
5+
VERSION = $(GITHUB_REF_NAME)
116
!ELSE
127
VERSION = unknown
138
!ENDIF
14-
# Clean up temp file
15-
!IF [del .version.tmp 2>nul]
16-
!ENDIF
9+
10+
!IFDEF GITHUB_SHA
11+
COMMIT_HASH = $(GITHUB_SHA)
1712
!ELSE
18-
VERSION = $(GITHUB_REF_NAME)
13+
COMMIT_HASH = unknown
1914
!ENDIF
2015

21-
APP_NAME_VERSION = $(APP_NAME) $(VERSION)
2216
APP_EXE = $(APP_NAME).exe
2317
APP_PDB = $(APP_NAME).pdb
2418
APP_RES = $(APP_NAME).res
2519

2620
CC = CL
27-
CFLAGS = /std:c++17 /W4 /MD /nologo /w44996 "/DAPPNAME_VERSION=\"$(APP_NAME_VERSION)\""
21+
CFLAGS = /std:c++17 /W4 /MD /nologo /w44996 "/DAPP_NAME=\"$(APP_NAME)\"" "/DVERSION=\"$(VERSION)\"" "/DCOMMIT_HASH=\"$(COMMIT_HASH)\""
2822
LFLAGS = /link \
2923
/LIBPATH:..\external\sdl\build\lib \
3024
/ENTRY:mainCRTStartup

0 commit comments

Comments
 (0)