diff --git a/Makefile b/Makefile index 1a73a94..83457c1 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,8 @@ XFILES := SOURCES := *.cpp +PREFIX ?= /usr + ifeq ($(TARGET),) targetmachine := $(shell $(CXX) -dumpmachine) ifneq ($(findstring mingw,$(targetmachine)),) @@ -100,3 +102,29 @@ endif $(FNAME_$(TARGET)): $(SOURCES) $(XFILES) $(CXX) $^ -std=c++98 $(CFLAGS_G) $(MOREFLAGS) $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) $(LFLAGS) -o$@ + +ifeq ($(TARGET),gtk) +install: + mkdir -p $(DESTDIR)$(PREFIX)/bin + mkdir -p $(DESTDIR)$(PREFIX)/share/applications + mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps + mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/symbolic/apps + mkdir -p $(DESTDIR)$(PREFIX)/share/metainfo + install -p -m755 $(FNAME_$(TARGET)) $(DESTDIR)$(PREFIX)/bin + install -p -m755 data/com.github.Alcaro.Flips.desktop $(DESTDIR)$(PREFIX)/share/applications + install -p -m644 data/com.github.Alcaro.Flips.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps + install -p -m644 data/com.github.Alcaro.Flips-symbolic.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/symbolic/apps + install -p -m644 data/com.github.Alcaro.Flips.metainfo.xml $(DESTDIR)$(PREFIX)/share/metainfo + +uninstall: + mkdir -p $(DESTDIR)$(PREFIX)/bin + mkdir -p $(DESTDIR)$(PREFIX)/share/applications + mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps + mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/symbolic/apps + mkdir -p $(DESTDIR)$(PREFIX)/share/metainfo + rm $(DESTDIR)$(PREFIX)/bin/$(FNAME_$(TARGET)) + rm $(DESTDIR)$(PREFIX)/share/applications/com.github.Alcaro.Flips.desktop + rm $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/com.github.Alcaro.Flips.svg + rm $(DESTDIR)$(PREFIX)/share/icons/hicolor/symbolic/apps/com.github.Alcaro.Flips-symbolic.svg + rm $(DESTDIR)$(PREFIX)/share/metainfo/com.github.Alcaro.Flips.metainfo.xml +endif diff --git a/data/com.github.Alcaro.Flips-symbolic.svg b/data/com.github.Alcaro.Flips-symbolic.svg new file mode 100644 index 0000000..7e9ab23 --- /dev/null +++ b/data/com.github.Alcaro.Flips-symbolic.svg @@ -0,0 +1,68 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/data/com.github.Alcaro.Flips.desktop b/data/com.github.Alcaro.Flips.desktop new file mode 100644 index 0000000..923a5bb --- /dev/null +++ b/data/com.github.Alcaro.Flips.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Name=Flips +GenericName=Patcher +Comment=A patcher for IPS and BPS files +# Translators: Search terms to find this application. Do NOT translate or localize the semicolons! The list MUST also end with a semicolon! +Keywords=ips;bps;patcher; +Exec=flips %U +# Translators: Do NOT translate or transliterate this text (this is an icon file name)! +Icon=com.github.Alcaro.Flips +Terminal=false +X-GNOME-SingleWindow=true +Type=Application +StartupNotify=true +Categories=GNOME;GTK;Utility;RevisionControl; +MimeType=application/x-bps-patch;application/x-ips-patch; diff --git a/data/com.github.Alcaro.Flips.metainfo.xml b/data/com.github.Alcaro.Flips.metainfo.xml new file mode 100644 index 0000000..873eb15 --- /dev/null +++ b/data/com.github.Alcaro.Flips.metainfo.xml @@ -0,0 +1,41 @@ + + + + com.github.Alcaro.Flips + CC0-1.0 + GPL-3.0+ + Flips + A patcher for IPS and BPS files + + + + Flips is a patcher for IPS and BPS files, aiming for a simple interface + yet plenty of power under the hood. + + + + + + https://raw.githubusercontent.com/Alcaro/Flips/master/data/flips-main-window.png + + + https://raw.githubusercontent.com/Alcaro/Flips/master/data/flips-preferences-window.png + + + + + + + + + flips + + + com.github.Alcaro.Flips.desktop + https://github.com/Alcaro/Flips + https://github.com/Alcaro/Flips/issues + Alcaro + floating_at_muncher.se + + + diff --git a/data/com.github.Alcaro.Flips.svg b/data/com.github.Alcaro.Flips.svg new file mode 100644 index 0000000..c3d6229 --- /dev/null +++ b/data/com.github.Alcaro.Flips.svg @@ -0,0 +1,194 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/flips-main-window.png b/data/flips-main-window.png new file mode 100644 index 0000000..63bcaa0 Binary files /dev/null and b/data/flips-main-window.png differ diff --git a/data/flips-preferences-window.png b/data/flips-preferences-window.png new file mode 100644 index 0000000..82b0eb3 Binary files /dev/null and b/data/flips-preferences-window.png differ diff --git a/flatpak/com.github.Alcaro.Flips.json b/flatpak/com.github.Alcaro.Flips.json new file mode 100644 index 0000000..63b59f2 --- /dev/null +++ b/flatpak/com.github.Alcaro.Flips.json @@ -0,0 +1,34 @@ +{ + "app-id" : "com.github.Alcaro.Flips", + "runtime" : "org.gnome.Platform", + "runtime-version" : "3.34", + "sdk" : "org.gnome.Sdk", + "command" : "flips", + "finish-args" : [ + /* X11 + XShm access */ + "--share=ipc", + "--socket=x11", + /* Wayland access */ + "--socket=wayland", + /* OpenGL + DRI access */ + "--device=dri", + /* Needed to find the ROMs and patches */ + "--filesystem=host:ro" + ], + "modules" : [ + { + "name" : "flips", + "buildsystem" : "simple", + "build-commands": [ + "sh make.sh --flatpak=yes", + "sh make.sh --flatpak=yes --install=yes" + ], + "sources" : [ + { + "type" : "git", + "url" : "https://github.com/Alcaro/Flips.git" + } + ] + } + ] +} diff --git a/flips-gtk.cpp b/flips-gtk.cpp index a047073..e8f01b5 100644 --- a/flips-gtk.cpp +++ b/flips-gtk.cpp @@ -994,6 +994,10 @@ int GUIShow(const char * filename) button(0,0, "_Apply Patch", G_CALLBACK(a_ApplyPatch)); button(1,0, "_Create Patch", G_CALLBACK(a_CreatePatch)); button(0,1, "Apply and _Run", G_CALLBACK(a_ApplyRun)); +#ifdef FLATPAK + gtk_widget_set_sensitive(button, false); + gtk_widget_set_tooltip_text(button, "Running in emulators is not available in Flatpak"); +#endif button(1,1, "_Settings", G_CALLBACK(a_ShowSettings)); #undef button @@ -1029,6 +1033,7 @@ int GUIShow(const char * filename) int main(int argc, char * argv[]) { + g_set_prgname("com.github.Alcaro.Flips"); canShowGUI = gtk_parse_args(&argc, &argv); cfg.init_file(g_build_filename(g_get_user_config_dir(), "flipscfg", NULL)); return flipsmain(argc, argv); diff --git a/make.sh b/make.sh index 222c684..43f41bf 100755 --- a/make.sh +++ b/make.sh @@ -2,6 +2,8 @@ #This script creates a heavily optimized Linux binary. For debugging or Windows, you're better off using the Makefile directly. +PREFIX=/usr + FLAGS='-Wall -Werror -O3 -flto -fuse-linker-plugin -fomit-frame-pointer -fmerge-all-constants -fvisibility=hidden' FLAGS=$FLAGS' -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables' FLAGS=$FLAGS' -ffunction-sections -fdata-sections -Wl,--gc-sections -fprofile-dir=obj/' @@ -11,6 +13,8 @@ LINFLAGS=' -Wl,-z,relro,-z,now,--as-needed,--hash-style=gnu,--relax' PROFILE=yes +INSTALL=no + for i in "$@"; do case "$i" in --harden=yes) @@ -28,18 +32,30 @@ case "$i" in ;; --harden=no|--profile=yes) ;; + --install=yes) + INSTALL=yes + ;; + --flatpak=yes) + PREFIX=/app + FLAGS=$FLAGS" -DFLATPAK" + ;; *) echo "Unknown argument $1; valid arguments are:" - echo "--harden=yes --profile=no --cflags=(...) --lflags=(...)" + echo "--harden=yes --profile=no --cflags=(...) --lflags=(...) --install=yes --flatpak=yes" exit 1 ;; esac done -if [ $PROFILE = yes ]; then +if [ $INSTALL = yes ]; then + +echo 'GTK+ (install)' +TARGET=gtk make install PREFIX=$PREFIX || exit $? + +elif [ $PROFILE = yes ]; then echo 'GTK+ (1/3)' -rm obj/* flips; TARGET=gtk make CFLAGS="$FLAGS$LINFLAGS -fprofile-generate -lgcov" || exit $? +rm obj/* flips; TARGET=gtk make PREFIX=$PREFIX CFLAGS="$FLAGS$LINFLAGS -fprofile-generate -lgcov" || exit $? [ -e flips ] || exit 1 echo 'GTK+ (2/3)' @@ -55,7 +71,7 @@ $TIME ./flips --create --bps-delta profile/firefox-10.0esr.tar profile/f $TIME ./flips --create --bps-delta-moremem profile/firefox-10.0esr.tar profile/firefox-17.0esr.tar /dev/null echo 'GTK+ (3/3)' -rm flips; TARGET=gtk make CFLAGS="$FLAGS$LINFLAGS -fprofile-use" || exit $? +rm flips; TARGET=gtk make PREFIX=$PREFIX CFLAGS="$FLAGS$LINFLAGS -fprofile-use" || exit $? else -rm flips; TARGET=gtk make CFLAGS="$FLAGS$LINFLAGS" || exit $? +rm flips; TARGET=gtk make PREFIX=$PREFIX CFLAGS="$FLAGS$LINFLAGS" || exit $? fi
+ Flips is a patcher for IPS and BPS files, aiming for a simple interface + yet plenty of power under the hood. +