From c7f22c0dab0d338c97e67f1ee46a165700f40289 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 25 Oct 2023 22:15:32 +0200 Subject: [PATCH] Build the GUI on OSX. --- Makefile | 3 ++- build.py | 6 +++++- build/ab.mk | 2 +- build/ab.py | 2 ++ extras/build.py | 20 ++++++++++++++++++++ src/gui/build.py | 42 +++++++++++++++++++++++++++++++++++++++++- 6 files changed, 71 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f4fbb998..877b02f6 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,8 @@ OBJ = .obj ifeq ($(shell uname),Darwin) LDFLAGS += \ -framework IOKit \ - -framework Foundation + -framework Foundation \ + -Wl,-no_warn_duplicate_libraries endif .PHONY: all diff --git a/build.py b/build.py index 506b1b34..0d7a8d44 100644 --- a/build.py +++ b/build.py @@ -2,6 +2,7 @@ from build.ab import export from build.c import clibrary, cxxlibrary from build.protobuf import proto, protocc from build.pkg import package +import config package(name="protobuf_lib", package="protobuf") package(name="z_lib", package="zlib") @@ -223,6 +224,9 @@ export( "brother120tool": "tools+brother120tool", "brother240tool": "tools+brother240tool", "upgrade-flux-file": "tools+upgrade-flux-file", - }, + } + | {"FluxEngine.pkg": "src/gui+fluxengine_pkg"} + if config.osx + else {}, deps=["tests", "src/formats+docs", "scripts+mkdocindex"], ) diff --git a/build/ab.mk b/build/ab.mk index e59e2dcd..28e77fe4 100644 --- a/build/ab.mk +++ b/build/ab.mk @@ -24,7 +24,7 @@ update-ab: .PHONY: clean clean:: - @echo [-/-] CLEAN + @echo CLEAN $(hide) rm -rf $(OBJ) bin export PYTHONHASHSEED = 1 diff --git a/build/ab.py b/build/ab.py index b5dfdf2a..27654568 100644 --- a/build/ab.py +++ b/build/ab.py @@ -247,6 +247,8 @@ def targetof(s, cwd): s = cwd + s[1:] elif s.startswith("./"): s = normpath(join(cwd, s)) + elif s.endswith("/"): + return fileinvocation(s) elif s.startswith("$"): return fileinvocation(s) diff --git a/extras/build.py b/extras/build.py index 14c3045e..69f76583 100644 --- a/extras/build.py +++ b/extras/build.py @@ -1,3 +1,4 @@ +from build.ab import normalrule, simplerule from build.utils import objectify from build.c import clibrary @@ -12,3 +13,22 @@ clibrary( for n in icons }, ) + +normalrule( + name="fluxengine_iconset", + ins=["./icon.png"], + outs=["fluxengine.iconset"], + commands=[ + "mkdir -p {outs[0]}", + "sips -z 64 64 {ins[0]} --out {outs[0]}/icon_32x32@2x.png > /dev/null", + ], + label="ICONSET", +) + +normalrule( + name="fluxengine_icns", + ins=[".+fluxengine_iconset"], + outs=["fluxengine.icns"], + commands=["iconutil -c icns -o {outs[0]} {ins[0]}"], + label="ICONUTIL", +) diff --git a/src/gui/build.py b/src/gui/build.py index ba58f1d7..31edbccf 100644 --- a/src/gui/build.py +++ b/src/gui/build.py @@ -1,5 +1,6 @@ -from build.ab import emit +from build.ab import emit, normalrule from build.c import cxxprogram +import config emit( """ @@ -54,3 +55,42 @@ cxxprogram( "+protobuf_lib", ], ) + +if config.osx: + normalrule( + name="fluxengine_pkg", + ins=[".+fluxengine_app"], + outs=["FluxEngine.pkg"], + commands=[ + "pkgbuild --quiet --install-location /Applications --component {ins[0]} {outs[0]}" + ], + label="PKGBUILD", + ) + + normalrule( + name="fluxengine_app", + ins=[ + ".+gui", + "extras+fluxengine_icns", + "extras/FluxEngine.app.template/", + ], + outs=["FluxEngine.app"], + commands=[ + "rm -rf {outs[0]}", + "cp -a {ins[2]} {outs[0]}", + "touch {outs[0]}", + "cp {ins[0]} {outs[0]}/Contents/MacOS/fluxengine-gui", + "mkdir -p {outs[0]}/Contents/Resources", + "cp {ins[1]} {outs[0]}/Contents/Resources/FluxEngine.icns", + "dylibbundler -of -x {outs[0]}/Contents/MacOS/fluxengine-gui -b -d {outs[0]}/Contents/libs -cd > /dev/null", + "cp $$(brew --prefix wxwidgets)/README.md $@/Contents/libs/wxWidgets.md", + "cp $$(brew --prefix protobuf)/LICENSE $@/Contents/libs/protobuf.txt", + "cp $$(brew --prefix fmt)/LICENSE.rst $@/Contents/libs/fmt.rst", + "cp $$(brew --prefix libpng)/LICENSE $@/Contents/libs/libpng.txt", + "cp $$(brew --prefix libjpeg)/README $@/Contents/libs/libjpeg.txt", + "cp $$(brew --prefix abseil)/LICENSE $@/Contents/libs/abseil.txt", + "cp $$(brew --prefix libtiff)/LICENSE.md $@/Contents/libs/libtiff.txt", + "cp $$(brew --prefix zstd)/LICENSE $@/Contents/libs/zstd.txt", + ], + label="MKAPP", + )