xref: /aosp_15_r20/build/make/tools/zipalign/include/ZipAlign.h (revision 9e94795a3d4ef5c1d47486f9a02bb378756cea8a)
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ZIPALIGN_H
18 #define ZIPALIGN_H
19 
20 namespace android {
21 
22 /*
23  * Generate a new, aligned, zip "output" from an "input" zip.
24  * - alignTo: Alignment (in bytes) for uncompressed entries.
25  * - force  : Overwrite output if it exists, fail otherwise.
26  * - zopfli : Recompress compressed entries with more efficient algorithm.
27  *            Copy compressed entries as-is, and unaligned, otherwise.
28  * - pageAlignSharedLibs: Align .so files to @pageSize and other files to
29  *   alignTo, or all files to alignTo if false..
30  * - pageSize: Specifies the page size of the target device. This is used
31  *             to correctly page-align shared libraries.
32  *
33  * Returns 0 on success.
34  */
35 int process(const char* input, const char* output, int alignTo, bool force,
36     bool zopfli, bool pageAlignSharedLibs, int pageSize);
37 
38 /*
39  * Verify the alignment of a zip archive.
40  * - alignTo: Alignment (in bytes) for uncompressed entries.
41  * - pageAlignSharedLibs: Align .so files to @pageSize and other files to
42  *   alignTo, or all files to alignTo if false..
43  * - pageSize: Specifies the page size of the target device. This is used
44  *             to correctly page-align shared libraries.
45  *
46  * Returns 0 on success.
47  */
48 int verify(const char* fileName, int alignTo, bool verbose,
49     bool pageAlignSharedLibs, int pageSize);
50 
51 } // namespace android
52 
53 #endif // ZIPALIGN_H
54