Skip to content

Commit 0ad9c35

Browse files
committed
Improve Mac version by providing the cache
1 parent 2606b69 commit 0ad9c35

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

qt/deploy-mac

+24-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/bin/sh
22

3-
# Usage: ./deploy-mac [build-dir] [codesign]
4-
# where build-dir is the folder where the executable has already been built (by default, "build/")
3+
# Usage: ./deploy-mac [build-dir] [cache-dir] [codesign]
4+
# where build-dir is the folder where the executable has already been built (by default, "build/"),
5+
# cache-dir is the folder where the bibref-addbooks-cache indices are present,
56
# and codesign is the input for performing an optional code signing.
67

78
BUILD_DIR="$1"
@@ -10,6 +11,11 @@ if [ "$BUILD_DIR" = "" ]; then
1011
BUILD_DIR="build/"
1112
fi
1213

14+
CACHE_DIR="$2"
15+
if [ "$CACHE_DIR" = "" ]; then
16+
CACHE_DIR="../build/bibref-addbooks-cache"
17+
fi
18+
1319
MACDEPLOYQT=$(command -v macdeployqt)
1420
if [ ! -x "$MACDEPLOYQT" ]; then
1521
echo "macdeployqt is not in path."
@@ -21,11 +27,19 @@ test -d "$BUILD_DIR/bibref-qt.app/" || {
2127
exit 2
2228
}
2329

24-
test -d bin || {
25-
mkdir bin
26-
cp -R $BUILD_DIR/bibref-qt.app bin
30+
test -d bin && {
31+
echo "The bin folder should be removed first."
32+
exit 3
33+
}
34+
35+
test -d "$CACHE_DIR" || {
36+
echo "Build the cli version first and generate the cache via addbooks."
37+
exit 4
2738
}
2839

40+
mkdir bin
41+
cp -R $BUILD_DIR/bibref-qt.app bin
42+
2943
mkdir -p "bin/bibref-qt.app/Contents/Resources/statements/"
3044
mkdir -p "bin/bibref-qt.app/Contents/Resources/statements/SBLGNT"
3145
mkdir -p "bin/bibref-qt.app/Contents/Resources/statements/StatResGNT"
@@ -38,8 +52,11 @@ rm -fr bin/bibref-qt.app/Contents/Resources/statements/all
3852
unzip ../sword-lxx-sblgnt-statresgnt-kjv-fallback.zip -d bin/bibref-qt.app/Contents/Resources
3953
mv bin/bibref-qt.app/Contents/Resources/.sword bin/bibref-qt.app/Contents/Resources/sword
4054

41-
if [ -z "$2" ]; then
55+
# Put the cache in the bundle
56+
cp -R $CACHE_DIR bin/bibref-qt.app/Contents/Resources
57+
58+
if [ -z "$3" ]; then
4259
$MACDEPLOYQT bin/bibref-qt.app -dmg
4360
else
44-
$MACDEPLOYQT bin/bibref-qt.app -dmg -codesign="$2"
61+
$MACDEPLOYQT bin/bibref-qt.app -dmg -codesign="$3"
4562
fi

qt/main.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ int main(int argc, char *argv[])
9898
if (home)
9999
std::filesystem::current_path(std::getenv("XDG_DATA_HOME"));
100100
copy_sword_files();
101+
#ifdef __APPLE__
102+
// Set current working directory to Resources to have direct access to the cache:
103+
QString workingDirectory = qApp -> applicationDirPath();
104+
QString d1 = workingDirectory + QDir::separator() + ".." + QDir::separator() + "Resources";
105+
QDir::setCurrent(d1);
106+
#endif // __APPLE__
101107
window.show();
102108
return app.exec();
103109
}

qt/statementwindow.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ void StatementWindow::openFile(const QString &path)
5050
QString d4 = directory + QDir::separator() + ".." + QDir::separator()
5151
+ "share" + QDir::separator() + "statements";
5252
const QFileInfo f4(d4);
53+
QString d5 = directory + QDir::separator() + ".." + QDir::separator()
54+
+ "Resources" + QDir::separator() + "statements";
55+
const QFileInfo f5(d5);
5356
if (f1.exists() && f1.isDir())
5457
directory = d1;
5558
else if (f2.exists() && f2.isDir())
@@ -58,6 +61,8 @@ void StatementWindow::openFile(const QString &path)
5861
directory = d3;
5962
else if (f4.exists() && f4.isDir())
6063
directory = d4;
64+
else if (f5.exists() && f5.isDir())
65+
directory = d5;
6166
}
6267

6368
if (fileName.isNull()) {

0 commit comments

Comments
 (0)