]> git.saurik.com Git - apple/dyld.git/blob - dyld3/shared-cache/mrm_shared_cache_builder.h
dyld-635.2.tar.gz
[apple/dyld.git] / dyld3 / shared-cache / mrm_shared_cache_builder.h
1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
2 *
3 * Copyright (c) 2017 Apple Inc. All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24
25 #ifndef mrm_shared_cache_builder_hpp
26 #define mrm_shared_cache_builder_hpp
27
28 #include <Availability.h>
29
30 #include <stdint.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 // Note, this should match PLATFORM_* values in <mach-o/loader.h>
37 enum Platform {
38 unknown = 0,
39 macOS = 1, // PLATFORM_MACOS
40 iOS = 2, // PLATFORM_IOS
41 tvOS = 3, // PLATFORM_TVOS
42 watchOS = 4, // PLATFORM_WATCHOS
43 bridgeOS = 5, // PLATFORM_BRIDGEOS
44 iOSMac = 6, // PLATFORM_IOSMAC
45 iOS_simulator = 7, // PLATFORM_IOSIMULATOR
46 tvOS_simulator = 8, // PLATFORM_TVOSSIMULATOR
47 watchOS_simulator = 9 // PLATFORM_WATCHOSSIMULATOR
48 };
49
50 enum Disposition
51 {
52 Unknown = 0,
53 InternalDevelopment = 1,
54 Customer = 2,
55 InternalMinDevelopment = 3
56 };
57
58 enum FileFlags
59 {
60 // Note these are for macho inputs
61 NoFlags = 0,
62 MustBeInCache = 1,
63 ShouldBeExcludedFromCacheIfUnusedLeaf = 2,
64 RequiredClosure = 3,
65
66 // These are for the order files
67 DylibOrderFile = 100,
68 DirtyDataOrderFile = 101
69 };
70
71 struct BuildOptions_v1
72 {
73 uint64_t version; // Future proofing, set to 1
74 const char * updateName; // BuildTrain+UpdateNumber
75 const char * deviceName;
76 enum Disposition disposition; // Internal, Customer, etc.
77 enum Platform platform; // Enum: unknown, macOS, iOS, ...
78 const char ** archs;
79 uint64_t numArchs;
80 bool verboseDiagnostics;
81 bool isLocallyBuiltCache;
82 };
83
84 struct BuildResult {
85 uint64_t version; // Future proofing, set to 1
86 const char* loggingPrefix;
87 const char ** warnings;
88 uint64_t numWarnings;
89 const char ** errors;
90 uint64_t numErrors;
91 const char* sharedCachePath;
92 const char* cdHash;
93 };
94
95 struct FileResult {
96 const char* path;
97 const uint8_t* data; // Owned by the cache builder. Destroyed by destroySharedCacheBuilder
98 uint64_t size;
99 };
100
101 struct SharedCacheBuilder;
102
103 __API_AVAILABLE(macos(10.12))
104 struct SharedCacheBuilder* createSharedCacheBuilder(const struct BuildOptions_v1* options);
105
106 // Add a file. Returns true on success.
107 __API_AVAILABLE(macos(10.12))
108 bool addFile(struct SharedCacheBuilder* builder, const char* path, uint8_t* data, uint64_t size, enum FileFlags fileFlags);
109
110 __API_AVAILABLE(macos(10.12))
111 bool addSymlink(struct SharedCacheBuilder* builder, const char* fromPath, const char* toPath);
112
113 __API_AVAILABLE(macos(10.12))
114 bool runSharedCacheBuilder(struct SharedCacheBuilder* builder);
115
116 __API_AVAILABLE(macos(10.12))
117 uint64_t getErrorCount(const struct SharedCacheBuilder* builder);
118
119 __API_AVAILABLE(macos(10.12))
120 const char* getError(const struct SharedCacheBuilder* builder, uint64_t errorIndex);
121
122 __API_AVAILABLE(macos(10.12))
123 uint64_t getCacheResultCount(const struct SharedCacheBuilder* builder);
124
125 __API_AVAILABLE(macos(10.12))
126 void getCacheResult(struct SharedCacheBuilder* builder, uint64_t cacheIndex, struct BuildResult* result);
127
128 __API_AVAILABLE(macos(10.12))
129 uint64_t getFileResultCount(const struct SharedCacheBuilder* builder);
130
131 __API_AVAILABLE(macos(10.12))
132 void getFileResult(struct SharedCacheBuilder* builder, uint64_t fileIndex, struct FileResult* result);
133
134 __API_AVAILABLE(macos(10.12))
135 void destroySharedCacheBuilder(struct SharedCacheBuilder* builder);
136
137 #ifdef __cplusplus
138 }
139 #endif
140
141 #endif /* mrm_shared_cache_builder_hpp */