blob: be61eb9095c270257b2da4ea6dc452a4b8eab3f9 [file] [log] [blame]
Adam Lesinskia1ad4a82015-06-08 11:41:09 -07001/*
2 * Copyright (C) 2015 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 AAPT_PROGUARD_RULES_H
18#define AAPT_PROGUARD_RULES_H
19
20#include "Resource.h"
21#include "Source.h"
Adam Lesinski1ab598f2015-08-14 14:26:04 -070022
23#include "process/IResourceTableConsumer.h"
Adam Lesinskia1ad4a82015-06-08 11:41:09 -070024
25#include <map>
26#include <ostream>
27#include <set>
28#include <string>
29
30namespace aapt {
31namespace proguard {
32
33class KeepSet {
34public:
Adam Lesinski1ab598f2015-08-14 14:26:04 -070035 inline void addClass(const Source& source, const std::u16string& className) {
Adam Lesinskia1ad4a82015-06-08 11:41:09 -070036 mKeepSet[className].insert(source);
37 }
38
Adam Lesinski1ab598f2015-08-14 14:26:04 -070039 inline void addMethod(const Source& source, const std::u16string& methodName) {
Adam Lesinskia1ad4a82015-06-08 11:41:09 -070040 mKeepMethodSet[methodName].insert(source);
41 }
42
43private:
44 friend bool writeKeepSet(std::ostream* out, const KeepSet& keepSet);
45
Adam Lesinski1ab598f2015-08-14 14:26:04 -070046 std::map<std::u16string, std::set<Source>> mKeepSet;
47 std::map<std::u16string, std::set<Source>> mKeepMethodSet;
Adam Lesinskia1ad4a82015-06-08 11:41:09 -070048};
49
Adam Lesinski1ab598f2015-08-14 14:26:04 -070050bool collectProguardRulesForManifest(const Source& source, XmlResource* res, KeepSet* keepSet);
51bool collectProguardRules(const Source& source, XmlResource* res, KeepSet* keepSet);
Adam Lesinskia1ad4a82015-06-08 11:41:09 -070052
53bool writeKeepSet(std::ostream* out, const KeepSet& keepSet);
54
55} // namespace proguard
56} // namespace aapt
57
58#endif // AAPT_PROGUARD_RULES_H