/
okular.rb
187 lines (169 loc) · 6.36 KB
/
okular.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
require_relative "../lib/cmake"
class Okular < Formula
desc "Document Viewer"
homepage "https://okular.kde.org"
url "https://download.kde.org/stable/release-service/23.08.2/src/okular-23.08.2.tar.xz"
sha256 "25a69e1e666925e52c57d1b09beb72ad3a61a61328daf042359c3f6a740f2edd"
head "https://invent.kde.org/graphics/okular.git", branch: "master"
depends_on "chmlib" => :build
depends_on "cmake" => [:build, :test]
depends_on "ebook-tools" => :build
depends_on "extra-cmake-modules" => [:build, :test]
depends_on "kde-mac/kde/kf5-khtml" => :build
depends_on "kdoctools" => :build
depends_on "ninja" => :build
depends_on "discount"
depends_on "djvulibre"
depends_on "freetype"
depends_on "kde-mac/kde/kf5-breeze-icons"
depends_on "kde-mac/kde/kf5-kactivities"
depends_on "kde-mac/kde/kf5-kirigami2"
depends_on "kde-mac/kde/kf5-kjs"
depends_on "kde-mac/kde/kf5-kparts"
depends_on "kde-mac/kde/kf5-kpty"
depends_on "kde-mac/kde/libkexiv2"
depends_on "kde-mac/kde/phonon"
depends_on "libspectre"
depends_on "poppler-qt5"
depends_on "qca"
depends_on "threadweaver"
depends_on "zlib"
patch :DATA
def install
args = %w[
-DCMAKE_DISABLE_FIND_PACKAGE_KF5Purpose=YES
-DCMAKE_DISABLE_FIND_PACKAGE_QMobipocket=YES
]
system "cmake", *kde_cmake_args, *args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
prefix.install "build/install_manifest.txt"
# Extract Qt plugin and QML2 path
mkdir "getqmlpath" do
(Pathname.pwd/"main.cpp").write <<~EOS
#include <QTextStream>
#include <QLibraryInfo>
int main() {
QTextStream out(stdout);
out << QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath) << endl;
}
EOS
(Pathname.pwd/"qmlpath.pro").write <<~EOS
QT += core
TEMPLATE = app
TARGET = qmlpath
CONFIG += cmdline
CONFIG += silent
SOURCES += main.cpp
EOS
system "#{Formula["qt@5"].bin}/qmake"
system "make"
end
qtpp = Utils.safe_popen_read("#{Formula["qt@5"].bin}/qtpaths", "--plugin-dir").chomp
qml2pp = Utils.safe_popen_read("./getqmlpath/qmlpath").chomp
system "/usr/libexec/PlistBuddy",
"-c", "Add :LSEnvironment:QT_PLUGIN_PATH string \"#{qtpp}\:#{HOMEBREW_PREFIX}/lib/qt5/plugins\"",
"#{bin}/okular.app/Contents/Info.plist"
system "/usr/libexec/PlistBuddy",
"-c", "Add :LSEnvironment:QT_PLUGIN_PATH string \"#{qtpp}\:#{HOMEBREW_PREFIX}/lib/qt5/plugins\"",
"-c", "Add :LSEnvironment:QML2_IMPORT_PATH string \"#{qml2pp}\:#{HOMEBREW_PREFIX}/lib/qt5/qml\"",
"#{bin}/okularkirigami.app/Contents/Info.plist"
end
def post_install
mkdir_p HOMEBREW_PREFIX/"share/okular"
ln_sf HOMEBREW_PREFIX/"share/icons/breeze/breeze-icons.rcc", HOMEBREW_PREFIX/"share/okular/icontheme.rcc"
end
def caveats
<<~EOS
You need to take some manual steps in order to make this formula work:
"$(brew --repo kde-mac/kde)/tools/do-caveats.sh"
EOS
end
test do
assert_match "help", shell_output("#{bin}/okular.app/Contents/MacOS/okular --help")
end
end
# Fix build
# Fix Retina display
__END__
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 579379dc8..cd59e37f3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -261,7 +261,7 @@ endif()
# Special handling for linking okularcore on OSX/Apple
IF(APPLE)
- SET(OKULAR_IOKIT "-framework IOKit" CACHE STRING "Apple IOKit framework")
+ SET(OKULAR_IOKIT "-framework CoreFoundation -framework CoreGraphics -framework IOKit" CACHE STRING "Apple IOKit framework")
ENDIF(APPLE)
# Extra library needed by imported synctex code on Windows
diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt
index 628f74be1..f4e807dc5 100644
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@ -25,6 +25,7 @@ if(TARGET KF5::Activities)
target_link_libraries(okular KF5::Activities)
endif()
+set_target_properties(okular PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/MacOSXBundleInfo.plist.in)
install(TARGETS okular ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/shell/MacOSXBundleInfo.plist.in b/shell/MacOSXBundleInfo.plist.in
new file mode 100644
index 000000000..ab421eaf8
--- /dev/null
+++ b/shell/MacOSXBundleInfo.plist.in
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+ <key>NSHighResolutionCapable</key>
+ <string>True</string>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+ <key>CFBundleGetInfoString</key>
+ <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+ <key>CFBundleIconFile</key>
+ <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleLongVersionString</key>
+ <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+ <key>CFBundleName</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+ <key>CSResourcesFileMapped</key>
+ <true/>
+ <key>LSRequiresCarbon</key>
+ <true/>
+ <key>NSHumanReadableCopyright</key>
+ <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+ <key>LSMultipleInstancesProhibited</key>
+ <true/>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeExtensions</key>
+ <array>
+ <string>*</string>
+ </array>
+ <key>CFBundleTypeName</key>
+ <string>NSStringPboardType</string>
+ <key>CFBundleTypeRole</key>
+ <string>Editor</string>
+ </dict>
+ </array>
+</dict>
+</plist>