Skip to content

Commit c537455

Browse files
committed
handle assets
1 parent 02180ab commit c537455

6 files changed

Lines changed: 171 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,5 @@ fastlane/test_output
7272
fastlane/report.xml
7373

7474
conan-output/
75+
conan-assets/
7576
graph_info.json

OpenDocumentReader.xcodeproj/project.pbxproj

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 56;
6+
objectVersion = 70;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -38,6 +38,20 @@
3838
E2F7ED61220B54D700D63515 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2F7ED5F220B54D700D63515 /* LaunchScreen.storyboard */; };
3939
/* End PBXBuildFile section */
4040

41+
/* Begin PBXBuildRule section */
42+
E15897752DF6377C00319830 /* PBXBuildRule */ = {
43+
isa = PBXBuildRule;
44+
compilerSpec = com.apple.compilers.proxy.script;
45+
fileType = pattern.proxy;
46+
inputFiles = (
47+
);
48+
isEditable = 1;
49+
outputFiles = (
50+
);
51+
script = "# Type a script or drag a script file from your workspace to insert its path.\n";
52+
};
53+
/* End PBXBuildRule section */
54+
4155
/* Begin PBXContainerItemProxy section */
4256
E22B25312557F0E2001D0C52 /* PBXContainerItemProxy */ = {
4357
isa = PBXContainerItemProxy;
@@ -115,6 +129,23 @@
115129
F441BA4458128EC8A16A91C9 /* Pods-OpenDocumentReaderTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OpenDocumentReaderTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-OpenDocumentReaderTests/Pods-OpenDocumentReaderTests.release.xcconfig"; sourceTree = "<group>"; };
116130
/* End PBXFileReference section */
117131

132+
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
133+
E15897762DF637BD00319830 /* PBXFileSystemSynchronizedBuildFileExceptionSet */ = {
134+
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
135+
membershipExceptions = (
136+
odrcore/odr_spreadsheet.css,
137+
odrcore/odr_spreadsheet.js,
138+
odrcore/odr.css,
139+
odrcore/odr.js,
140+
);
141+
target = E2F7ED4E220B54D600D63515 /* OpenDocumentReader */;
142+
};
143+
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
144+
145+
/* Begin PBXFileSystemSynchronizedRootGroup section */
146+
E15897702DF631AF00319830 /* conan-assets */ = {isa = PBXFileSystemSynchronizedRootGroup; exceptions = (E15897762DF637BD00319830 /* PBXFileSystemSynchronizedBuildFileExceptionSet */, ); explicitFileTypes = {}; explicitFolders = (); path = "conan-assets"; sourceTree = "<group>"; };
147+
/* End PBXFileSystemSynchronizedRootGroup section */
148+
118149
/* Begin PBXFrameworksBuildPhase section */
119150
E22B25292557F0E2001D0C52 /* Frameworks */ = {
120151
isa = PBXFrameworksBuildPhase;
@@ -198,6 +229,7 @@
198229
E2F7ED46220B54D600D63515 = {
199230
isa = PBXGroup;
200231
children = (
232+
E15897702DF631AF00319830 /* conan-assets */,
201233
E17AF34D2C258C5100FBED6A /* configs */,
202234
E2F7ED51220B54D600D63515 /* OpenDocumentReader */,
203235
E22B252D2557F0E2001D0C52 /* OpenDocumentReaderTests */,
@@ -270,11 +302,16 @@
270302
F435F37405C0FE5E8503721A /* [CP] Embed Pods Frameworks */,
271303
E2C41D0F226DEF390049EF8E /* Run Script */,
272304
F8CA8E81987336E1DB902130 /* [CP] Copy Pods Resources */,
305+
E158977C2DF640E700319830 /* [CP] Copy Conan Resources */,
273306
);
274307
buildRules = (
308+
E15897752DF6377C00319830 /* PBXBuildRule */,
275309
);
276310
dependencies = (
277311
);
312+
fileSystemSynchronizedGroups = (
313+
E15897702DF631AF00319830 /* conan-assets */,
314+
);
278315
name = OpenDocumentReader;
279316
productName = "OpenDocument Reader";
280317
productReference = 52A348B12A9262D100DACAB9 /* OpenDocumentReader.app */;
@@ -404,6 +441,26 @@
404441
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
405442
showEnvVarsInLog = 0;
406443
};
444+
E158977C2DF640E700319830 /* [CP] Copy Conan Resources */ = {
445+
isa = PBXShellScriptBuildPhase;
446+
buildActionMask = 2147483647;
447+
files = (
448+
);
449+
inputFileListPaths = (
450+
"${PROJECT_DIR}/conan-assets/input-files.xcfilelist",
451+
);
452+
inputPaths = (
453+
);
454+
name = "[CP] Copy Conan Resources";
455+
outputFileListPaths = (
456+
"${PROJECT_DIR}/conan-assets/output-files.xcfilelist",
457+
);
458+
outputPaths = (
459+
);
460+
runOnlyForDeploymentPostprocessing = 0;
461+
shellPath = /bin/sh;
462+
shellScript = "\"${PROJECT_DIR}/conan/copy-resources.sh\"\n";
463+
};
407464
E2C41D0F226DEF390049EF8E /* Run Script */ = {
408465
isa = PBXShellScriptBuildPhase;
409466
buildActionMask = 2147483647;
@@ -431,10 +488,14 @@
431488
inputFileListPaths = (
432489
"${PODS_ROOT}/Target Support Files/Pods-OpenDocumentReader/Pods-OpenDocumentReader-frameworks-${CONFIGURATION}-input-files.xcfilelist",
433490
);
491+
inputPaths = (
492+
);
434493
name = "[CP] Embed Pods Frameworks";
435494
outputFileListPaths = (
436495
"${PODS_ROOT}/Target Support Files/Pods-OpenDocumentReader/Pods-OpenDocumentReader-frameworks-${CONFIGURATION}-output-files.xcfilelist",
437496
);
497+
outputPaths = (
498+
);
438499
runOnlyForDeploymentPostprocessing = 0;
439500
shellPath = /bin/sh;
440501
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-OpenDocumentReader/Pods-OpenDocumentReader-frameworks.sh\"\n";
@@ -448,10 +509,14 @@
448509
inputFileListPaths = (
449510
"${PODS_ROOT}/Target Support Files/Pods-OpenDocumentReader/Pods-OpenDocumentReader-resources-${CONFIGURATION}-input-files.xcfilelist",
450511
);
512+
inputPaths = (
513+
);
451514
name = "[CP] Copy Pods Resources";
452515
outputFileListPaths = (
453516
"${PODS_ROOT}/Target Support Files/Pods-OpenDocumentReader/Pods-OpenDocumentReader-resources-${CONFIGURATION}-output-files.xcfilelist",
454517
);
518+
outputPaths = (
519+
);
455520
runOnlyForDeploymentPostprocessing = 0;
456521
shellPath = /bin/sh;
457522
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-OpenDocumentReader/Pods-OpenDocumentReader-resources.sh\"\n";
@@ -606,6 +671,7 @@
606671
CODE_SIGN_STYLE = Automatic;
607672
CURRENT_PROJECT_VERSION = 42;
608673
DEFINES_MODULE = YES;
674+
DEVELOPMENT_ASSET_PATHS = "conan-assets";
609675
DEVELOPMENT_TEAM = 5LS6X97G6J;
610676
ENABLE_BITCODE = NO;
611677
ENABLE_USER_SCRIPT_SANDBOXING = NO;
@@ -697,6 +763,7 @@
697763
CODE_SIGN_STYLE = Automatic;
698764
CURRENT_PROJECT_VERSION = 42;
699765
DEFINES_MODULE = YES;
766+
DEVELOPMENT_ASSET_PATHS = "conan-assets";
700767
DEVELOPMENT_TEAM = 5LS6X97G6J;
701768
ENABLE_BITCODE = NO;
702769
ENABLE_USER_SCRIPT_SANDBOXING = NO;
@@ -932,6 +999,7 @@
932999
CODE_SIGN_STYLE = Automatic;
9331000
CURRENT_PROJECT_VERSION = 42;
9341001
DEFINES_MODULE = YES;
1002+
DEVELOPMENT_ASSET_PATHS = "conan-assets";
9351003
DEVELOPMENT_TEAM = 5LS6X97G6J;
9361004
ENABLE_BITCODE = NO;
9371005
ENABLE_USER_SCRIPT_SANDBOXING = NO;
@@ -967,6 +1035,7 @@
9671035
CODE_SIGN_STYLE = Automatic;
9681036
CURRENT_PROJECT_VERSION = 42;
9691037
DEFINES_MODULE = YES;
1038+
DEVELOPMENT_ASSET_PATHS = "conan-assets";
9701039
DEVELOPMENT_TEAM = 5LS6X97G6J;
9711040
ENABLE_BITCODE = NO;
9721041
ENABLE_USER_SCRIPT_SANDBOXING = NO;

OpenDocumentReader/CoreWrapper.mm

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <odr/html_service.hpp>
1818
#include <odr/odr.hpp>
1919
#include <odr/exceptions.hpp>
20+
#include <odr/global_params.hpp>
2021

2122
#include <string>
2223
#include <optional>
@@ -35,6 +36,10 @@ - (bool)translate:(NSString *)inputPath cache:(NSString *)cachePath into:(NSStri
3536
_pageNames = nil;
3637
_pagePaths = nil;
3738

39+
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
40+
std::string bundlePathCpp = std::string([bundlePath UTF8String]);
41+
odr::GlobalParams::set_odr_core_data_path(bundlePathCpp + "/odrcore");
42+
3843
html.reset();
3944

4045
odr::HtmlConfig config;
@@ -44,7 +49,7 @@ - (bool)translate:(NSString *)inputPath cache:(NSString *)cachePath into:(NSStri
4449
password = @"";
4550
}
4651

47-
auto inputPathC = [inputPath cStringUsingEncoding:NSUTF8StringEncoding];
52+
auto inputPathC = [inputPath UTF8String];
4853
auto inputPathCpp = std::string(inputPathC);
4954

5055
std::vector<odr::FileType> fileTypes;
@@ -64,10 +69,10 @@ - (bool)translate:(NSString *)inputPath cache:(NSString *)cachePath into:(NSStri
6469
return false;
6570
}
6671

67-
auto outputPathC = [outputPath cStringUsingEncoding:NSUTF8StringEncoding];
72+
auto outputPathC = [outputPath UTF8String];
6873
auto outputPathCpp = std::string(outputPathC);
6974

70-
auto cachePathC = [cachePath cStringUsingEncoding:NSUTF8StringEncoding];
75+
auto cachePathC = [cachePath UTF8String];
7176
auto cachePathCpp = std::string(cachePathC);
7277

7378
odr::DecodedFile file = odr::open(inputPathCpp);
@@ -118,9 +123,9 @@ - (bool)backTranslate:(NSString *)diff into:(NSString *)outputPath {
118123
try {
119124
_errorCode = 0;
120125

121-
odr::html::edit(*document, [diff cStringUsingEncoding:NSUTF8StringEncoding]);
126+
odr::html::edit(*document, [diff UTF8String]);
122127

123-
document->save([outputPath cStringUsingEncoding:NSUTF8StringEncoding]);
128+
document->save([outputPath UTF8String]);
124129
} catch (...) {
125130
_errorCode = @(-3);
126131
return false;

conan/conandeployer.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import shutil
2+
from pathlib import Path
3+
4+
5+
def deploy(graph, output_folder: str, **kwargs):
6+
output_folder = Path(output_folder).resolve()
7+
8+
conanfile = graph.root.conanfile
9+
conanfile.output.info(f"Custom deployer to {output_folder}")
10+
11+
symlinks = conanfile.conf.get(
12+
"tools.deployer:symlinks", check_type=bool, default=True
13+
)
14+
arch = conanfile.settings.get_safe("arch")
15+
16+
conanfile.output.info(f"Symlinks: {symlinks}")
17+
conanfile.output.info(f"Arch: {arch}")
18+
19+
deps = {dep.ref.name: dep for dep in conanfile.dependencies.values()}
20+
21+
print(f"Dependencies: {list(deps.keys())}")
22+
23+
copytree_kwargs = {"symlinks": symlinks, "dirs_exist_ok": True}
24+
25+
if "odrcore" in deps:
26+
dep = deps["odrcore"]
27+
conanfile.output.info(f"Deploying odrcore to {output_folder}")
28+
shutil.copytree(
29+
f"{dep.package_folder}/share",
30+
f"{output_folder}/odrcore",
31+
**copytree_kwargs,
32+
)
33+
34+
if "pdf2htmlex" in deps:
35+
dep = deps["pdf2htmlex"]
36+
conanfile.output.info(f"Deploying pdf2htmlex to {output_folder}")
37+
shutil.copytree(
38+
f"{dep.package_folder}/share/pdf2htmlEX",
39+
f"{output_folder}/pdf2htmlex",
40+
**copytree_kwargs,
41+
)
42+
43+
if "poppler-data" in deps:
44+
dep = deps["poppler-data"]
45+
conanfile.output.info(f"Deploying poppler-data to {output_folder}")
46+
shutil.copytree(
47+
f"{dep.package_folder}/share/poppler",
48+
f"{output_folder}/poppler",
49+
**copytree_kwargs,
50+
)
51+
52+
if "fontconfig" in deps:
53+
dep = deps["fontconfig"]
54+
conanfile.output.info(f"Deploying fontconfig to {output_folder}")
55+
shutil.copytree(
56+
f"{dep.package_folder}/res/share",
57+
f"{output_folder}/fontconfig",
58+
**copytree_kwargs,
59+
)
60+
61+
with (
62+
open(f"{output_folder}/input-files.xcfilelist", "w") as f_in,
63+
open(f"{output_folder}/output-files.xcfilelist", "w") as f_out,
64+
):
65+
for file in Path(output_folder).glob("**/*"):
66+
file = file.relative_to(output_folder)
67+
if file.suffix == ".xcfilelist":
68+
continue
69+
f_in.write(f"$(PROJECT_DIR)/{output_folder.name}/{file}\n")
70+
f_out.write(
71+
f"${{TARGET_BUILD_DIR}}/${{UNLOCALIZED_RESOURCES_FOLDER_PATH}}/{file}\n"
72+
)

conan/copy-resources.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -e
3+
set -u
4+
set -o pipefail
5+
6+
mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
7+
8+
# copy all resources from "${PROJECT_DIR}/conan-assets" to "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
9+
# but ignore .xcfilelist
10+
rsync -av --exclude='*.xcfilelist' "${PROJECT_DIR}/conan-assets/" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/"

conan/setup-all.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
55
cd $DIR/..
66

7+
# assets
8+
conan install conan/ \
9+
--output-folder=conan-output \
10+
--build=missing \
11+
--profile:host=conan/profiles/ios \
12+
--deployer=conan/conandeployer.py \
13+
--deployer-folder=conan-assets
14+
715
# device
816
for configuration in "Debug" "Debug Lite" "Release" "Release Lite"; do
917
conan install conan/ \

0 commit comments

Comments
 (0)