Skip to content

Commit

Permalink
feat(macOS): Initial Desktop UI (Qt) support
Browse files Browse the repository at this point in the history
* Adds new RetroArchQT build target to RetroArch_Metal.xcodeproj

Prerequisites:

* Install Qt Frameworks

    $ brew install qt

* Build `moc` files using

    $ make -f Makefile.apple HAVE_QT=1 Q=/usr/local/opt/qt/bin/moc generate

Limitations:

* Qt frameworks are not embedded in bundle, therefore Qt must be
  installed via the `brew` command
  • Loading branch information
stuartcarnie committed Sep 6, 2018
1 parent c60fdf0 commit 428f895
Show file tree
Hide file tree
Showing 9 changed files with 352 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ wiiu/wut/elf2rpl/elf2rpl

pkg/apple/iOS/build/
pkg/apple/iOS/modules/
pkg/apple/build/
ui/drivers/qt/moc_*
ui/drivers/moc_*

obj-unix/
.vagrant/
Expand Down
24 changes: 24 additions & 0 deletions Makefile.apple
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include Makefile.common

# Qt MOC generation, required for QObject-derived classes
ifneq ($(MOC_HEADERS),)
# prefix moc_ to base filename of paths and change extension from h to cpp, so a/b/foo.h becomes a/b/moc_foo.cpp
MOC_SRC := $(join $(addsuffix moc_,$(dir $(MOC_HEADERS))), $(notdir $(MOC_HEADERS:.h=.cpp)))
endif

Q ?= $(error missing moc)

.PHONY: generate

$(MOC_SRC):
@$(if $(Q), $(shell echo echo MOC $<),)
$(eval MOC_TMP := $(patsubst %.h,%_moc.cpp,$@))
$(Q)$(MOC) -o $(MOC_TMP) $<

$(foreach x,$(join $(addsuffix :,$(MOC_SRC)),$(MOC_HEADERS)),$(eval $x))

generate: $(MOC_SRC)
@echo $(MOC_SRC)

print-%:
@echo '$*=$($*)'
11 changes: 11 additions & 0 deletions griffin/griffin_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ MENU
UI
============================================================ */
#if defined(HAVE_QT)
#ifndef __APPLE__
#define HAVE_MAIN /* also requires defining in frontend.c */
#endif
#include "../ui/drivers/ui_qt.cpp"

#include "../ui/drivers/qt/ui_qt_window.cpp"
Expand All @@ -53,6 +55,15 @@ UI
#include "../ui/drivers/qt/thumbnaildownload.cpp"
#include "../ui/drivers/qt/thumbnailpackdownload.cpp"
#include "../ui/drivers/qt/playlistthumbnaildownload.cpp"
#include "../ui/drivers/moc_ui_qt.cpp"
#include "../ui/drivers/qt/moc_coreinfodialog.cpp"
#include "../ui/drivers/qt/moc_coreoptionsdialog.cpp"
#include "../ui/drivers/qt/moc_filedropwidget.cpp"
#include "../ui/drivers/qt/moc_flowlayout.cpp"
#include "../ui/drivers/qt/moc_playlistentrydialog.cpp"
#include "../ui/drivers/qt/moc_shaderparamsdialog.cpp"
#include "../ui/drivers/qt/moc_ui_qt_load_core_window.cpp"
#include "../ui/drivers/qt/moc_viewoptionsdialog.cpp"
#endif

