Skip to content

Commit

Permalink
MacOS build
Browse files Browse the repository at this point in the history
Builds for Intel 64-bit and Apple Arm.
Combines builds into fat binaries.
Packages nsfplay into app bundle.
Builds icon, also compiles PNG into windows icons.
Added version.txt hopefully to allow inclusion everywhere it's needed.
  • Loading branch information
bbbradsmith authored Apr 14, 2024
1 parent f88580c commit 21d9159
Show file tree
Hide file tree
Showing 16 changed files with 243 additions and 18 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,69 @@ jobs:
with:
name: nsfplay3-ubuntu--${{ env.BUILD_TAG }}
path: artifact/

build-macos:
name: MacOS
runs-on: macos-latest
steps:
- name: Checkout Files
uses: actions/checkout@v4
- name: Setup MacOS
run: brew install make cmake imagemagick
- name: wxWidgets Cache Key
run: echo "WXHASH=$(git submodule status wx | tr -d '[:blank:]')" >> $GITHUB_ENV
- name: Cache wxWidgets
id: cache-wx
uses: actions/cache@v4
with:
path: |
wxlibArm/make
wxlibIntel/make
wx/include
key: wx-macos-${{ env.WXHASH }}
- name: Build wxWidgets
if: steps.cache-wx.outputs.cache-hit != 'true'
run: |
export CC=clang
export WXOUT=wxlibArm
export WXCONF_EXTRA="-DCMAKE_OSX_ARCHITECTURES=arm64"
make wxlib
export WXOUT=wxlibIntel
export WXCONF_EXTRA="-DCMAKE_OSX_ARCHITECTURES=x86_64"
make wxlib
#rm -rf wxlibArm/make/libs
#rm -rf wxlibIntel/make/libs
- name: Make
run: |
export CC=clang
export CXXFLAGS_EXTRA="-target arm64-apple-macos11 -Wno-c++11-extensions"
export LDFLAGS_EXTRA="-target arm64-apple-macos11"
export WXL_DIR=../wxlibArm
export OUTDIR=output/makeArm INTDIR=intermediate/makeArm
make cmd nsfplay
export CXXFLAGS_EXTRA="-target x86_64-apple-macos10.13 -Wno-c++11-extensions"
export LDFLAGS_EXTRA="-target x86_64-apple-macos10.13"
export WXL_DIR=../wxlibIntel
export OUTDIR=output/makeIntel INTDIR=intermediate/makeIntel
make cmd nsfplay
- name: Make Fat App
run: |
lipo -create -output output/makeArm/nsfplac2 output/makeArm/nsfplac output/makeIntel/nsfplay
lipo -create -output output/makeArm/nsfplay2 output/makeArm/nsfplay output/makeIntel/nsfplay
mv output/makeArm/nsfplac2 output/makeArm/nsfplac
mv output/makeArm/nsfplay2 output/makeArm/nsfplay
export WXL_DIR=../wxlibArm
export OUTDIR=output/makeArm INTDIR=intermediate/makeArm
make mac
- name: Prepare Artifacts
run: |
mkdir artifact
cp nsfplay.txt artifact
cp output/makeArm/nsfplac artifact
cp -r output/makeArm/nsfplay.app artifact/nsfplay.app
echo "BUILD_TAG=$(git log -1 --format="%ad--%h" --date=format-local:"%Y-%m-%d-%H%M%S")" >> $GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: nsfplay3-macos--${{ env.BUILD_TAG }}
path: artifact/
Binary file added icons/famicom.ico
Binary file not shown.
Binary file added icons/famicom16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/famicom32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions icons/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
include ../makefile.common

# TODO windows icons should have 16, 32, 48, 256
# make a 48 version

ICON_INTDIR ?= ../$(INTDIR)/icon
MAC_INTDIR ?= $(ICON_INTDIR)/nsfplay.iconset

.PHONY: default rebuild mac
default: rebuild

ifneq ("$(wildcard magick)","")
$error("magick utility not found, please install imagemagick")
endif

ICOS = nsfplay.ico famicom.ico
ICOS_TEMP = $(addprefix $(ICON_INTDIR)/,$(ICOS))

rebuild: $(ICOS_TEMP)
cp $(ICOS_TEMP) .

$(ICON_INTDIR)/nsfplay.ico: nsfplay16.png nsfplay32.png | $(ICON_INTDIR)/
magick nsfplay32.png -scale 256 $(ICON_INTDIR)/nsfplay256.png
magick convert nsfplay16.png nsfplay32.png $(ICON_INTDIR)/nsfplay256.png -colors 256 $@

$(ICON_INTDIR)/famicom.ico: famicom16.png famicom32.png | $(ICON_INTDIR)/
magick famicom32.png -scale 256 $(ICON_INTDIR)/famicom256.png
magick convert famicom16.png famicom32.png $(ICON_INTDIR)/famicom256.png -colors 256 $@

