blob: 2668999c572ec2c7cc96988185a7a9688512042f [file] [log] [blame]
Anton Hansson0860aaf2021-10-08 16:48:03 +01001// Copyright (C) 2021 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package api
16
17import (
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +000018 "fmt"
Anton Hansson07a12952022-01-12 17:28:39 +000019 "sort"
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +000020 "strings"
Anton Hansson07a12952022-01-12 17:28:39 +000021
Anton Hansson0860aaf2021-10-08 16:48:03 +010022 "github.com/google/blueprint/proptools"
23
24 "android/soong/android"
25 "android/soong/genrule"
Anton Hanssoncb00f942022-01-13 09:45:12 +000026 "android/soong/java"
Anton Hansson0860aaf2021-10-08 16:48:03 +010027)
28
Anton Hansson05e944d2022-01-13 12:26:30 +000029const art = "art.module.public.api"
30const conscrypt = "conscrypt.module.public.api"
31const i18n = "i18n.module.public.api"
Nikita Ioffed3f0a6f2022-11-15 11:26:53 +000032const virtualization = "framework-virtualization"
Mark White3cc5e002023-08-07 11:18:09 +000033const location = "framework-location"
Roshan Pius0fa80892023-11-14 14:30:26 -080034const nfc = "framework-nfc"
Anton Hansson09a9c4e2022-04-08 10:59:46 +010035
Anton Hansson95e89a82022-01-28 11:31:50 +000036var core_libraries_modules = []string{art, conscrypt, i18n}
Zi Wang0d6a5302023-02-16 14:54:01 -080037
Nikita Ioffed3f0a6f2022-11-15 11:26:53 +000038// List of modules that are not yet updatable, and hence they can still compile
39// against hidden APIs. These modules are filtered out when building the
40// updatable-framework-module-impl (because updatable-framework-module-impl is
41// built against module_current SDK). Instead they are directly statically
42// linked into the all-framework-module-lib, which is building against hidden
43// APIs.
Nikita Ioffe5593fbb2022-12-01 14:52:34 +000044// In addition, the modules in this list are allowed to contribute to test APIs
45// stubs.
Roshan Pius0fa80892023-11-14 14:30:26 -080046var non_updatable_modules = []string{virtualization, location, nfc}
Anton Hansson05e944d2022-01-13 12:26:30 +000047
Anton Hansson0860aaf2021-10-08 16:48:03 +010048// The intention behind this soong plugin is to generate a number of "merged"
49// API-related modules that would otherwise require a large amount of very
50// similar Android.bp boilerplate to define. For example, the merged current.txt
51// API definitions (created by merging the non-updatable current.txt with all
52// the module current.txts). This simplifies the addition of new android
53// modules, by reducing the number of genrules etc a new module must be added to.
54
55// The properties of the combined_apis module type.
56type CombinedApisProperties struct {
Anton Hansson16ff3572022-01-11 18:36:35 +000057 // Module libraries in the bootclasspath
58 Bootclasspath []string
Anton Hansson07a12952022-01-12 17:28:39 +000059 // Module libraries on the bootclasspath if include_nonpublic_framework_api is true.
60 Conditional_bootclasspath []string
Anton Hansson16ff3572022-01-11 18:36:35 +000061 // Module libraries in system server
62 System_server_classpath []string
Anton Hansson0860aaf2021-10-08 16:48:03 +010063}
64
65type CombinedApis struct {
66 android.ModuleBase
67
68 properties CombinedApisProperties
69}
70
71func init() {
72 registerBuildComponents(android.InitRegistrationContext)
73}
74
75func registerBuildComponents(ctx android.RegistrationContext) {
76 ctx.RegisterModuleType("combined_apis", combinedApisModuleFactory)
77}
78
79var PrepareForCombinedApisTest = android.FixtureRegisterWithContext(registerBuildComponents)
80
81func (a *CombinedApis) GenerateAndroidBuildActions(ctx android.ModuleContext) {
82}
83
84type genruleProps struct {
85 Name *string
86 Cmd *string
87 Dists []android.Dist
88 Out []string
89 Srcs []string
90 Tools []string
91 Visibility []string
92}
93
Anton Hanssoncb00f942022-01-13 09:45:12 +000094type libraryProps struct {
95 Name *string
96 Sdk_version *string
97 Static_libs []string
98 Visibility []string
Jihoon Kang1453baa2023-05-27 05:32:30 +000099 Defaults []string
Anton Hanssoncb00f942022-01-13 09:45:12 +0000100}
101
Anton Hansson4468d7c2022-01-14 12:10:01 +0000102type fgProps struct {
103 Name *string
104 Srcs []string
105 Visibility []string
106}
107
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +0000108type defaultsProps struct {
109 Name *string
110 Api_surface *string
111 Api_contributions []string
112 Defaults_visibility []string
Jihoon Kang471a05b2023-08-01 06:37:17 +0000113 Previous_api *string
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +0000114}
115
Anton Hansson0860aaf2021-10-08 16:48:03 +0100116// Struct to pass parameters for the various merged [current|removed].txt file modules we create.
117type MergedTxtDefinition struct {
118 // "current.txt" or "removed.txt"
119 TxtFilename string
Anton Hansson09a9c4e2022-04-08 10:59:46 +0100120 // Filename in the new dist dir. "android.txt" or "android-removed.txt"
121 DistFilename string
Anton Hansson0860aaf2021-10-08 16:48:03 +0100122 // The module for the non-updatable / non-module part of the api.
123 BaseTxt string
124 // The list of modules that are relevant for this merged txt.
125 Modules []string
126 // The output tag for each module to use.e.g. {.public.api.txt} for current.txt
127 ModuleTag string
128 // public, system, module-lib or system-server
129 Scope string
130}
131
132func createMergedTxt(ctx android.LoadHookContext, txt MergedTxtDefinition) {
133 metalavaCmd := "$(location metalava)"
134 // Silence reflection warnings. See b/168689341
135 metalavaCmd += " -J--add-opens=java.base/java.util=ALL-UNNAMED "
Paul Duffinf3b1fc42023-08-14 22:03:06 +0100136 metalavaCmd += " --quiet merge-signatures --format=v2 "
Anton Hansson0860aaf2021-10-08 16:48:03 +0100137
138 filename := txt.TxtFilename
139 if txt.Scope != "public" {
140 filename = txt.Scope + "-" + filename
141 }
Chris Parsons3b7e34b2023-09-27 22:34:57 +0000142 moduleName := ctx.ModuleName() + "-" + filename
143
Anton Hansson0860aaf2021-10-08 16:48:03 +0100144 props := genruleProps{}
Chris Parsons3b7e34b2023-09-27 22:34:57 +0000145 props.Name = proptools.StringPtr(moduleName)
Anton Hansson0860aaf2021-10-08 16:48:03 +0100146 props.Tools = []string{"metalava"}
Anton Hansson16ff3572022-01-11 18:36:35 +0000147 props.Out = []string{filename}
Paul Duffinf3b1fc42023-08-14 22:03:06 +0100148 props.Cmd = proptools.StringPtr(metalavaCmd + "$(in) --out $(out)")
Anton Hanssonfd316452022-01-14 11:15:52 +0000149 props.Srcs = append([]string{txt.BaseTxt}, createSrcs(txt.Modules, txt.ModuleTag)...)
Anton Hansson0860aaf2021-10-08 16:48:03 +0100150 props.Dists = []android.Dist{
151 {
152 Targets: []string{"droidcore"},
153 Dir: proptools.StringPtr("api"),
154 Dest: proptools.StringPtr(filename),
155 },
156 {
Anton Hansson09a9c4e2022-04-08 10:59:46 +0100157 Targets: []string{"api_txt", "sdk"},
Anton Hansson0860aaf2021-10-08 16:48:03 +0100158 Dir: proptools.StringPtr("apistubs/android/" + txt.Scope + "/api"),
Anton Hansson09a9c4e2022-04-08 10:59:46 +0100159 Dest: proptools.StringPtr(txt.DistFilename),
Anton Hansson0860aaf2021-10-08 16:48:03 +0100160 },
161 }
162 props.Visibility = []string{"//visibility:public"}
Colin Crossc6420762023-12-07 12:38:40 -0800163 ctx.CreateModule(genrule.GenRuleFactory, &props)
Anton Hansson0860aaf2021-10-08 16:48:03 +0100164}
165
Cole Faustdcda3702022-10-04 14:46:35 -0700166func createMergedAnnotationsFilegroups(ctx android.LoadHookContext, modules, system_server_modules []string) {
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +0000167 for _, i := range []struct {
Cole Faustdcda3702022-10-04 14:46:35 -0700168 name string
169 tag string
170 modules []string
171 }{
172 {
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +0000173 name: "all-modules-public-annotations",
174 tag: "{.public.annotations.zip}",
Cole Faustdcda3702022-10-04 14:46:35 -0700175 modules: modules,
176 }, {
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +0000177 name: "all-modules-system-annotations",
178 tag: "{.system.annotations.zip}",
Cole Faustdcda3702022-10-04 14:46:35 -0700179 modules: modules,
180 }, {
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +0000181 name: "all-modules-module-lib-annotations",
182 tag: "{.module-lib.annotations.zip}",
Cole Faustdcda3702022-10-04 14:46:35 -0700183 modules: modules,
184 }, {
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +0000185 name: "all-modules-system-server-annotations",
186 tag: "{.system-server.annotations.zip}",
Cole Faustdcda3702022-10-04 14:46:35 -0700187 modules: system_server_modules,
188 },
189 } {
190 props := fgProps{}
191 props.Name = proptools.StringPtr(i.name)
192 props.Srcs = createSrcs(i.modules, i.tag)
Colin Crossc6420762023-12-07 12:38:40 -0800193 ctx.CreateModule(android.FileGroupFactory, &props)
Cole Faustdcda3702022-10-04 14:46:35 -0700194 }
Anton Hansson74b15642022-06-23 08:27:23 +0000195}
196
Anton Hanssonc6e9d2f2022-01-25 15:53:43 +0000197func createMergedPublicStubs(ctx android.LoadHookContext, modules []string) {
198 props := libraryProps{}
199 props.Name = proptools.StringPtr("all-modules-public-stubs")
200 props.Static_libs = transformArray(modules, "", ".stubs")
201 props.Sdk_version = proptools.StringPtr("module_current")
202 props.Visibility = []string{"//frameworks/base"}
203 ctx.CreateModule(java.LibraryFactory, &props)
204}
205
206func createMergedSystemStubs(ctx android.LoadHookContext, modules []string) {
Nikita Ioffe5593fbb2022-12-01 14:52:34 +0000207 // First create the all-updatable-modules-system-stubs
208 {
209 updatable_modules := removeAll(modules, non_updatable_modules)
210 props := libraryProps{}
211 props.Name = proptools.StringPtr("all-updatable-modules-system-stubs")
212 props.Static_libs = transformArray(updatable_modules, "", ".stubs.system")
213 props.Sdk_version = proptools.StringPtr("module_current")
214 props.Visibility = []string{"//frameworks/base"}
215 ctx.CreateModule(java.LibraryFactory, &props)
216 }
217 // Now merge all-updatable-modules-system-stubs and stubs from non-updatable modules
218 // into all-modules-system-stubs.
219 {
220 props := libraryProps{}
221 props.Name = proptools.StringPtr("all-modules-system-stubs")
222 props.Static_libs = transformArray(non_updatable_modules, "", ".stubs.system")
223 props.Static_libs = append(props.Static_libs, "all-updatable-modules-system-stubs")
224 props.Sdk_version = proptools.StringPtr("module_current")
225 props.Visibility = []string{"//frameworks/base"}
226 ctx.CreateModule(java.LibraryFactory, &props)
227 }
228}
229
230func createMergedTestStubsForNonUpdatableModules(ctx android.LoadHookContext) {
Anton Hanssonc6e9d2f2022-01-25 15:53:43 +0000231 props := libraryProps{}
Nikita Ioffe5593fbb2022-12-01 14:52:34 +0000232 props.Name = proptools.StringPtr("all-non-updatable-modules-test-stubs")
233 props.Static_libs = transformArray(non_updatable_modules, "", ".stubs.test")
Anton Hanssonc6e9d2f2022-01-25 15:53:43 +0000234 props.Sdk_version = proptools.StringPtr("module_current")
235 props.Visibility = []string{"//frameworks/base"}
236 ctx.CreateModule(java.LibraryFactory, &props)
237}
238
Anton Hansson95e89a82022-01-28 11:31:50 +0000239func createMergedFrameworkImpl(ctx android.LoadHookContext, modules []string) {
240 // This module is for the "framework-all" module, which should not include the core libraries.
241 modules = removeAll(modules, core_libraries_modules)
Nikita Ioffed3f0a6f2022-11-15 11:26:53 +0000242 // Remove the modules that belong to non-updatable APEXes since those are allowed to compile
243 // against unstable APIs.
244 modules = removeAll(modules, non_updatable_modules)
245 // First create updatable-framework-module-impl, which contains all updatable modules.
246 // This module compiles against module_lib SDK.
247 {
248 props := libraryProps{}
249 props.Name = proptools.StringPtr("updatable-framework-module-impl")
250 props.Static_libs = transformArray(modules, "", ".impl")
251 props.Sdk_version = proptools.StringPtr("module_current")
252 props.Visibility = []string{"//frameworks/base"}
253 ctx.CreateModule(java.LibraryFactory, &props)
254 }
255
256 // Now create all-framework-module-impl, which contains updatable-framework-module-impl
257 // and all non-updatable modules. This module compiles against hidden APIs.
258 {
259 props := libraryProps{}
260 props.Name = proptools.StringPtr("all-framework-module-impl")
261 props.Static_libs = transformArray(non_updatable_modules, "", ".impl")
262 props.Static_libs = append(props.Static_libs, "updatable-framework-module-impl")
263 props.Sdk_version = proptools.StringPtr("core_platform")
264 props.Visibility = []string{"//frameworks/base"}
265 ctx.CreateModule(java.LibraryFactory, &props)
266 }
Anton Hansson95e89a82022-01-28 11:31:50 +0000267}
268
269func createMergedFrameworkModuleLibStubs(ctx android.LoadHookContext, modules []string) {
Mark White3cc5e002023-08-07 11:18:09 +0000270 // The user of this module compiles against the "core" SDK and against non-updatable modules,
271 // so remove to avoid dupes.
Anton Hansson95e89a82022-01-28 11:31:50 +0000272 modules = removeAll(modules, core_libraries_modules)
Mark White3cc5e002023-08-07 11:18:09 +0000273 modules = removeAll(modules, non_updatable_modules)
Anton Hanssoncb00f942022-01-13 09:45:12 +0000274 props := libraryProps{}
275 props.Name = proptools.StringPtr("framework-updatable-stubs-module_libs_api")
Anton Hanssonfd316452022-01-14 11:15:52 +0000276 props.Static_libs = transformArray(modules, "", ".stubs.module_lib")
Anton Hanssoncb00f942022-01-13 09:45:12 +0000277 props.Sdk_version = proptools.StringPtr("module_current")
278 props.Visibility = []string{"//frameworks/base"}
279 ctx.CreateModule(java.LibraryFactory, &props)
280}
281
Anton Hansson4468d7c2022-01-14 12:10:01 +0000282func createPublicStubsSourceFilegroup(ctx android.LoadHookContext, modules []string) {
283 props := fgProps{}
284 props.Name = proptools.StringPtr("all-modules-public-stubs-source")
285 props.Srcs = createSrcs(modules, "{.public.stubs.source}")
286 props.Visibility = []string{"//frameworks/base"}
Colin Crossc6420762023-12-07 12:38:40 -0800287 ctx.CreateModule(android.FileGroupFactory, &props)
Anton Hansson4468d7c2022-01-14 12:10:01 +0000288}
289
Anton Hansson07a12952022-01-12 17:28:39 +0000290func createMergedTxts(ctx android.LoadHookContext, bootclasspath, system_server_classpath []string) {
Anton Hansson0860aaf2021-10-08 16:48:03 +0100291 var textFiles []MergedTxtDefinition
Anton Hansson16ff3572022-01-11 18:36:35 +0000292
Anton Hansson0860aaf2021-10-08 16:48:03 +0100293 tagSuffix := []string{".api.txt}", ".removed-api.txt}"}
Anton Hansson09a9c4e2022-04-08 10:59:46 +0100294 distFilename := []string{"android.txt", "android-removed.txt"}
Anton Hansson0860aaf2021-10-08 16:48:03 +0100295 for i, f := range []string{"current.txt", "removed.txt"} {
296 textFiles = append(textFiles, MergedTxtDefinition{
Colin Crossc6420762023-12-07 12:38:40 -0800297 TxtFilename: f,
298 DistFilename: distFilename[i],
299 BaseTxt: ":non-updatable-" + f,
300 Modules: bootclasspath,
301 ModuleTag: "{.public" + tagSuffix[i],
302 Scope: "public",
Anton Hansson0860aaf2021-10-08 16:48:03 +0100303 })
304 textFiles = append(textFiles, MergedTxtDefinition{
Colin Crossc6420762023-12-07 12:38:40 -0800305 TxtFilename: f,
306 DistFilename: distFilename[i],
307 BaseTxt: ":non-updatable-system-" + f,
308 Modules: bootclasspath,
309 ModuleTag: "{.system" + tagSuffix[i],
310 Scope: "system",
Anton Hansson0860aaf2021-10-08 16:48:03 +0100311 })
312 textFiles = append(textFiles, MergedTxtDefinition{
Colin Crossc6420762023-12-07 12:38:40 -0800313 TxtFilename: f,
314 DistFilename: distFilename[i],
315 BaseTxt: ":non-updatable-module-lib-" + f,
316 Modules: bootclasspath,
317 ModuleTag: "{.module-lib" + tagSuffix[i],
318 Scope: "module-lib",
Anton Hansson0860aaf2021-10-08 16:48:03 +0100319 })
320 textFiles = append(textFiles, MergedTxtDefinition{
Colin Crossc6420762023-12-07 12:38:40 -0800321 TxtFilename: f,
322 DistFilename: distFilename[i],
323 BaseTxt: ":non-updatable-system-server-" + f,
324 Modules: system_server_classpath,
325 ModuleTag: "{.system-server" + tagSuffix[i],
326 Scope: "system-server",
Anton Hansson0860aaf2021-10-08 16:48:03 +0100327 })
328 }
329 for _, txt := range textFiles {
330 createMergedTxt(ctx, txt)
331 }
332}
333
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +0000334func createApiContributionDefaults(ctx android.LoadHookContext, modules []string) {
335 defaultsSdkKinds := []android.SdkKind{
336 android.SdkPublic, android.SdkSystem, android.SdkModule,
337 }
338 for _, sdkKind := range defaultsSdkKinds {
339 props := defaultsProps{}
340 props.Name = proptools.StringPtr(
341 sdkKind.DefaultJavaLibraryName() + "_contributions")
342 if sdkKind == android.SdkModule {
343 props.Name = proptools.StringPtr(
344 sdkKind.DefaultJavaLibraryName() + "_contributions_full")
345 }
346 props.Api_surface = proptools.StringPtr(sdkKind.String())
347 apiSuffix := ""
348 if sdkKind != android.SdkPublic {
349 apiSuffix = "." + strings.ReplaceAll(sdkKind.String(), "-", "_")
350 }
351 props.Api_contributions = transformArray(
352 modules, "", fmt.Sprintf(".stubs.source%s.api.contribution", apiSuffix))
353 props.Defaults_visibility = []string{"//visibility:public"}
Jihoon Kang471a05b2023-08-01 06:37:17 +0000354 props.Previous_api = proptools.StringPtr(":android.api.public.latest")
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +0000355 ctx.CreateModule(java.DefaultsFactory, &props)
356 }
357}
358
Jihoon Kang1453baa2023-05-27 05:32:30 +0000359func createFullApiLibraries(ctx android.LoadHookContext) {
360 javaLibraryNames := []string{
361 "android_stubs_current",
362 "android_system_stubs_current",
363 "android_test_stubs_current",
Mark Whitee35b1382023-08-12 01:31:26 +0000364 "android_test_frameworks_core_stubs_current",
Jihoon Kang1453baa2023-05-27 05:32:30 +0000365 "android_module_lib_stubs_current",
366 "android_system_server_stubs_current",
367 }
368
369 for _, libraryName := range javaLibraryNames {
370 props := libraryProps{}
371 props.Name = proptools.StringPtr(libraryName)
372 staticLib := libraryName + ".from-source"
373 if ctx.Config().BuildFromTextStub() {
374 staticLib = libraryName + ".from-text"
375 }
376 props.Static_libs = []string{staticLib}
377 props.Defaults = []string{"android.jar_defaults"}
378 props.Visibility = []string{"//visibility:public"}
379
380 ctx.CreateModule(java.LibraryFactory, &props)
381 }
382}
383
Anton Hansson0860aaf2021-10-08 16:48:03 +0100384func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) {
Anton Hansson07a12952022-01-12 17:28:39 +0000385 bootclasspath := a.properties.Bootclasspath
Cole Faustdcda3702022-10-04 14:46:35 -0700386 system_server_classpath := a.properties.System_server_classpath
Anton Hansson07a12952022-01-12 17:28:39 +0000387 if ctx.Config().VendorConfig("ANDROID").Bool("include_nonpublic_framework_api") {
388 bootclasspath = append(bootclasspath, a.properties.Conditional_bootclasspath...)
389 sort.Strings(bootclasspath)
390 }
Cole Faustdcda3702022-10-04 14:46:35 -0700391 createMergedTxts(ctx, bootclasspath, system_server_classpath)
Anton Hansson0860aaf2021-10-08 16:48:03 +0100392
Anton Hanssonc6e9d2f2022-01-25 15:53:43 +0000393 createMergedPublicStubs(ctx, bootclasspath)
394 createMergedSystemStubs(ctx, bootclasspath)
Nikita Ioffe5593fbb2022-12-01 14:52:34 +0000395 createMergedTestStubsForNonUpdatableModules(ctx)
Anton Hansson95e89a82022-01-28 11:31:50 +0000396 createMergedFrameworkModuleLibStubs(ctx, bootclasspath)
397 createMergedFrameworkImpl(ctx, bootclasspath)
Anton Hanssoncb00f942022-01-13 09:45:12 +0000398
Cole Faustdcda3702022-10-04 14:46:35 -0700399 createMergedAnnotationsFilegroups(ctx, bootclasspath, system_server_classpath)
Anton Hanssoncc18e032022-01-12 14:45:22 +0000400
Anton Hansson4468d7c2022-01-14 12:10:01 +0000401 createPublicStubsSourceFilegroup(ctx, bootclasspath)
Jihoon Kang1e4ac1d2023-04-07 18:50:38 +0000402
403 createApiContributionDefaults(ctx, bootclasspath)
Jihoon Kang1453baa2023-05-27 05:32:30 +0000404
405 createFullApiLibraries(ctx)
Anton Hansson0860aaf2021-10-08 16:48:03 +0100406}
407
408func combinedApisModuleFactory() android.Module {
409 module := &CombinedApis{}
410 module.AddProperties(&module.properties)
411 android.InitAndroidModule(module)
412 android.AddLoadHook(module, func(ctx android.LoadHookContext) { module.createInternalModules(ctx) })
413 return module
414}
Anton Hanssonfd316452022-01-14 11:15:52 +0000415
416// Various utility methods below.
417
418// Creates an array of ":<m><tag>" for each m in <modules>.
419func createSrcs(modules []string, tag string) []string {
420 return transformArray(modules, ":", tag)
421}
422
423// Creates an array of "<prefix><m><suffix>", for each m in <modules>.
424func transformArray(modules []string, prefix, suffix string) []string {
425 a := make([]string, 0, len(modules))
426 for _, module := range modules {
427 a = append(a, prefix+module+suffix)
428 }
429 return a
430}
431
432func removeAll(s []string, vs []string) []string {
433 for _, v := range vs {
434 s = remove(s, v)
435 }
436 return s
437}
438
439func remove(s []string, v string) []string {
440 s2 := make([]string, 0, len(s))
441 for _, sv := range s {
442 if sv != v {
443 s2 = append(s2, sv)
444 }
445 }
446 return s2
447}