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_IOSMAC
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
72 struct BuildOptions_v1
74 uint64_t version
; // Future proofing, set to 1
75 const char * updateName
; // BuildTrain+UpdateNumber
76 const char * deviceName
;
77 enum Disposition disposition
; // Internal, Customer, etc.
78 enum Platform platform
; // Enum: unknown, macOS, iOS, ...
81 bool verboseDiagnostics
;
82 bool isLocallyBuiltCache
;
87 AddFile
= 0, // New file: uid, gid, mode, data, cdhash fields must be set
88 ChangeFile
= 1, // Change the data of file: data, size, and cdhash fields must be set
93 uint64_t version
; // Future proofing, set to 1
95 enum FileBehavior behavior
;
96 const uint8_t* data
; // Owned by the cache builder. Destroyed by destroySharedCacheBuilder
98 // CDHash, must be set for new or modified files
100 const char* hashType
;
107 uint64_t version
; // Future proofing, set to 1
108 const char* loggingPrefix
; // needed?
109 const char* deviceConfiguration
;
110 const char ** warnings
; // should this be per-result?
111 uint64_t numWarnings
;
112 const char ** errors
; // should this be per-result?
114 const char* uuidString
;
118 struct SharedCacheBuilder
;
120 __API_AVAILABLE(macos(10.12))
121 void getVersion(uint32_t *major
, uint32_t *minor
);
123 __API_AVAILABLE(macos(10.12))
124 struct SharedCacheBuilder
* createSharedCacheBuilder(const struct BuildOptions_v1
* options
);
126 // Add a file. Returns true on success.
127 __API_AVAILABLE(macos(10.12))
128 bool addFile(struct SharedCacheBuilder
* builder
, const char* path
, uint8_t* data
, uint64_t size
, enum FileFlags fileFlags
);
130 __API_AVAILABLE(macos(10.12))
131 bool addSymlink(struct SharedCacheBuilder
* builder
, const char* fromPath
, const char* toPath
);
133 __API_AVAILABLE(macos(10.12))
134 bool runSharedCacheBuilder(struct SharedCacheBuilder
* builder
);
136 __API_AVAILABLE(macos(10.12))
137 const char* const* getErrors(const struct SharedCacheBuilder
* builder
, uint64_t* errorCount
);
139 __API_AVAILABLE(macos(10.12))
140 const struct FileResult
* const* getFileResults(struct SharedCacheBuilder
* builder
, uint64_t* resultCount
);
142 __API_AVAILABLE(macos(10.12))
143 const struct CacheResult
* const* getCacheResults(struct SharedCacheBuilder
* builder
, uint64_t* resultCount
);
145 __API_AVAILABLE(macos(10.12))
146 const char* const* getFilesToRemove(const struct SharedCacheBuilder
* builder
, uint64_t* fileCount
);
148 __API_AVAILABLE(macos(10.12))
149 void destroySharedCacheBuilder(struct SharedCacheBuilder
* builder
);
155 #endif /* mrm_shared_cache_builder_hpp */