mac: nsfplay16.png nsfplay32.png
$(MKDIR) $(MAC_INTDIR)
cp nsfplay16.png $(MAC_INTDIR)/icon_16x16.png
cp nsfplay32.png $(MAC_INTDIR)/[email protected]
cp nsfplay32.png $(MAC_INTDIR)/icon_32x32.png
magick nsfplay32.png -scale 64 $(MAC_INTDIR)/[email protected]
magick nsfplay32.png -scale 128 $(MAC_INTDIR)/icon_128x128.png
magick nsfplay32.png -scale 256 $(MAC_INTDIR)/icon_256x256.png
magick nsfplay32.png -scale 512 $(MAC_INTDIR)/icon_512x512.png
magick nsfplay32.png -scale 1024 $(MAC_INTDIR)/[email protected]
cp $(MAC_INTDIR)/icon_512x512.png $(MAC_INTDIR)/[email protected]
cp $(MAC_INTDIR)/icon_256x256.png $(MAC_INTDIR)/[email protected]
iconutil -c icns -o $(ICON_INTDIR)/nsfplay.icns $(MAC_INTDIR)

$(ICON_INTDIR)/:
$(MKDIR) $@

clean:
rm -rf $(ICON_INTDIR)
Binary file added icons/nsfplay.ico
Binary file not shown.
Binary file added icons/nsfplay16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/nsfplay32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include makefile.common

.PHONY: default core cmd gui wxlib nsfplay winamp install uninstall clean
.PHONY: default core cmd gui nsfplay mac winamp icons wxlib install uninstall clean

default: core cmd nsfplay

Expand All @@ -13,15 +13,21 @@ cmd: core
gui: core
$(MAKE) -C gui

wxlib:
$(MAKE) -f makefile.wx

nsfplay: core gui
$(MAKE) -C nsfplay

mac:
$(MAKE) -C nsfplay mac

winamp: core gui
$(MAKE) -C winamp

icons:
$(MAKE) -C icons

wxlib:
$(MAKE) -f makefile.wx

install: cmd
$(MAKE) -C cmd install
$(MAKE) -C nsfplay install
Expand Down
37 changes: 29 additions & 8 deletions makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ endif
# platform settings

ifeq ($(OS),Windows_NT)
# Windows (MSYS2, gcc)
CXXFLAGS_EXTRA ?= -municode
LDFLAGS_EXTRA ?= -static -static-libgcc -static-libstdc++
LDFLAGS_EXTRA ?= -static -static-libgcc -static-libstdc++ -Wl,--fatal-warnings
LDFLAGS_CMD ?= -mconsole
LDFLAGS_GUI ?=
LDFLAGS_NSFPLAY ?= -mwindows
Expand All @@ -66,9 +67,23 @@ ifeq ($(OS),Windows_NT)
-luuid -lole32 -loleacc -loleaut32 \
-lversion -lshlwapi -luxtheme -lwinspool
endif
else ifeq ($(shell uname),Darwin)
# MacOS (clang)
CXXFLAGS_EXTRA ?= -Wno-c++11-extension
LDFLAGS_EXTRA ?=
LDFLAGS_CMD ?=
LDFLAGS_GUI ?=
LDFLAGS_NSFPLAY ?=
LDFLAGS_DLL ?= -shared
LIB_SUFFIX ?= .a
EXE_SUFFIC ?=
DLL_SUFFIX ?= .so
WXL_LIBDIR ?= .
WXL_CONFIG ?= $(WXL_DIR)/$(WXL_CMAKEDIR)/wx-config
else
# Linux / Other (gcc)
CXXFLAGS_EXTRA ?=
LDFLAGS_EXTRA ?=
LDFLAGS_EXTRA ?= -Wl,--fatal-warnings
LDFLAGS_CMD ?=
LDFLAGS_GUI ?=
LDFLAGS_NSFPLAY ?=
Expand All @@ -77,7 +92,6 @@ else
EXE_SUFFIX ?=
DLL_SUFFIX ?= .so
WXL_LIBDIR ?= .
# wx-config
WXL_CONFIG ?= $(WXL_DIR)/$(WXL_CMAKEDIR)/wx-config
endif

Expand All @@ -94,12 +108,19 @@ endif
# common build flags

CXXFLAGS ?= $(OPTIMIZE) -Wall -Werror -g
LDFLAGS ?= -Wl,--fatal-warnings -g
LDFLAGS ?= -g
INC_COMMON ?= -I../include

# utility to move GCC debug information outside of binaries
# on MacOS we only have a limited version of strip

