blob: aafffd39d84eacabd9e8a697c6643be00f6e0c09 [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 Lesinski467f1712015-11-16 17:35:44 -080022#include "xml/XmlDom.h"
Adam Lesinskia1ad4a82015-06-08 11:41:09 -070023
24#include <map>
25#include <ostream>
26#include <set>
27#include <string>
28
29namespace aapt {
30namespace proguard {
31
32class KeepSet {
33public:
Adam Lesinski1ab598f2015-08-14 14:26:04 -070034 inline void addClass(const Source& source, const std::u16string& className) {
Adam Lesinskia1ad4a82015-06-08 11:41:09 -070035 mKeepSet[className].insert(source);
36 }
37
Adam Lesinski1ab598f2015-08-14 14:26:04 -070038 inline void addMethod(const Source& source, const std::u16string& methodName) {
Adam Lesinskia1ad4a82015-06-08 11:41:09 -070039 mKeepMethodSet[methodName].insert(source);
40 }
41
42private:
43 friend bool writeKeepSet(std::ostream* out, const KeepSet& keepSet);
44
Adam Lesinski1ab598f2015-08-14 14:26:04 -070045 std::map<std::u16string, std::set<Source>> mKeepSet;
46 std::map<std::u16string, std::set<Source>> mKeepMethodSet;
Adam Lesinskia1ad4a82015-06-08 11:41:09 -070047};
48
Adam Lesinski467f1712015-11-16 17:35:44 -080049bool collectProguardRulesForManifest(const Source& source, xml::XmlResource* res, KeepSet* keepSet);
50bool collectProguardRules(const Source& source, xml::XmlResource* res, KeepSet* keepSet);
Adam Lesinskia1ad4a82015-06-08 11:41:09 -070051
52bool writeKeepSet(std::ostream* out, const KeepSet& keepSet);
53
54} // namespace proguard
55} // namespace aapt
56
57#endif // AAPT_PROGUARD_RULES_H