1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
3 * Copyright (c) 2017 Apple Inc. All rights reserved.
5 * @APPLE_LICENSE_HEADER_START@
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
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.
22 * @APPLE_LICENSE_HEADER_END@
25 #ifndef mrm_shared_cache_builder_hpp
26 #define mrm_shared_cache_builder_hpp
28 #include <Availability.h>
31 #include <sys/types.h>
37 // Note, this should match PLATFORM_* values in <mach-o/loader.h>
40 macOS
= 1, // PLATFORM_MACOS
41 iOS
= 2, // PLATFORM_IOS
42 tvOS
= 3, // PLATFORM_TVOS
43 watchOS
= 4, // PLATFORM_WATCHOS
44 bridgeOS
= 5, // PLATFORM_BRIDGEOS
45 iOSMac
= 6, // PLATFORM_MACCATALYST
46 iOS_simulator
= 7, // PLATFORM_IOSIMULATOR
47 tvOS_simulator
= 8, // PLATFORM_TVOSSIMULATOR
48 watchOS_simulator
= 9 // PLATFORM_WATCHOSSIMULATOR
54 InternalDevelopment
= 1,
56 InternalMinDevelopment
= 3
61 // Note these are for macho inputs
64 ShouldBeExcludedFromCacheIfUnusedLeaf
= 2,
67 // These are for the order files
69 DirtyDataOrderFile
= 101,
70 ObjCOptimizationsFile
= 102,
73 struct BuildOptions_v1
75 uint64_t version
; // Future proofing, set to 1
76 const char * updateName
; // BuildTrain+UpdateNumber
77 const char * deviceName
;
78 enum Disposition disposition
; // Internal, Customer, etc.
79 enum Platform platform
; // Enum: unknown, macOS, iOS, ...
82 bool verboseDiagnostics
;
83 bool isLocallyBuiltCache
;
86 // This is available when getVersion() returns 1.2 or higher
87 struct BuildOptions_v2
89 uint64_t version
; // Future proofing, set to 2
90 const char * updateName
; // BuildTrain+UpdateNumber
91 const char * deviceName
;
92 enum Disposition disposition
; // Internal, Customer, etc.
93 enum Platform platform
; // Enum: unknown, macOS, iOS, ...
96 bool verboseDiagnostics
;
97 bool isLocallyBuiltCache
;
104 AddFile
= 0, // New file: uid, gid, mode, data, cdhash fields must be set
105 ChangeFile
= 1, // Change the data of file: data, size, and cdhash fields must be set
110 uint64_t version
; // Future proofing, set to 1
112 enum FileBehavior behavior
;
113 const uint8_t* data
; // Owned by the cache builder. Destroyed by destroySharedCacheBuilder
115 // CDHash, must be set for new or modified files
116 const char* hashArch
;
117 const char* hashType
;
124 uint64_t version
; // Future proofing, set to 1
125 const char* loggingPrefix
; // needed?
126 const char* deviceConfiguration
;
127 const char ** warnings
; // should this be per-result?
128 uint64_t numWarnings
;
129 const char ** errors
; // should this be per-result?
131 const char* uuidString
;
135 struct MRMSharedCacheBuilder
;
137 __API_AVAILABLE(macos(10.12))
138 void getVersion(uint32_t *major
, uint32_t *minor
);
140 __API_AVAILABLE(macos(10.12))
141 struct MRMSharedCacheBuilder
* createSharedCacheBuilder(const struct BuildOptions_v1
* options
);
143 // Add a file. Returns true on success.
144 __API_AVAILABLE(macos(10.12))
145 bool addFile(struct MRMSharedCacheBuilder
* builder
, const char* path
, uint8_t* data
, uint64_t size
, enum FileFlags fileFlags
);
147 __API_AVAILABLE(macos(10.12))
148 bool addSymlink(struct MRMSharedCacheBuilder
* builder
, const char* fromPath
, const char* toPath
);
150 __API_AVAILABLE(macos(10.12))
151 bool runSharedCacheBuilder(struct MRMSharedCacheBuilder
* builder
);
153 __API_AVAILABLE(macos(10.12))
154 const char* const* getErrors(const struct MRMSharedCacheBuilder
* builder
, uint64_t* errorCount
);
156 __API_AVAILABLE(macos(10.12))
157 const struct FileResult
* const* getFileResults(struct MRMSharedCacheBuilder
* builder
, uint64_t* resultCount
);
159 __API_AVAILABLE(macos(10.12))
160 const struct CacheResult
* const* getCacheResults(struct MRMSharedCacheBuilder
* builder
, uint64_t* resultCount
);
162 __API_AVAILABLE(macos(10.12))
163 const char* const* getFilesToRemove(const struct MRMSharedCacheBuilder
* builder
, uint64_t* fileCount
);
165 __API_AVAILABLE(macos(10.12))
166 void destroySharedCacheBuilder(struct MRMSharedCacheBuilder
* builder
);
172 #endif /* mrm_shared_cache_builder_hpp */