STRIP_DEBUG = \
objcopy --only-keep-debug $@ [email protected] ; \
strip --strip-debug --strip-unneeded $@ ; \
objcopy [email protected] $@
ifneq ($(shell uname),Darwin)
STRIP_DEBUG ?= \
objcopy --only-keep-debug $@ [email protected] ; \
strip --strip-debug --strip-unneeded $@ ; \
objcopy [email protected] $@
else
STRIP_DEBUG ?= \
nm -a $@ > [email protected] ; \
strip $@
endif
55 changes: 55 additions & 0 deletions nsfplay/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>nsf</string>
</array>
<key>CFBundleTypeName</key>
<string>NSF sound file</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>nsfplay.nsf</string>
</array>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>nsfe</string>
</array>
<key>CFBundleTypeName</key>
<string>NSFE sound file</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSItemContentTypes</key>
<array>
<string>nsfplay.nsfe</string>
</array>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>nsfplay</string>
<key>CFBundleIconFile</key>
<string>nsfplay.icns</string>
<key>CFBundleIconName</key>
<string>nsfplay</string>
<key>CFBundleIdentifier</key>
<string>nsfplay</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>nsfplay</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>NSFP</string>
</dict>
</plist>
25 changes: 23 additions & 2 deletions nsfplay/makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
include ../makefile.common

TARGETFILE ?= $(NSFPLAY_NAME)$(EXE_SUFFIX)
TARGET ?= ../$(OUTDIR)/$(TARGETFILE)
TARGET_DIR ?= ../$(OUTDIR)
TARGET ?= $(TARGET_DIR)/$(TARGETFILE)
NSFPLAY_INTDIR ?= ../$(INTDIR)/nsfplay
NSFPLAY_INSTALL = $(prefix)/$(TARGETFILE)

.PHONY: default install uninstall clean
.PHONY: default mac install uninstall clean

default: $(TARGET)

Expand Down Expand Up @@ -58,4 +59,24 @@ clean:
rm -rf $(NSFPLAY_INTDIR)
rm -rf $(dir $(TARGET))

# mac app build
# intentionally does not depend on $(TARGET) to allow modifying it for fat builds before creating the app

ICON_INTDIR ?= ../$(INTDIR)/icon

mac: $(ICON_INTDIR)/nsfplay.icns Info.plist ../version.txt
$(MKDIR) $(TARGET_DIR)/$(NSFPLAY_NAME).app
$(MKDIR) $(TARGET_DIR)/$(NSFPLAY_NAME).app/Contents
$(MKDIR) $(TARGET_DIR)/$(NSFPLAY_NAME).app/Contents/MacOS
$(MKDIR) $(TARGET_DIR)/$(NSFPLAY_NAME).app/Contents/Resources
cp ../$(INTDIR)/icon/nsfplay.icns $(TARGET_DIR)/$(NSFPLAY_NAME).app/Contents/Resources
cp $(TARGET) $(TARGET_DIR)/$(NSFPLAY_NAME).app/Contents/MacOS
cp Info.plist $(TARGET_DIR)/$(NSFPLAY_NAME).app/Contents
plutil -insert CFBundleShortVersionString -string $(shell cat ../version.txt) $(TARGET_DIR)/$(NSFPLAY_NAME).app/Contents/Info.plist
plutil -insert CFBundleVersion -string $(shell cat ../version.txt) $(TARGET_DIR)/$(NSFPLAY_NAME).app/Contents/Info.plist

$(ICON_INTDIR)/nsfplay.icns:
make -C ../icons mac


include $(DEPS)
Binary file removed nsfplay/nsfplay.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion nsfplay/nsfplay.rc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "resource.h"

IDI_NSFPLAY_ICO ICON "nsfplay.ico"
IDI_NSFPLAY_ICO ICON "../icons/nsfplay.ico"
13 changes: 10 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ This is a work in progress total rewrite of NSFPlay. Goals include:

## Components

* `core` - A platform-agnostic NSF player library suitable for integration into other programs.
* `gui` - A cross platform GUI library that works with the core, allowing plugins to share the same UI as the stand alone player.
* `cmd` - A stand-alone command line player.
Products:
* `core` - A platform-agnostic NSF player library `nsfcore` suitable for integration into other programs.
* `cmd` - A stand-alone command line player `nsfplac`.
* `nsfplay` - A stand-alone GUI player.
* `winamp` - A winamp plugin (Windows 32-bit only).

Support:
* `gui` - A library that provides a common user interface, allowing a plugin to share the same UI as the stand alone player.
* `include` - Public interfaces for the `core` and `gui` libraries.
* `icons` - Icons used for the GUI, edit the PNG files, and rebuild the ICO copies using the makefile (imagemagick required).
* `wx` - [wxWidgets v3.2.4](https://github.com/wxWidgets/wxWidgets/tree/v3.2.4) cross platform GUI library.

## Build
Expand Down Expand Up @@ -84,6 +89,8 @@ On Windows (including MSYS2), you don't need to keep the cmake generated directo
* `make uninstall` - delete install from `/usr/local/bin/`.
* `make install prefix=~/my/directory` - install to custom directory.
* `make uninstall prefix=~/my/directory` - uninstall from custom directory.
* `make icons` - rebuild windows icons from PNG source.
* `make mac` - packages `nsfplay` into `nsfplay.app` (build nsfplay first).
* `make wxlib` - fetches wxWidgets submodule in `wx/` and builds libraries to `wxlib/`.

See `makefile.common` for various potential environment overrides.
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"3.0 prototype"

0 comments on commit 21d9159

Please sign in to comment.