blob: 9142bd51aedbf286bf3383a8849dc6cca07cd7b7 [file] [log] [blame]
Bob Badour92ecf7c2021-02-12 18:05:29 -08001package {
Etienne Ruffieux917abc32022-02-28 14:07:17 +00002 default_visibility: [":__subpackages__"],
Bob Badour92ecf7c2021-02-12 18:05:29 -08003 default_applicable_licenses: ["system_bt_license"],
4}
5
6// Added automatically by a large-scale-change that took the approach of
7// 'apply every license found to every target'. While this makes sure we respect
8// every license restriction, it may not be entirely correct.
9//
10// e.g. GPL in an MIT project might only apply to the contrib/ directory.
11//
12// Please consider splitting the single license below into multiple licenses,
13// taking care not to lose any license_kind information, and overriding the
14// default license using the 'licenses: [...]' property on targets as needed.
15//
16// For unused files, consider creating a 'fileGroup' with "//visibility:private"
17// to attach the license to, and including a comment whether the files may be
18// used in the current project.
19// See: http://go/android-license-faq
20license {
21 name: "system_bt_license",
22 visibility: [":__subpackages__"],
23 license_kinds: [
24 "SPDX-license-identifier-Apache-2.0",
25 "SPDX-license-identifier-BSD",
26 "SPDX-license-identifier-MIT",
27 "legacy_unencumbered",
28 ],
29 license_text: [
30 "NOTICE",
31 ],
32}
33
Jack Hecac30a22018-08-28 18:28:55 -070034filegroup {
Colin Cross03e29e52019-05-23 14:12:59 -070035 name: "BluetoothTestConfigTemplate",
36 srcs: [
37 "AndroidTestTemplate.xml",
38 ],
Jack Hecac30a22018-08-28 18:28:55 -070039}
David Duartea84ffd12023-03-28 17:58:57 +000040
David Duarte4043a702023-06-04 16:44:03 +000041// This default contains properties that should be common to all the cc targets
42// developed by the Bluetooth team.
43//
44// Be careful when adding new properties here:
45// - The option should not impact negatively any target, for example "-Wno-*"
46// options should not be added here but instead on every targets needing
47// them to avoid allowing adding new warnings in targets that didn't contained
48// them (you can use the bpmodify tool to ease the work of adding this warning
49// everywhere) and also allows cleaning them one at a time.
50//
51// - The option should apply to all the c/c++ code developed by the Bluetooth team:
52// test, tools, fuzzers, etc, not only production targets, if you need to add an option
53// for a subset of Bluetooth cc targets you should look at the defaults including this
54// defaults like "fluoride_defaults" and "gd_defaults".
55//
56// - Try to keep the name as precise as possible to document to the dependent of what
57// this default contains. This also means that if you add a new option that isn't
58// documented by the name of this default, rename it.
59//
William Escande22560942024-09-18 16:44:36 -070060// - Try avoiding adding option that would not fit "future" targets, for example dependencies,
David Duarte4043a702023-06-04 16:44:03 +000061// even if every modules of Bluetooth depends on a specific dependency it should be left out
62// from this default to not push it for future targets that might not need it.
63cc_defaults {
64 name: "bluetooth_cflags",
65 cflags: [
66 "-Wall",
67 "-Werror",
68 "-Wextra",
Henri Chataing22f5e112024-09-21 01:20:25 +000069 "-Wmissing-prototypes",
William Escande27297182023-10-09 17:15:04 -070070 // Override global.go that demote the error to a warning
David Duartec8d2a492024-04-11 18:02:38 +000071 "-Werror=format",
William Escande27297182023-10-09 17:15:04 -070072 "-Werror=reorder-init-list",
David Duarte4043a702023-06-04 16:44:03 +000073 ],
David Duarte19954d12023-08-01 14:07:56 +000074 c_std: "c99",
Myles Watsondbd43e72024-02-15 11:02:58 -080075 cpp_std: "c++20",
David Duarte4043a702023-06-04 16:44:03 +000076}
William Escande22560942024-09-18 16:44:36 -070077
Henri Chataing31dba772024-10-18 14:33:17 -070078// List of tidy checks that are enabled for cc targets.
79// Note that the goal is not to enable all checks, many of them will
80// appear as noise especially in the modernize-* range.
81bluetooth_tidy_checks = [
82 "-*",
83 "misc-*",
84
85 // This check implements detection of local variables which could be declared
86 // as const but are not.
87 "-misc-const-correctness",
Henri Chataing693806a2024-10-23 20:45:34 +000088
89 // Finds classes that contain non-static data members in addition to user-declared
90 // non-static member functions and diagnose all data members declared with a
91 // non-public access specifier.
92 "-misc-non-private-member-variables-in-classes",
Henri Chataing31dba772024-10-18 14:33:17 -070093]
94
95// This default tidy checks that will be run against all the cc targets
96// developed by the Bluetooth team.
97cc_defaults {
98 name: "bluetooth_tidy",
99 tidy: true,
100 tidy_checks: bluetooth_tidy_checks,
101 tidy_checks_as_errors: bluetooth_tidy_checks,
102}
103
William Escande22560942024-09-18 16:44:36 -0700104java_defaults {
105 name: "bluetooth_errorprone_rules",
106 errorprone: {
107 enabled: true,
108 javacflags: [
109 "-Xep:AlmostJavadoc:ERROR",
110 "-Xep:AlreadyChecked:ERROR",
111 "-Xep:BadImport:ERROR",
112 "-Xep:CatchAndPrintStackTrace:ERROR",
113 "-Xep:CatchFail:ERROR",
114 "-Xep:CheckReturnValue:ERROR",
115 "-Xep:ClassCanBeStatic:ERROR",
116 "-Xep:DateFormatConstant:ERROR",
117 "-Xep:DirectInvocationOnMock:ERROR",
118 "-Xep:EmptyBlockTag:ERROR",
119 "-Xep:EmptyCatch:ERROR",
William Escande023cccb2024-10-17 17:56:01 -0700120 "-Xep:EnumOrdinal:ERROR",
William Escande22560942024-09-18 16:44:36 -0700121 "-Xep:EqualsGetClass:ERROR",
122 "-Xep:EqualsHashCode:ERROR",
123 "-Xep:EqualsIncompatibleType:ERROR",
124 "-Xep:FallThrough:ERROR",
125 "-Xep:Finalize:ERROR",
126 "-Xep:FutureReturnValueIgnored:ERROR",
127 "-Xep:GuardedBy:ERROR",
128 "-Xep:HidingField:ERROR",
129 "-Xep:InconsistentHashCode:ERROR",
130 "-Xep:InlineFormatString:ERROR",
131 "-Xep:InlineMeInliner:ERROR",
132 "-Xep:InvalidBlockTag:ERROR",
133 "-Xep:InvalidInlineTag:ERROR",
134 "-Xep:InvalidParam:ERROR",
135 "-Xep:JavaUtilDate:ERROR",
136 "-Xep:JdkObsolete:ERROR",
137 "-Xep:LockOnNonEnclosingClassLiteral:ERROR",
138 "-Xep:LongFloatConversion:ERROR",
139 "-Xep:LoopOverCharArray:ERROR",
140 "-Xep:MissingCasesInEnumSwitch:ERROR",
141 "-Xep:MixedMutabilityReturnType:ERROR",
142 "-Xep:MockNotUsedInProduction:ERROR",
143 "-Xep:ModifiedButNotUsed:ERROR",
144 "-Xep:ModifyCollectionInEnhancedForLoop:ERROR",
145 "-Xep:NarrowCalculation:ERROR",
146 "-Xep:NarrowingCompoundAssignment:ERROR",
147 "-Xep:NonApiType:ERROR",
148 "-Xep:NonAtomicVolatileUpdate:ERROR",
149 "-Xep:NonCanonicalType:ERROR",
150 "-Xep:NotJavadoc:ERROR",
William Escande5cd9c5e2024-10-23 16:43:14 -0700151 "-Xep:NullablePrimitive:ERROR",
152 "-Xep:NullableVoid:ERROR",
William Escande22560942024-09-18 16:44:36 -0700153 "-Xep:ObjectEqualsForPrimitives:ERROR",
154 "-Xep:OperatorPrecedence:ERROR",
155 "-Xep:ReferenceEquality:ERROR",
156 "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
Antoine SOULIER0dc741f2024-08-21 18:07:29 +0000157 "-Xep:ReturnFromVoid:ERROR",
William Escande22560942024-09-18 16:44:36 -0700158 "-Xep:StaticAssignmentInConstructor:ERROR",
159 "-Xep:StaticGuardedByInstance:ERROR",
160 "-Xep:StringCaseLocaleUsage:ERROR",
161 "-Xep:StringCharset:ERROR",
162 "-Xep:SynchronizeOnNonFinalField:ERROR",
163 "-Xep:ToStringReturnsNull:ERROR",
164 "-Xep:TruthConstantAsserts:ERROR",
165 "-Xep:TruthIncompatibleType:ERROR",
166 "-Xep:UndefinedEquals:ERROR",
167 "-Xep:UnnecessaryAssignment:ERROR",
168 "-Xep:UnnecessaryAsync:ERROR",
169 "-Xep:UnnecessaryStringBuilder:ERROR",
170 "-Xep:UnrecognisedJavadocTag:ERROR",
171 "-Xep:UnusedMethod:ERROR",
172 "-Xep:UnusedNestedClass:ERROR",
173 "-Xep:UnusedVariable:ERROR",
William Escande57679d52024-10-28 14:23:27 -0700174 "-Xep:VariableNameSameAsType:ERROR",
William Escande22560942024-09-18 16:44:36 -0700175 "-Xep:WaitNotInLoop:ERROR",
176 "-Xep:WakelockReleasedDangerously:ERROR",
177
178 // Exclude generated files
179 "-XepExcludedPaths:.*/srcjars/.*",
180
William Escandebed62da2024-10-21 14:16:20 -0700181 // The @InlineMe annotation could be made available, but it would
William Escande57679d52024-10-28 14:23:27 -0700182 // apply on external facing API. This is not desired.
183 // For more context, see https://r.android.com/3303475
William Escandebed62da2024-10-21 14:16:20 -0700184 "-Xep:InlineMeSuggester:OFF",
William Escande22560942024-09-18 16:44:36 -0700185 ],
186 },
187}
188
189java_defaults {
190 name: "bluetooth_framework_errorprone_rules",
191 defaults: ["bluetooth_errorprone_rules"],
William Escande22560942024-09-18 16:44:36 -0700192 errorprone: {
William Escandec7480a12024-11-12 11:51:59 -0800193 extra_check_modules: ["error_prone_android_framework"],
194
William Escande22560942024-09-18 16:44:36 -0700195 javacflags: [
196 "-Xep:AndroidFrameworkBinderIdentity:ERROR",
197 "-Xep:AndroidFrameworkBluetoothPermission:ERROR",
198 "-Xep:AndroidFrameworkCompatChange:ERROR",
199 "-Xep:AndroidFrameworkEfficientParcelable:ERROR",
200 "-Xep:AndroidFrameworkEfficientStrings:ERROR",
201 "-Xep:AndroidFrameworkPendingIntentMutability:ERROR",
202 "-Xep:AndroidFrameworkRequiresPermission:ERROR",
203 "-Xep:AndroidFrameworkRethrowFromSystem:ERROR",
204 "-Xep:AndroidFrameworkTargetSdk:ERROR",
205 "-Xep:AndroidHideInComments:ERROR",
206
207 // After fixing this errorprone, we decided to not merge the change.
208 // It is not very readable and the benefits are minimal when looking
209 // at the size of the maps used in the Bluetooth application.
210 // See https://r.android.com/3200511
211 "-Xep:AndroidFrameworkEfficientCollections:OFF",
212
213 // Does not look pertinent in our situation
214 "-Xep:AndroidFrameworkEfficientXml:OFF",
215 ],
216 },
217}