/*============================================================
Expand Down
15 changes: 1 addition & 14 deletions pkg/apple/BaseConfig.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,11 @@
//
// Created by Stuart Carnie on 5/10/18.
//
VULKAN_PACKAGE_PATH = /Volumes/Data/projects/frameworks/vulkan/moltenvk/Package

// macOS
VULKAN_FRAMEWORK_PATH[sdk=macosx*] = $(VULKAN_PACKAGE_PATH)/$(CONFIGURATION)/MoltenVK/macOS


// general
FRAMEWORK_SEARCH_PATHS[sdk=macosx*] = $(inherited) $(LOCAL_LIBRARY_DIR)/Frameworks $(VULKAN_FRAMEWORK_PATH)
LIBRARY_SEARCH_PATHS[sdk=macosx*] = $(inherited) $(VULKAN_FRAMEWORK_PATH)

// OTHER_LDFLAGS = $(inherited) -lMoltenVK -framework MoltenVK

OTHER_CFLAGS = $(inherited) -DHAVE_RUNAHEAD -DHAVE_GRIFFIN -DHAVE_FLAC -DHAVE_DR_FLAC -DHAVE_DR_MP3 -DHAVE_LROUND -DFLAC__HAS_OGG=0 -DHAVE_CHD -DHAVE_STB_VORBIS -DHAVE_MINIUPNPC -DHAVE_BUILTINMINIUPNPC -DHAVE_UPDATE_ASSETS -DHAVE_LANGEXTRA -DHAVE_CHEEVOS -DHAVE_IMAGEVIEWER -DHAVE_IOHIDMANAGER -DHAVE_CORETEXT -DHAVE_RGUI -DHAVE_MENU -DOSX -DHAVE_OPENGL -DHAVE_CC_RESAMPLER -DHAVE_GLSL -DINLINE=inline -D__LIBRETRO__ -DHAVE_COREAUDIO -DHAVE_DYNAMIC -DHAVE_OVERLAY -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_COCOA -DHAVE_MAIN -DHAVE_NETWORKGAMEPAD -DHAVE_NETWORKING -DRARCH_INTERNAL -DHAVE_THREADS -DHAVE_DYLIB -DHAVE_7ZIP -DHAVE_MATERIALUI -DHAVE_HID -DHAVE_XMB -DHAVE_SEGA -DHAVE_SHADERPIPELINE -DHAVE_MMAP -DHAVE_LIBRETRODB -DHAVE_GETOPT_LONG -DHAVE_METAL -DHAVE_SLANG -DHAVE_GLSLANG -DHAVE_SPIRV_CROSS -DWANT_GLSLANG -DENABLE_HLSL -DGLSLANG_OSINCLUDE_UNIX -DMETAL_DEBUG
OTHER_CFLAGS = $(inherited) -DHAVE_RUNAHEAD -DHAVE_GRIFFIN -DHAVE_FLAC -DHAVE_DR_FLAC -DHAVE_DR_MP3 -DHAVE_LROUND -DFLAC__HAS_OGG=0 -DHAVE_CHD -DHAVE_STB_VORBIS -DHAVE_MINIUPNPC -DHAVE_BUILTINMINIUPNPC -DHAVE_UPDATE_ASSETS -DHAVE_LANGEXTRA -DHAVE_CHEEVOS -DHAVE_IMAGEVIEWER -DHAVE_IOHIDMANAGER -DHAVE_CORETEXT -DHAVE_RGUI -DHAVE_MENU -DOSX -DHAVE_OPENGL -DHAVE_CC_RESAMPLER -DHAVE_GLSL -DINLINE=inline -D__LIBRETRO__ -DHAVE_COREAUDIO -DHAVE_DYNAMIC -DHAVE_OVERLAY -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_COCOA -DHAVE_NETWORKGAMEPAD -DHAVE_NETWORKING -DRARCH_INTERNAL -DHAVE_THREADS -DHAVE_DYLIB -DHAVE_7ZIP -DHAVE_MATERIALUI -DHAVE_HID -DHAVE_XMB -DHAVE_SEGA -DHAVE_SHADERPIPELINE -DHAVE_MMAP -DHAVE_LIBRETRODB -DHAVE_GETOPT_LONG -DHAVE_METAL -DHAVE_SLANG -DHAVE_GLSLANG -DHAVE_SPIRV_CROSS -DWANT_GLSLANG -DENABLE_HLSL -DGLSLANG_OSINCLUDE_UNIX -DMETAL_DEBUG

SRCBASE = $(SRCROOT)/../..
DEPS_DIR = $(SRCBASE)/deps
HEADER_SEARCH_PATHS = $(inherited) $(SRCBASE) $(SRCBASE)/gfx/include $(SRCBASE)/libretro-common/include $(DEPS_DIR)/libFLAC/include $(DEPS_DIR)/7zip $(DEPS_DIR)/stb $(DEPS_DIR) $(DEPS_DIR)/SPIRV-Cross $(DEPS_DIR)/glslang $(DEPS_DIR)/glslang/glslang/glslang/Public $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent $(DEPS_DIR)/glslang/glslang/SPIRV $(DEPS_DIR)/glslang/glslang/glslang/OSDependent/Unix
CLANG_CXX_LANGUAGE_STANDARD=c++11
LD_RUNPATH_SEARCH_PATHS = @executable_path
CLANG_ENABLE_OBJC_ARC=YES
//SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
9 changes: 9 additions & 0 deletions pkg/apple/Metal.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// BaseConfig.xcconfig
// RetroArch
//
// Created by Stuart Carnie on 5/10/18.
//

OTHER_CFLAGS = $(inherited) -DHAVE_MAIN

24 changes: 24 additions & 0 deletions pkg/apple/QTConfig.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// RetroArch build configuration specific to Qt
//
// Created by Stuart Carnie on 5/10/18.
//

// QT Support
QT_INSTALL = /usr/local/opt/qt
QT_FRAMEWORK_PATH = $(QT_INSTALL)/lib
QT_FRAMEWORKS = -framework QtWidgets -framework QtGui -framework QtConcurrent -framework QtNetwork -framework QtCore

QT_HEADERS = $(QT_INSTALL)/include
QT_HEADER_SEARCH_PATHS = $(QT_HEADERS) $(QT_HEADERS)/QtWidgets $(QT_HEADERS)/QtGui $(QT_HEADERS)/QtConcurrent $(QT_HEADERS)/QtNetwork $(QT_HEADERS)/QtCore
QT_CFLAGS = -DHAVE_QT -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CONCURRENT_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB

// general
FRAMEWORK_SEARCH_PATHS[sdk=macosx*] = $(inherited) $(QT_FRAMEWORK_PATH)

OTHER_LDFLAGS = $(inherited) $(QT_FRAMEWORKS)

OTHER_CFLAGS = $(inherited) $(QT_CFLAGS)

HEADER_SEARCH_PATHS = $(inherited) $(QT_HEADER_SEARCH_PATHS)
LD_RUNPATH_SEARCH_PATHS = @executable_path
49 changes: 49 additions & 0 deletions pkg/apple/RetroArch copy-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>*</string>
</array>
<key>CFBundleTypeName</key>
<string>All Files</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>retroarch</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.7.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.7.4</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 RetroArch. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>RApplication</string>
</dict>
</plist>
Loading

0 comments on commit 428f895

Please sign in to comment.