Bob Badour | 92ecf7c | 2021-02-12 18:05:29 -0800 | [diff] [blame] | 1 | package { |
Etienne Ruffieux | 917abc3 | 2022-02-28 14:07:17 +0000 | [diff] [blame] | 2 | default_visibility: [":__subpackages__"], |
Bob Badour | 92ecf7c | 2021-02-12 18:05:29 -0800 | [diff] [blame] | 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 |
| 20 | license { |
| 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 He | cac30a2 | 2018-08-28 18:28:55 -0700 | [diff] [blame] | 34 | filegroup { |
Colin Cross | 03e29e5 | 2019-05-23 14:12:59 -0700 | [diff] [blame] | 35 | name: "BluetoothTestConfigTemplate", |
| 36 | srcs: [ |
| 37 | "AndroidTestTemplate.xml", |
| 38 | ], |
Jack He | cac30a2 | 2018-08-28 18:28:55 -0700 | [diff] [blame] | 39 | } |
David Duarte | a84ffd1 | 2023-03-28 17:58:57 +0000 | [diff] [blame] | 40 | |
David Duarte | 4043a70 | 2023-06-04 16:44:03 +0000 | [diff] [blame] | 41 | // 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 Escande | 2256094 | 2024-09-18 16:44:36 -0700 | [diff] [blame] | 60 | // - Try avoiding adding option that would not fit "future" targets, for example dependencies, |
David Duarte | 4043a70 | 2023-06-04 16:44:03 +0000 | [diff] [blame] | 61 | // 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. |
| 63 | cc_defaults { |
| 64 | name: "bluetooth_cflags", |
| 65 | cflags: [ |
| 66 | "-Wall", |
| 67 | "-Werror", |
| 68 | "-Wextra", |
Henri Chataing | 22f5e11 | 2024-09-21 01:20:25 +0000 | [diff] [blame] | 69 | "-Wmissing-prototypes", |
William Escande | 2729718 | 2023-10-09 17:15:04 -0700 | [diff] [blame] | 70 | // Override global.go that demote the error to a warning |
David Duarte | c8d2a49 | 2024-04-11 18:02:38 +0000 | [diff] [blame] | 71 | "-Werror=format", |
William Escande | 2729718 | 2023-10-09 17:15:04 -0700 | [diff] [blame] | 72 | "-Werror=reorder-init-list", |
David Duarte | 4043a70 | 2023-06-04 16:44:03 +0000 | [diff] [blame] | 73 | ], |
David Duarte | 19954d1 | 2023-08-01 14:07:56 +0000 | [diff] [blame] | 74 | c_std: "c99", |
Myles Watson | dbd43e7 | 2024-02-15 11:02:58 -0800 | [diff] [blame] | 75 | cpp_std: "c++20", |
David Duarte | 4043a70 | 2023-06-04 16:44:03 +0000 | [diff] [blame] | 76 | } |
William Escande | 2256094 | 2024-09-18 16:44:36 -0700 | [diff] [blame] | 77 | |
Henri Chataing | 31dba77 | 2024-10-18 14:33:17 -0700 | [diff] [blame] | 78 | // 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. |
| 81 | bluetooth_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 Chataing | 693806a | 2024-10-23 20:45:34 +0000 | [diff] [blame] | 88 | |
| 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 Chataing | 31dba77 | 2024-10-18 14:33:17 -0700 | [diff] [blame] | 93 | ] |
| 94 | |
| 95 | // This default tidy checks that will be run against all the cc targets |
| 96 | // developed by the Bluetooth team. |
| 97 | cc_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 Escande | 2256094 | 2024-09-18 16:44:36 -0700 | [diff] [blame] | 104 | java_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 Escande | 023cccb | 2024-10-17 17:56:01 -0700 | [diff] [blame] | 120 | "-Xep:EnumOrdinal:ERROR", |
William Escande | 2256094 | 2024-09-18 16:44:36 -0700 | [diff] [blame] | 121 | "-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 Escande | 5cd9c5e | 2024-10-23 16:43:14 -0700 | [diff] [blame] | 151 | "-Xep:NullablePrimitive:ERROR", |
| 152 | "-Xep:NullableVoid:ERROR", |
William Escande | 2256094 | 2024-09-18 16:44:36 -0700 | [diff] [blame] | 153 | "-Xep:ObjectEqualsForPrimitives:ERROR", |
| 154 | "-Xep:OperatorPrecedence:ERROR", |
| 155 | "-Xep:ReferenceEquality:ERROR", |
| 156 | "-Xep:ReturnAtTheEndOfVoidFunction:ERROR", |
Antoine SOULIER | 0dc741f | 2024-08-21 18:07:29 +0000 | [diff] [blame] | 157 | "-Xep:ReturnFromVoid:ERROR", |
William Escande | 2256094 | 2024-09-18 16:44:36 -0700 | [diff] [blame] | 158 | "-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 Escande | 57679d5 | 2024-10-28 14:23:27 -0700 | [diff] [blame] | 174 | "-Xep:VariableNameSameAsType:ERROR", |
William Escande | 2256094 | 2024-09-18 16:44:36 -0700 | [diff] [blame] | 175 | "-Xep:WaitNotInLoop:ERROR", |
| 176 | "-Xep:WakelockReleasedDangerously:ERROR", |
| 177 | |
| 178 | // Exclude generated files |
| 179 | "-XepExcludedPaths:.*/srcjars/.*", |
| 180 | |
William Escande | bed62da | 2024-10-21 14:16:20 -0700 | [diff] [blame] | 181 | // The @InlineMe annotation could be made available, but it would |
William Escande | 57679d5 | 2024-10-28 14:23:27 -0700 | [diff] [blame] | 182 | // apply on external facing API. This is not desired. |
| 183 | // For more context, see https://r.android.com/3303475 |
William Escande | bed62da | 2024-10-21 14:16:20 -0700 | [diff] [blame] | 184 | "-Xep:InlineMeSuggester:OFF", |
William Escande | 2256094 | 2024-09-18 16:44:36 -0700 | [diff] [blame] | 185 | ], |
| 186 | }, |
| 187 | } |
| 188 | |
| 189 | java_defaults { |
| 190 | name: "bluetooth_framework_errorprone_rules", |
| 191 | defaults: ["bluetooth_errorprone_rules"], |
William Escande | 2256094 | 2024-09-18 16:44:36 -0700 | [diff] [blame] | 192 | errorprone: { |
William Escande | c7480a1 | 2024-11-12 11:51:59 -0800 | [diff] [blame] | 193 | extra_check_modules: ["error_prone_android_framework"], |
| 194 | |
William Escande | 2256094 | 2024-09-18 16:44:36 -0700 | [diff] [blame] | 195 | 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 | } |