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>
36 // Note, this should match PLATFORM_* values in <mach-o/loader.h>
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
53 InternalDevelopment
= 1,
55 InternalMinDevelopment
= 3
60 // Note these are for macho inputs
63 ShouldBeExcludedFromCacheIfUnusedLeaf
= 2,
66 // These are for the order files
68 DirtyDataOrderFile
= 101
71 struct BuildOptions_v1
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, ...
80 bool verboseDiagnostics
;
81 bool isLocallyBuiltCache
;
85 uint64_t version
; // Future proofing, set to 1
86 const char* loggingPrefix
;
87 const char ** warnings
;
91 const char* sharedCachePath
;
97 const uint8_t* data
; // Owned by the cache builder. Destroyed by destroySharedCacheBuilder
101 struct SharedCacheBuilder
;
103 __API_AVAILABLE(macos(10.12))
104 struct SharedCacheBuilder
* createSharedCacheBuilder(const struct BuildOptions_v1
* options
);
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
);
110 __API_AVAILABLE(macos(10.12))
111 bool addSymlink(struct SharedCacheBuilder
* builder
, const char* fromPath
, const char* toPath
);
113 __API_AVAILABLE(macos(10.12))
114 bool runSharedCacheBuilder(struct SharedCacheBuilder
* builder
);
116 __API_AVAILABLE(macos(10.12))
117 uint64_t getErrorCount(const struct SharedCacheBuilder
* builder
);
119 __API_AVAILABLE(macos(10.12))
120 const char* getError(const struct SharedCacheBuilder
* builder
, uint64_t errorIndex
);
122 __API_AVAILABLE(macos(10.12))
123 uint64_t getCacheResultCount(const struct SharedCacheBuilder
* builder
);
125 __API_AVAILABLE(macos(10.12))
126 void getCacheResult(struct SharedCacheBuilder
* builder
, uint64_t cacheIndex
, struct BuildResult
* result
);
128 __API_AVAILABLE(macos(10.12))
129 uint64_t getFileResultCount(const struct SharedCacheBuilder
* builder
);
131 __API_AVAILABLE(macos(10.12))
132 void getFileResult(struct SharedCacheBuilder
* builder
, uint64_t fileIndex
, struct FileResult
* result
);
134 __API_AVAILABLE(macos(10.12))
135 void destroySharedCacheBuilder(struct SharedCacheBuilder
* builder
);
141 #endif /* mrm_shared_cache_builder_hpp */