-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS X Packaging (Q2Pro.app) #106
base: master
Are you sure you want to change the base?
Changes from all commits
497ebe2
c376be7
92823a1
5ed545d
63abbe9
dfd88f2
403399f
e7ebb3f
869fa22
e919147
50ff57c
cdf9173
1ab18f6
d374072
d8c32a4
7660510
0095c0b
0176366
03ddefa
febaf39
1d0e935
9b3f5e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Makefile for Q2Pro.app, requires http://macdylibbundler.sourceforge.net/ | ||
|
||
TARGET = target | ||
Q2PRO = $(TARGET)/Q2Pro.app | ||
BINDIR = $(Q2PRO)/Contents/MacOS | ||
DATADIR = $(Q2PRO)/Contents/Resources | ||
DIST = $(TARGET)/Q2Pro.dmg | ||
VOLUME_NAME = Q2Pro | ||
REMOTE_USER = $(shell whoami) | ||
HTTP_REPOSITORY = quetoo.org:/var/www/quetoo.org/files | ||
HTTP_TARGET = $(REMOTE_USER)@$(HTTP_REPOSITORY) | ||
|
||
all: install | ||
|
||
pre-install: | ||
install -d $(TARGET) | ||
cp -R Q2Pro.app $(Q2PRO) | ||
find $(Q2PRO) -name .turd -delete | ||
|
||
install-bin: pre-install | ||
install ../q2pro $(BINDIR) | ||
install ../q2proded $(BINDIR) | ||
install ../gamex86_64.so $(BINDIR)/baseq2 | ||
|
||
install-lib: install-bin | ||
install -d $(TARGET)/lib | ||
dylibbundler -b \ | ||
-x "$(BINDIR)/q2pro" \ | ||
-x "$(BINDIR)/q2proded" \ | ||
-d $(TARGET)/lib -of -p @executable_path/lib | ||
mv $(TARGET)/lib $(BINDIR)/lib | ||
|
||
install-share: | ||
install -m 0644 ../INSTALL.md $(DATADIR) | ||
install -m 0644 ../LICENSE $(DATADIR) | ||
install -m 0644 ../README.md $(DATADIR) | ||
install -m 0644 ../src/client/ui/q2pro.menu $(DATADIR)/baseq2 | ||
|
||
install: pre-install install-bin install-lib install-share | ||
|
||
dist: | ||
ln -f -s /Applications $(TARGET)/Applications | ||
hdiutil create $(DIST) -srcfolder $(TARGET) -volname $(VOLUME_NAME) | ||
|
||
dist-release: | ||
rsync -rzhP $(DIST) $(HTTP_TARGET) | ||
|
||
clean: | ||
rm -rf $(TARGET)/* | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?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>English</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>Q2Pro</string> | ||
<key>CFBundleExecutable</key> | ||
<string>q2pro</string> | ||
<key>CFBundleIconFile</key> | ||
<string>quake2.icns</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>org.quetoo.q2pro.launcher</string> | ||
<key>CFBundleName</key> | ||
<string>Q2Pro</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>Quetoo.org</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>Quetoo.org</string> | ||
<key>LSMinimumSystemVersion</key> | ||
<string>10.10</string> | ||
</dict> | ||
</plist> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/usr/bin/python | ||
|
||
from os import path, system | ||
import sys | ||
|
||
class Dictionary(dict): | ||
"""A dict allowing dot notation.""" | ||
def __getattr__(self, attr): | ||
return self.get(attr, None) | ||
__setattr__ = dict.__setitem__ | ||
__delattr__ = dict.__delitem__ | ||
|
||
config = Dictionary({ | ||
'root': 'quetoo.org::quake2', | ||
'base': [ | ||
'baseq2/pak[1-3].pak', | ||
'baseq2/pak-quake2-extras.pak', | ||
'baseq2/players/*', | ||
'3.20_changes.txt', | ||
'license.txt', | ||
'readme.txt', | ||
], | ||
'ctf': [ | ||
'ctf/*' | ||
], | ||
'demo': [ | ||
'baseq2/pak-quake2-demo.pak', | ||
'license-demo.txt' | ||
], | ||
'hud': [ | ||
'baseq2/pak-kmquake2-hud.pak', | ||
], | ||
'models': [ | ||
'baseq2/pak-generations-models.pak' | ||
], | ||
'textures': [ | ||
'baseq2/pak-jimw-textures.pak' | ||
] | ||
}) | ||
|
||
messages = Dictionary({ | ||
'begin': 'This script will install optional game data. Continue?', | ||
'home': 'Enter your Quake2 directory:', | ||
'base': 'Install the 3.20 point release? (25MB)', | ||
'ctf': 'Install ThreeWave Capture the Flag? (12MB)', | ||
'demo': 'Install the demo? Select this if you do not own Quake2. (48MB)', | ||
'hud': 'Install the KMQuake2 high-resolution HUD? (0.5MB)', | ||
'models': 'Install the Generations high-resolution models? (37MB)', | ||
'textures': 'Install Jim W\'s high-resolution textures? (320MB)', | ||
'end': 'Installation complete.' | ||
}) | ||
|
||
def _rsync(source, target): | ||
"""Fetches a single source pattern to the specified target.""" | ||
system("rsync -rRzhP %s/%s %s" % (config.root, source, target)) | ||
|
||
def rsync(module): | ||
"""Fetches all path patterns in the specified module.""" | ||
for path in module: | ||
_rsync(path, config.home) | ||
|
||
def less(file): | ||
"""Dumps the file to the console.""" | ||
system("less %s/%s" % (config.home, file)) | ||
|
||
def prompt(message, default=''): | ||
"""Prompts the user for input, returning their response.""" | ||
while True: | ||
sys.stdout.write("%s [%s] " % (message, default)) | ||
response = raw_input().lower() | ||
if response == '': | ||
if default == '': | ||
continue | ||
response = default | ||
return response.lower() | ||
|
||
if __name__ == '__main__': | ||
|
||
if prompt(messages.begin, 'y') != 'y': | ||
sys.exit() | ||
|
||
config.home = path.expanduser('~/.quake2') | ||
config.home = prompt(messages.home, config.home) | ||
|
||
if prompt(messages.base, 'y') == 'y': | ||
rsync(config.base) | ||
less('license.txt') | ||
|
||
if prompt(messages.ctf, 'y') == 'y': | ||
rsync(config.ctf) | ||
|
||
if prompt(messages.demo, 'n') == 'y': | ||
rsync(config.demo) | ||
less('license-demo.txt') | ||
|
||
if prompt(messages.hud, 'y') == 'y': | ||
rsync(config.hud) | ||
|
||
if prompt(messages.models, 'y') == 'y': | ||
rsync(config.models) | ||
|
||
if prompt(messages.textures, 'y') == 'y': | ||
rsync(config.textures) | ||
|
||
print messages.end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the game data installation script I developed for my AprQ2 fork. Users can run this to optionally install the 3.20 point release, the game demo, CTF, high res textures, Generations Arena models, etc.. It's like Q2Starter for Apple and Linux. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,7 +146,7 @@ S_Init | |
*/ | ||
void S_Init(void) | ||
{ | ||
s_enable = Cvar_Get("s_enable", "1", CVAR_SOUND); | ||
s_enable = Cvar_Get("s_enable", "2", CVAR_SOUND); | ||
if (s_enable->integer <= SS_NOT) { | ||
Com_Printf("Sound initialization disabled.\n"); | ||
return; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default this to 2 so that OpenAL is tried if available. Seems like a logical thing to do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I built a version without OpenAL and it correctly resets to |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,10 @@ with this program; if not, write to the Free Software Foundation, Inc., | |
#include <SDL.h> | ||
#endif | ||
|
||
#ifdef __APPLE__ | ||
#include <mach-o/dyld.h> | ||
#endif | ||
|
||
cvar_t *sys_basedir; | ||
cvar_t *sys_libdir; | ||
cvar_t *sys_homedir; | ||
|
@@ -282,7 +286,23 @@ void Sys_Init(void) | |
signal(SIGPIPE, SIG_IGN); | ||
signal(SIGUSR1, hup_handler); | ||
|
||
// basedir <path> | ||
#ifdef __APPLE__ | ||
// set Q2Pro.app/Contents/Resources as basedir | ||
char path[MAX_OSPATH], *c; | ||
unsigned int i = sizeof(path); | ||
|
||
if (_NSGetExecutablePath(path, &i) > -1) { | ||
if ((c = strstr(path, "Q2Pro.app"))) { | ||
strcpy(c, "Q2Pro.app/Contents/Resources"); | ||
Cvar_FullSet("basedir", path, CVAR_NOSET, FROM_CODE); | ||
|
||
strcpy(c, "Q2Pro.app/Contents/MacOS"); | ||
Cvar_FullSet("libdir", path, CVAR_NOSET, FROM_CODE); | ||
} | ||
} | ||
#endif | ||
|
||
// basedir <path> | ||
// allows the game to run from outside the data tree | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change forces There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of hard-coding, you could put these in your .config file:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @skullernet is the code suitable for upstreaming after passing review? Distributing binaries with dependencies is a major pain for OSX unlike Windows or ELF-based Unix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sthalik I would recommend not including the changes to unix/system.c or guarding them behind an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change only modifies the game's behavior if it's running on macOS and is launched from within a .app bundle. I don't think the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might be right, I recall having problems with relative paths in some versions of macOS which I solved with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, either of those sound responsible enough ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a wrapper shell script as the executable in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feel free to do whatever you like with this PR, including closing it. I was porting things over from my own projects over 2 years ago to help Q2Pro reach macOS users. You may take it or leave it ¯_(ツ)_/¯ |
||
sys_basedir = Cvar_Get("basedir", DATADIR, CVAR_NOSET); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is based on the packaging I've created for Quake II, Quetoo, GtkRadiant, etc.. It uses
dylibbundler
to find, copy and fix dynamically linked dependencies.