• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {
2    default_visibility: [":__subpackages__"],
3    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
34filegroup {
35    name: "BluetoothGTestConfigTemplate",
36    srcs: [
37        "BluetoothGTestTemplate.xml",
38    ],
39}
40
41filegroup {
42    name: "BluetoothRustTestConfigTemplate",
43    srcs: [
44        "BluetoothRustTestTemplate.xml",
45    ],
46}
47
48// This default contains properties that should be common to all the cc targets
49// developed by the Bluetooth team.
50//
51// Be careful when adding new properties here:
52//  - The option should not impact negatively any target, for example "-Wno-*"
53//    options should not be added here but instead on every targets needing
54//    them to avoid allowing adding new warnings in targets that didn't contained
55//    them (you can use the bpmodify tool to ease the work of adding this warning
56//    everywhere) and also allows cleaning them one at a time.
57//
58//  - The option should apply to all the c/c++ code developed by the Bluetooth team:
59//    test, tools, fuzzers, etc, not only production targets, if you need to add an option
60//    for a subset of Bluetooth cc targets you should look at the defaults including this
61//    defaults like "fluoride_defaults" and "gd_defaults".
62//
63//  - Try to keep the name as precise as possible to document to the dependent of what
64//    this default contains. This also means that if you add a new option that isn't
65//    documented by the name of this default, rename it.
66//
67//  - Try avoiding adding option that would not fit "future" targets, for example dependencies,
68//    even if every modules of Bluetooth depends on a specific dependency it should be left out
69//    from this default to not push it for future targets that might not need it.
70cc_defaults {
71    name: "bluetooth_cflags",
72    cflags: [
73        "-Wall",
74        "-Werror",
75        "-Wextra",
76        "-Wmissing-prototypes",
77        // Override global.go that demote the error to a warning
78        "-Werror=format",
79        "-Werror=reorder-init-list",
80        "-Wthread-safety",
81    ],
82    c_std: "c99",
83    cpp_std: "c++20",
84    arch: {
85        riscv64: {
86            ldflags: ["-Wl,--no-relax"],
87        },
88    },
89}
90
91// List of tidy checks that are enabled for cc targets.
92// Note that the goal is not to enable all checks, many of them will
93// appear as noise especially in the modernize-* range.
94bluetooth_tidy_checks = [
95    "-*",
96    "misc-*",
97
98    // This check implements detection of local variables which could be declared
99    // as const but are not.
100    "-misc-const-correctness",
101
102    // Finds classes that contain non-static data members in addition to user-declared
103    // non-static member functions and diagnose all data members declared with a
104    // non-public access specifier.
105    "-misc-non-private-member-variables-in-classes",
106]
107
108// This default tidy checks that will be run against all the cc targets
109// developed by the Bluetooth team.
110cc_defaults {
111    name: "bluetooth_tidy",
112    tidy: true,
113    tidy_checks: bluetooth_tidy_checks,
114    tidy_checks_as_errors: bluetooth_tidy_checks,
115}
116
117java_defaults {
118    name: "bluetooth_errorprone_rules",
119    errorprone: {
120        enabled: true,
121        javacflags: [
122            "-Xep:AlmostJavadoc:ERROR",
123            "-Xep:AlreadyChecked:ERROR",
124            "-Xep:AmbiguousMethodReference:ERROR",
125            "-Xep:ArrayRecordComponent:ERROR",
126            "-Xep:AttemptedNegativeZero:ERROR",
127            "-Xep:BadImport:ERROR",
128            "-Xep:BadInstanceof:ERROR",
129            "-Xep:CatchAndPrintStackTrace:ERROR",
130            "-Xep:CatchFail:ERROR",
131            "-Xep:CheckReturnValue:ERROR",
132            "-Xep:ClassCanBeStatic:ERROR",
133            "-Xep:DateFormatConstant:ERROR",
134            "-Xep:DirectInvocationOnMock:ERROR",
135            "-Xep:DuplicateBranches:ERROR",
136            "-Xep:EmptyBlockTag:ERROR",
137            "-Xep:EmptyCatch:ERROR",
138            "-Xep:EnumOrdinal:ERROR",
139            "-Xep:EqualsGetClass:ERROR",
140            "-Xep:EqualsHashCode:ERROR",
141            "-Xep:EqualsIncompatibleType:ERROR",
142            "-Xep:FallThrough:ERROR",
143            "-Xep:FieldCanBeFinal:ERROR",
144            "-Xep:FieldCanBeLocal:ERROR",
145            "-Xep:FieldCanBeStatic:ERROR",
146            "-Xep:Finalize:ERROR",
147            "-Xep:ForEachIterable:ERROR",
148            "-Xep:FutureReturnValueIgnored:ERROR",
149            "-Xep:GuardedBy:ERROR",
150            "-Xep:HidingField:ERROR",
151            "-Xep:InconsistentHashCode:ERROR",
152            "-Xep:IncrementInForLoopAndHeader:ERROR",
153            "-Xep:InlineFormatString:ERROR",
154            "-Xep:InlineMeInliner:ERROR",
155            "-Xep:InvalidBlockTag:ERROR",
156            "-Xep:InvalidInlineTag:ERROR",
157            "-Xep:InvalidLink:ERROR",
158            "-Xep:InvalidParam:ERROR",
159            "-Xep:JavaLangClash:ERROR",
160            "-Xep:JavaUtilDate:ERROR",
161            "-Xep:JdkObsolete:ERROR",
162            "-Xep:LockOnNonEnclosingClassLiteral:ERROR",
163            "-Xep:LongFloatConversion:ERROR",
164            "-Xep:LoopOverCharArray:ERROR",
165            "-Xep:MethodCanBeStatic:ERROR",
166            "-Xep:MissingCasesInEnumSwitch:ERROR",
167            "-Xep:MixedMutabilityReturnType:ERROR",
168            "-Xep:MockNotUsedInProduction:ERROR",
169            "-Xep:ModifiedButNotUsed:ERROR",
170            "-Xep:ModifyCollectionInEnhancedForLoop:ERROR",
171            "-Xep:NarrowCalculation:ERROR",
172            "-Xep:NarrowingCompoundAssignment:ERROR",
173            "-Xep:NonApiType:ERROR",
174            "-Xep:NonAtomicVolatileUpdate:ERROR",
175            "-Xep:NonCanonicalType:ERROR",
176            "-Xep:NotJavadoc:ERROR",
177            "-Xep:NullOptional:ERROR",
178            "-Xep:NullableOptional:ERROR",
179            "-Xep:NullablePrimitive:ERROR",
180            "-Xep:NullableVoid:ERROR",
181            "-Xep:ObjectEqualsForPrimitives:ERROR",
182            // "-Xep:ObjectToString:ERROR", // Wrongfully reporting errors
183            "-Xep:OperatorPrecedence:ERROR",
184            "-Xep:RedundantControlFlow:ERROR",
185            "-Xep:ReferenceEquality:ERROR",
186            "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
187            "-Xep:ReturnFromVoid:ERROR",
188            "-Xep:SelfAssertion:ERROR",
189            "-Xep:StaticAssignmentInConstructor:ERROR",
190            "-Xep:StaticGuardedByInstance:ERROR",
191            "-Xep:StringCaseLocaleUsage:ERROR",
192            "-Xep:StringCharset:ERROR",
193            // "-Xep:StringSplitter:ERROR", // Not enabled in android platform
194            "-Xep:SynchronizeOnNonFinalField:ERROR",
195            "-Xep:ThreadJoinLoop:ERROR",
196            "-Xep:ToStringReturnsNull:ERROR",
197            "-Xep:TruthAssertExpected:ERROR",
198            "-Xep:TruthConstantAsserts:ERROR",
199            "-Xep:TruthGetOrDefault:ERROR",
200            "-Xep:TruthIncompatibleType:ERROR",
201            "-Xep:UndefinedEquals:ERROR",
202            "-Xep:UnnecessaryAssignment:ERROR",
203            "-Xep:UnnecessaryAsync:ERROR",
204            "-Xep:UnnecessaryStringBuilder:ERROR",
205            "-Xep:UnrecognisedJavadocTag:ERROR",
206            "-Xep:UnusedMethod:ERROR",
207            "-Xep:UnusedNestedClass:ERROR",
208            "-Xep:UnusedTypeParameter:ERROR",
209            "-Xep:UnusedVariable:ERROR",
210            "-Xep:VariableNameSameAsType:ERROR",
211            "-Xep:WaitNotInLoop:ERROR",
212            "-Xep:WakelockReleasedDangerously:ERROR",
213
214            // Exclude generated files
215            "-XepExcludedPaths:.*/srcjars/.*",
216
217            // The @InlineMe annotation could be made available, but it would
218            // apply on external facing API. This is not desired.
219            // For more context, see https://r.android.com/3303475
220            "-Xep:InlineMeSuggester:OFF",
221        ],
222    },
223}
224
225java_defaults {
226    name: "bluetooth_framework_errorprone_rules",
227    defaults: ["bluetooth_errorprone_rules"],
228    errorprone: {
229        extra_check_modules: ["error_prone_android_framework"],
230
231        javacflags: [
232            "-Xep:AndroidFrameworkBinderIdentity:ERROR",
233            "-Xep:AndroidFrameworkBluetoothPermission:ERROR",
234            "-Xep:AndroidFrameworkCompatChange:ERROR",
235            "-Xep:AndroidFrameworkEfficientParcelable:ERROR",
236            "-Xep:AndroidFrameworkEfficientStrings:ERROR",
237            "-Xep:AndroidFrameworkPendingIntentMutability:ERROR",
238            "-Xep:AndroidFrameworkRequiresPermission:ERROR",
239            "-Xep:AndroidFrameworkRethrowFromSystem:ERROR",
240            "-Xep:AndroidFrameworkTargetSdk:ERROR",
241            "-Xep:AndroidHideInComments:ERROR",
242
243            // After fixing this errorprone, we decided to not merge the change.
244            // It is not very readable and the benefits are minimal when looking
245            // at the size of the maps used in the Bluetooth application.
246            // See https://r.android.com/3200511
247            "-Xep:AndroidFrameworkEfficientCollections:OFF",
248
249            // Does not look pertinent in our situation
250            "-Xep:AndroidFrameworkEfficientXml:OFF",
251        ],
252    },
253}
254