blob: e8078776ce683d40dd7d68fc29a403d0a346b21f [file] [log] [blame]
Dan Willemsenb0552672019-01-25 16:04:11 -08001// Copyright 2019 Google Inc. All rights reserved.
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
Jaewoong Jung4b79e982020-06-01 10:45:49 -070015package sh
Dan Willemsenb0552672019-01-25 16:04:11 -080016
17import (
18 "fmt"
Colin Cross7c7c1142019-07-29 16:46:49 -070019 "path/filepath"
Jaewoong Jung6e0eee52020-05-29 16:15:32 -070020 "sort"
Julien Desprez9e7fc142019-03-08 11:07:05 -080021 "strings"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070022
Jaewoong Jung6e0eee52020-05-29 16:15:32 -070023 "github.com/google/blueprint"
Jaewoong Jung4b79e982020-06-01 10:45:49 -070024 "github.com/google/blueprint/proptools"
25
26 "android/soong/android"
Jaewoong Jung6e0eee52020-05-29 16:15:32 -070027 "android/soong/cc"
frankfengc5b87492020-06-03 10:28:47 -070028 "android/soong/tradefed"
Dan Willemsenb0552672019-01-25 16:04:11 -080029)
30
31// sh_binary is for shell scripts (and batch files) that are installed as
32// executable files into .../bin/
33//
34// Do not use them for prebuilt C/C++/etc files. Use cc_prebuilt_binary
35// instead.
36
Jaewoong Jung4b79e982020-06-01 10:45:49 -070037var pctx = android.NewPackageContext("android/soong/sh")
38
Dan Willemsenb0552672019-01-25 16:04:11 -080039func init() {
Jaewoong Jung4b79e982020-06-01 10:45:49 -070040 pctx.Import("android/soong/android")
41
42 android.RegisterModuleType("sh_binary", ShBinaryFactory)
43 android.RegisterModuleType("sh_binary_host", ShBinaryHostFactory)
44 android.RegisterModuleType("sh_test", ShTestFactory)
45 android.RegisterModuleType("sh_test_host", ShTestHostFactory)
Dan Willemsenb0552672019-01-25 16:04:11 -080046}
47
48type shBinaryProperties struct {
49 // Source file of this prebuilt.
Colin Cross27b922f2019-03-04 22:35:41 -080050 Src *string `android:"path,arch_variant"`
Dan Willemsenb0552672019-01-25 16:04:11 -080051
52 // optional subdirectory under which this file is installed into
53 Sub_dir *string `android:"arch_variant"`
54
55 // optional name for the installed file. If unspecified, name of the module is used as the file name
56 Filename *string `android:"arch_variant"`
57
58 // when set to true, and filename property is not set, the name for the installed file
59 // is the same as the file name of the source file.
60 Filename_from_src *bool `android:"arch_variant"`
61
62 // Whether this module is directly installable to one of the partitions. Default: true.
63 Installable *bool
Rashed Abdel-Tawab6a341312019-10-04 20:38:01 -070064
65 // install symlinks to the binary
66 Symlinks []string `android:"arch_variant"`
Colin Crosscc83efb2020-08-21 14:25:33 -070067
68 // Make this module available when building for ramdisk.
69 Ramdisk_available *bool
70
71 // Make this module available when building for recovery.
72 Recovery_available *bool
Dan Willemsenb0552672019-01-25 16:04:11 -080073}
74
Julien Desprez9e7fc142019-03-08 11:07:05 -080075type TestProperties struct {
76 // list of compatibility suites (for example "cts", "vts") that the module should be
77 // installed into.
78 Test_suites []string `android:"arch_variant"`
79
80 // the name of the test configuration (for example "AndroidTest.xml") that should be
81 // installed with the module.
Colin Crossa6384822020-06-09 15:09:22 -070082 Test_config *string `android:"path,arch_variant"`
Jaewoong Jung8eaeb092019-05-16 14:58:29 -070083
84 // list of files or filegroup modules that provide data that should be installed alongside
85 // the test.
86 Data []string `android:"path,arch_variant"`
frankfengc5b87492020-06-03 10:28:47 -070087
88 // Add RootTargetPreparer to auto generated test config. This guarantees the test to run
89 // with root permission.
90 Require_root *bool
91
92 // the name of the test configuration template (for example "AndroidTestTemplate.xml") that
93 // should be installed with the module.
94 Test_config_template *string `android:"path,arch_variant"`
95
96 // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
97 // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
98 // explicitly.
99 Auto_gen_config *bool
Jaewoong Jung6e0eee52020-05-29 16:15:32 -0700100
101 // list of binary modules that should be installed alongside the test
102 Data_bins []string `android:"path,arch_variant"`
103
104 // list of library modules that should be installed alongside the test
105 Data_libs []string `android:"path,arch_variant"`
106
107 // list of device binary modules that should be installed alongside the test.
108 // Only available for host sh_test modules.
109 Data_device_bins []string `android:"path,arch_variant"`
110
111 // list of device library modules that should be installed alongside the test.
112 // Only available for host sh_test modules.
113 Data_device_libs []string `android:"path,arch_variant"`
Julien Desprez9e7fc142019-03-08 11:07:05 -0800114}
115
Dan Willemsenb0552672019-01-25 16:04:11 -0800116type ShBinary struct {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700117 android.ModuleBase
Dan Willemsenb0552672019-01-25 16:04:11 -0800118
119 properties shBinaryProperties
120
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700121 sourceFilePath android.Path
122 outputFilePath android.OutputPath
123 installedFile android.InstallPath
Dan Willemsenb0552672019-01-25 16:04:11 -0800124}
125
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700126var _ android.HostToolProvider = (*ShBinary)(nil)
Colin Cross7c7c1142019-07-29 16:46:49 -0700127
Julien Desprez9e7fc142019-03-08 11:07:05 -0800128type ShTest struct {
129 ShBinary
130
131 testProperties TestProperties
Jaewoong Jung8eaeb092019-05-16 14:58:29 -0700132
Jaewoong Jung4aedc862020-06-10 17:23:46 -0700133 installDir android.InstallPath
134
frankfengc5b87492020-06-03 10:28:47 -0700135 data android.Paths
136 testConfig android.Path
Jaewoong Jung6e0eee52020-05-29 16:15:32 -0700137
138 dataModules map[string]android.Path
Julien Desprez9e7fc142019-03-08 11:07:05 -0800139}
140
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700141func (s *ShBinary) HostToolPath() android.OptionalPath {
142 return android.OptionalPathForPath(s.installedFile)
Colin Cross7c7c1142019-07-29 16:46:49 -0700143}
144
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700145func (s *ShBinary) DepsMutator(ctx android.BottomUpMutatorContext) {
Dan Willemsenb0552672019-01-25 16:04:11 -0800146 if s.properties.Src == nil {
147 ctx.PropertyErrorf("src", "missing prebuilt source file")
148 }
Dan Willemsenb0552672019-01-25 16:04:11 -0800149}
150
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700151func (s *ShBinary) OutputFile() android.OutputPath {
Dan Willemsenb0552672019-01-25 16:04:11 -0800152 return s.outputFilePath
153}
154
155func (s *ShBinary) SubDir() string {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700156 return proptools.String(s.properties.Sub_dir)
Dan Willemsenb0552672019-01-25 16:04:11 -0800157}
158
159func (s *ShBinary) Installable() bool {
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700160 return s.properties.Installable == nil || proptools.Bool(s.properties.Installable)
Dan Willemsenb0552672019-01-25 16:04:11 -0800161}
162
Rashed Abdel-Tawab6a341312019-10-04 20:38:01 -0700163func (s *ShBinary) Symlinks() []string {
164 return s.properties.Symlinks
165}
166
Colin Crosscc83efb2020-08-21 14:25:33 -0700167var _ android.ImageInterface = (*ShBinary)(nil)
168
169func (s *ShBinary) ImageMutatorBegin(ctx android.BaseModuleContext) {}
170
171func (s *ShBinary) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
172 return !s.ModuleBase.InstallInRecovery() && !s.ModuleBase.InstallInRamdisk()
173}
174
175func (s *ShBinary) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
176 return proptools.Bool(s.properties.Ramdisk_available) || s.ModuleBase.InstallInRamdisk()
177}
178
179func (s *ShBinary) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
180 return proptools.Bool(s.properties.Recovery_available) || s.ModuleBase.InstallInRecovery()
181}
182
183func (s *ShBinary) ExtraImageVariations(ctx android.BaseModuleContext) []string {
184 return nil
185}
186
187func (s *ShBinary) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
188}
189
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700190func (s *ShBinary) generateAndroidBuildActions(ctx android.ModuleContext) {
191 s.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(s.properties.Src))
192 filename := proptools.String(s.properties.Filename)
193 filename_from_src := proptools.Bool(s.properties.Filename_from_src)
Dan Willemsenb0552672019-01-25 16:04:11 -0800194 if filename == "" {
195 if filename_from_src {
196 filename = s.sourceFilePath.Base()
197 } else {
198 filename = ctx.ModuleName()
199 }
200 } else if filename_from_src {
201 ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
202 return
203 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700204 s.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
Dan Willemsenb0552672019-01-25 16:04:11 -0800205
206 // This ensures that outputFilePath has the correct name for others to
207 // use, as the source file may have a different name.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700208 ctx.Build(pctx, android.BuildParams{
209 Rule: android.CpExecutable,
Dan Willemsenb0552672019-01-25 16:04:11 -0800210 Output: s.outputFilePath,
211 Input: s.sourceFilePath,
212 })
213}
214
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700215func (s *ShBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Cross7c7c1142019-07-29 16:46:49 -0700216 s.generateAndroidBuildActions(ctx)
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700217 installDir := android.PathForModuleInstall(ctx, "bin", proptools.String(s.properties.Sub_dir))
Colin Cross7c7c1142019-07-29 16:46:49 -0700218 s.installedFile = ctx.InstallExecutable(installDir, s.outputFilePath.Base(), s.outputFilePath)
219}
220
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700221func (s *ShBinary) AndroidMkEntries() []android.AndroidMkEntries {
222 return []android.AndroidMkEntries{android.AndroidMkEntries{
Dan Willemsenb0552672019-01-25 16:04:11 -0800223 Class: "EXECUTABLES",
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700224 OutputFile: android.OptionalPathForPath(s.outputFilePath),
Dan Willemsenb0552672019-01-25 16:04:11 -0800225 Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700226 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
227 func(entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700228 s.customAndroidMkEntries(entries)
Jaewoong Jung4aedc862020-06-10 17:23:46 -0700229 entries.SetString("LOCAL_MODULE_RELATIVE_PATH", proptools.String(s.properties.Sub_dir))
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700230 },
Dan Willemsenb0552672019-01-25 16:04:11 -0800231 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900232 }}
Dan Willemsenb0552672019-01-25 16:04:11 -0800233}
234
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700235func (s *ShBinary) customAndroidMkEntries(entries *android.AndroidMkEntries) {
Jaewoong Jung8eaeb092019-05-16 14:58:29 -0700236 entries.SetString("LOCAL_MODULE_SUFFIX", "")
237 entries.SetString("LOCAL_MODULE_STEM", s.outputFilePath.Rel())
Rashed Abdel-Tawab6a341312019-10-04 20:38:01 -0700238 if len(s.properties.Symlinks) > 0 {
239 entries.SetString("LOCAL_MODULE_SYMLINKS", strings.Join(s.properties.Symlinks, " "))
240 }
Jaewoong Jung8eaeb092019-05-16 14:58:29 -0700241}
242
Jaewoong Jung6e0eee52020-05-29 16:15:32 -0700243type dependencyTag struct {
244 blueprint.BaseDependencyTag
245 name string
246}
247
248var (
249 shTestDataBinsTag = dependencyTag{name: "dataBins"}
250 shTestDataLibsTag = dependencyTag{name: "dataLibs"}
251 shTestDataDeviceBinsTag = dependencyTag{name: "dataDeviceBins"}
252 shTestDataDeviceLibsTag = dependencyTag{name: "dataDeviceLibs"}
253)
254
255var sharedLibVariations = []blueprint.Variation{{Mutator: "link", Variation: "shared"}}
256
257func (s *ShTest) DepsMutator(ctx android.BottomUpMutatorContext) {
258 s.ShBinary.DepsMutator(ctx)
259
260 ctx.AddFarVariationDependencies(ctx.Target().Variations(), shTestDataBinsTag, s.testProperties.Data_bins...)
261 ctx.AddFarVariationDependencies(append(ctx.Target().Variations(), sharedLibVariations...),
262 shTestDataLibsTag, s.testProperties.Data_libs...)
263 if ctx.Target().Os.Class == android.Host && len(ctx.Config().Targets[android.Android]) > 0 {
Jaewoong Jung642916f2020-10-09 17:25:15 -0700264 deviceVariations := ctx.Config().AndroidFirstDeviceTarget.Variations()
Jaewoong Jung6e0eee52020-05-29 16:15:32 -0700265 ctx.AddFarVariationDependencies(deviceVariations, shTestDataDeviceBinsTag, s.testProperties.Data_device_bins...)
266 ctx.AddFarVariationDependencies(append(deviceVariations, sharedLibVariations...),
267 shTestDataDeviceLibsTag, s.testProperties.Data_device_libs...)
268 } else if ctx.Target().Os.Class != android.Host {
269 if len(s.testProperties.Data_device_bins) > 0 {
270 ctx.PropertyErrorf("data_device_bins", "only available for host modules")
271 }
272 if len(s.testProperties.Data_device_libs) > 0 {
273 ctx.PropertyErrorf("data_device_libs", "only available for host modules")
274 }
275 }
276}
277
278func (s *ShTest) addToDataModules(ctx android.ModuleContext, relPath string, path android.Path) {
279 if _, exists := s.dataModules[relPath]; exists {
280 ctx.ModuleErrorf("data modules have a conflicting installation path, %v - %s, %s",
281 relPath, s.dataModules[relPath].String(), path.String())
282 return
283 }
284 s.dataModules[relPath] = path
285}
286
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700287func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Cross7c7c1142019-07-29 16:46:49 -0700288 s.ShBinary.generateAndroidBuildActions(ctx)
289 testDir := "nativetest"
290 if ctx.Target().Arch.ArchType.Multilib == "lib64" {
291 testDir = "nativetest64"
292 }
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700293 if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
Colin Cross7c7c1142019-07-29 16:46:49 -0700294 testDir = filepath.Join(testDir, ctx.Target().NativeBridgeRelativePath)
295 } else if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
296 testDir = filepath.Join(testDir, ctx.Arch().ArchType.String())
297 }
Jaewoong Jung4aedc862020-06-10 17:23:46 -0700298 if s.SubDir() != "" {
299 // Don't add the module name to the installation path if sub_dir is specified for backward
300 // compatibility.
301 s.installDir = android.PathForModuleInstall(ctx, testDir, s.SubDir())
302 } else {
303 s.installDir = android.PathForModuleInstall(ctx, testDir, s.Name())
304 }
305 s.installedFile = ctx.InstallExecutable(s.installDir, s.outputFilePath.Base(), s.outputFilePath)
Jaewoong Jung8eaeb092019-05-16 14:58:29 -0700306
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700307 s.data = android.PathsForModuleSrc(ctx, s.testProperties.Data)
frankfengc5b87492020-06-03 10:28:47 -0700308
309 var configs []tradefed.Config
310 if Bool(s.testProperties.Require_root) {
311 configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil})
312 } else {
313 options := []tradefed.Option{{Name: "force-root", Value: "false"}}
314 configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", options})
315 }
frankfengbe6ae772020-09-28 13:22:57 -0700316 if len(s.testProperties.Data_device_bins) > 0 {
317 moduleName := s.Name()
318 remoteDir := "/data/local/tests/unrestricted/" + moduleName + "/"
319 options := []tradefed.Option{{Name: "cleanup", Value: "true"}}
320 for _, bin := range s.testProperties.Data_device_bins {
321 options = append(options, tradefed.Option{Name: "push-file", Key: bin, Value: remoteDir + bin})
322 }
323 configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.PushFilePreparer", options})
324 }
frankfengc5b87492020-06-03 10:28:47 -0700325 s.testConfig = tradefed.AutoGenShellTestConfig(ctx, s.testProperties.Test_config,
326 s.testProperties.Test_config_template, s.testProperties.Test_suites, configs, s.testProperties.Auto_gen_config, s.outputFilePath.Base())
Jaewoong Jung6e0eee52020-05-29 16:15:32 -0700327
328 s.dataModules = make(map[string]android.Path)
329 ctx.VisitDirectDeps(func(dep android.Module) {
330 depTag := ctx.OtherModuleDependencyTag(dep)
331 switch depTag {
332 case shTestDataBinsTag, shTestDataDeviceBinsTag:
333 if cc, isCc := dep.(*cc.Module); isCc {
334 s.addToDataModules(ctx, cc.OutputFile().Path().Base(), cc.OutputFile().Path())
335 return
336 }
337 property := "data_bins"
338 if depTag == shTestDataDeviceBinsTag {
339 property = "data_device_bins"
340 }
341 ctx.PropertyErrorf(property, "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
342 case shTestDataLibsTag, shTestDataDeviceLibsTag:
343 if cc, isCc := dep.(*cc.Module); isCc {
344 // Copy to an intermediate output directory to append "lib[64]" to the path,
345 // so that it's compatible with the default rpath values.
346 var relPath string
347 if cc.Arch().ArchType.Multilib == "lib64" {
348 relPath = filepath.Join("lib64", cc.OutputFile().Path().Base())
349 } else {
350 relPath = filepath.Join("lib", cc.OutputFile().Path().Base())
351 }
352 if _, exist := s.dataModules[relPath]; exist {
353 return
354 }
355 relocatedLib := android.PathForModuleOut(ctx, "relocated", relPath)
356 ctx.Build(pctx, android.BuildParams{
357 Rule: android.Cp,
358 Input: cc.OutputFile().Path(),
359 Output: relocatedLib,
360 })
361 s.addToDataModules(ctx, relPath, relocatedLib)
362 return
363 }
364 property := "data_libs"
365 if depTag == shTestDataDeviceBinsTag {
366 property = "data_device_libs"
367 }
368 ctx.PropertyErrorf(property, "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
369 }
370 })
Jaewoong Jung8eaeb092019-05-16 14:58:29 -0700371}
372
Colin Cross7c7c1142019-07-29 16:46:49 -0700373func (s *ShTest) InstallInData() bool {
374 return true
375}
376
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700377func (s *ShTest) AndroidMkEntries() []android.AndroidMkEntries {
378 return []android.AndroidMkEntries{android.AndroidMkEntries{
Jaewoong Jung8eaeb092019-05-16 14:58:29 -0700379 Class: "NATIVE_TESTS",
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700380 OutputFile: android.OptionalPathForPath(s.outputFilePath),
Jaewoong Jung8eaeb092019-05-16 14:58:29 -0700381 Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700382 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
383 func(entries *android.AndroidMkEntries) {
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700384 s.customAndroidMkEntries(entries)
Jaewoong Jung4aedc862020-06-10 17:23:46 -0700385 entries.SetPath("LOCAL_MODULE_PATH", s.installDir.ToMakePath())
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700386 entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", s.testProperties.Test_suites...)
Colin Crossa6384822020-06-09 15:09:22 -0700387 if s.testConfig != nil {
388 entries.SetPath("LOCAL_FULL_TEST_CONFIG", s.testConfig)
frankfengc5b87492020-06-03 10:28:47 -0700389 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700390 for _, d := range s.data {
391 rel := d.Rel()
392 path := d.String()
393 if !strings.HasSuffix(path, rel) {
394 panic(fmt.Errorf("path %q does not end with %q", path, rel))
395 }
396 path = strings.TrimSuffix(path, rel)
397 entries.AddStrings("LOCAL_TEST_DATA", path+":"+rel)
Jaewoong Jung8eaeb092019-05-16 14:58:29 -0700398 }
Jaewoong Jung6e0eee52020-05-29 16:15:32 -0700399 relPaths := make([]string, 0)
400 for relPath, _ := range s.dataModules {
401 relPaths = append(relPaths, relPath)
402 }
403 sort.Strings(relPaths)
404 for _, relPath := range relPaths {
405 dir := strings.TrimSuffix(s.dataModules[relPath].String(), relPath)
406 entries.AddStrings("LOCAL_TEST_DATA", dir+":"+relPath)
407 }
Jaewoong Junge0dc8df2019-08-27 17:33:16 -0700408 },
Jaewoong Jung8eaeb092019-05-16 14:58:29 -0700409 },
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900410 }}
Julien Desprez9e7fc142019-03-08 11:07:05 -0800411}
412
Dan Willemsenb0552672019-01-25 16:04:11 -0800413func InitShBinaryModule(s *ShBinary) {
414 s.AddProperties(&s.properties)
415}
416
Patrice Arrudae1034192019-03-11 13:20:17 -0700417// sh_binary is for a shell script or batch file to be installed as an
418// executable binary to <partition>/bin.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700419func ShBinaryFactory() android.Module {
Dan Willemsenb0552672019-01-25 16:04:11 -0800420 module := &ShBinary{}
421 InitShBinaryModule(module)
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700422 android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibFirst)
Dan Willemsenb0552672019-01-25 16:04:11 -0800423 return module
424}
425
Patrice Arrudae1034192019-03-11 13:20:17 -0700426// sh_binary_host is for a shell script to be installed as an executable binary
427// to $(HOST_OUT)/bin.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700428func ShBinaryHostFactory() android.Module {
Dan Willemsenb0552672019-01-25 16:04:11 -0800429 module := &ShBinary{}
430 InitShBinaryModule(module)
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700431 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibFirst)
Dan Willemsenb0552672019-01-25 16:04:11 -0800432 return module
433}
Julien Desprez9e7fc142019-03-08 11:07:05 -0800434
Jaewoong Jung61a83682019-07-01 09:08:50 -0700435// sh_test defines a shell script based test module.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700436func ShTestFactory() android.Module {
Julien Desprez9e7fc142019-03-08 11:07:05 -0800437 module := &ShTest{}
438 InitShBinaryModule(&module.ShBinary)
439 module.AddProperties(&module.testProperties)
440
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700441 android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibFirst)
Julien Desprez9e7fc142019-03-08 11:07:05 -0800442 return module
443}
Jaewoong Jung61a83682019-07-01 09:08:50 -0700444
445// sh_test_host defines a shell script based test module that runs on a host.
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700446func ShTestHostFactory() android.Module {
Jaewoong Jung61a83682019-07-01 09:08:50 -0700447 module := &ShTest{}
448 InitShBinaryModule(&module.ShBinary)
449 module.AddProperties(&module.testProperties)
450
Jaewoong Jung4b79e982020-06-01 10:45:49 -0700451 android.InitAndroidArchModule(module, android.HostSupported, android.MultilibFirst)
Jaewoong Jung61a83682019-07-01 09:08:50 -0700452 return module
453}
frankfengc5b87492020-06-03 10:28:47 -0700454
455var Bool = proptools.Bool