forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspatialite-gis.rb
82 lines (71 loc) · 2.35 KB
/
spatialite-gis.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require "formula"
class SpatialiteGis < Formula
homepage "https://www.gaia-gis.it/fossil/spatialite_gis/index"
url "http://www.gaia-gis.it/gaia-sins/spatialite_gis-1.0.0c.tar.gz"
sha1 "45508b27fbdc7166ef874ce3f79216d6c01f3c4f"
depends_on "pkg-config" => :build
depends_on "freexl"
depends_on "geos"
depends_on "libharu"
depends_on "librasterlite"
depends_on "libspatialite"
depends_on "proj"
depends_on "wxmac"
patch :p0 do
# Upstream fix for bad test of string equality. Remove on next release.
# https://www.gaia-gis.it/fossil/spatialite_gis/tktview?name=f0658b3ead
url "https://www.gaia-gis.it/fossil/spatialite_gis/vpatch?from=0506d89e65c692d7&to=0783daf1178ee1dc"
sha1 "a82f5f6aef40ec1177fb8a28164c7ad9ea600b18"
end
# Allow `spatialite_gis` to run without being packaged as an .app bundle.
patch :p1, :DATA
def install
# Failure to link aui library (see spatialite-gui)
# https://github.com/Homebrew/homebrew/pull/29358
inreplace "configure", "WX_LIBS=\"$(wx-config --libs)\"", "WX_LIBS=\"$(wx-config --libs std,aui)\""
# These libs don"t get picked up by configure.
ENV.append "LDFLAGS", "-liconv"
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make", "install"
end
end
__END__
Fix GUI so it can run without needing to construct an app bundle.
diff --git a/Main.cpp b/Main.cpp
index f90575e..2c6f7a3 100644
--- a/Main.cpp
+++ b/Main.cpp
@@ -39,6 +39,12 @@
#include <proj_api.h>
#include <geos_c.h>
+#ifdef __WXMAC__
+// Allow the program to run and recieve focus without creating an app bundle.
+#include <Carbon/Carbon.h>
+extern "C" { void CPSEnableForegroundOperation(ProcessSerialNumber* psn); }
+#endif
+
//
// ICONs in XPM format [universally portable]
//
@@ -87,6 +93,21 @@ IMPLEMENT_APP(MyApp)
frame->Show(true);
SetTopWindow(frame);
frame->LoadConfig(path);
+
+#ifdef __WXMAC__
+ // Acquire the necessary resources to run as a GUI app without being inside
+ // an app bundle.
+ //
+ // Credit for this hack goes to:
+ //
+ // http://www.miscdebris.net/blog/2010/03/30/solution-for-my-mac-os-x-gui-program-doesnt-get-focus-if-its-outside-an-application-bundle
+ ProcessSerialNumber psn;
+
+ GetCurrentProcess( &psn );
+ CPSEnableForegroundOperation( &psn );
+ SetFrontProcess( &psn );
+#endif
+
return true;
}