sh_binary.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. // 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. package sh
  15. import (
  16. "fmt"
  17. "path/filepath"
  18. "sort"
  19. "strings"
  20. "github.com/google/blueprint"
  21. "github.com/google/blueprint/proptools"
  22. "android/soong/android"
  23. "android/soong/bazel"
  24. "android/soong/cc"
  25. "android/soong/snapshot"
  26. "android/soong/tradefed"
  27. )
  28. // sh_binary is for shell scripts (and batch files) that are installed as
  29. // executable files into .../bin/
  30. //
  31. // Do not use them for prebuilt C/C++/etc files. Use cc_prebuilt_binary
  32. // instead.
  33. var pctx = android.NewPackageContext("android/soong/sh")
  34. func init() {
  35. pctx.Import("android/soong/android")
  36. registerShBuildComponents(android.InitRegistrationContext)
  37. }
  38. func registerShBuildComponents(ctx android.RegistrationContext) {
  39. ctx.RegisterModuleType("sh_binary", ShBinaryFactory)
  40. ctx.RegisterModuleType("sh_binary_host", ShBinaryHostFactory)
  41. ctx.RegisterModuleType("sh_test", ShTestFactory)
  42. ctx.RegisterModuleType("sh_test_host", ShTestHostFactory)
  43. }
  44. // Test fixture preparer that will register most sh build components.
  45. //
  46. // Singletons and mutators should only be added here if they are needed for a majority of sh
  47. // module types, otherwise they should be added under a separate preparer to allow them to be
  48. // selected only when needed to reduce test execution time.
  49. //
  50. // Module types do not have much of an overhead unless they are used so this should include as many
  51. // module types as possible. The exceptions are those module types that require mutators and/or
  52. // singletons in order to function in which case they should be kept together in a separate
  53. // preparer.
  54. var PrepareForTestWithShBuildComponents = android.GroupFixturePreparers(
  55. android.FixtureRegisterWithContext(registerShBuildComponents),
  56. )
  57. type shBinaryProperties struct {
  58. // Source file of this prebuilt.
  59. Src *string `android:"path,arch_variant"`
  60. // optional subdirectory under which this file is installed into
  61. Sub_dir *string `android:"arch_variant"`
  62. // optional name for the installed file. If unspecified, name of the module is used as the file name
  63. Filename *string `android:"arch_variant"`
  64. // when set to true, and filename property is not set, the name for the installed file
  65. // is the same as the file name of the source file.
  66. Filename_from_src *bool `android:"arch_variant"`
  67. // Whether this module is directly installable to one of the partitions. Default: true.
  68. Installable *bool
  69. // install symlinks to the binary
  70. Symlinks []string `android:"arch_variant"`
  71. // Make this module available when building for ramdisk.
  72. // On device without a dedicated recovery partition, the module is only
  73. // available after switching root into
  74. // /first_stage_ramdisk. To expose the module before switching root, install
  75. // the recovery variant instead.
  76. Ramdisk_available *bool
  77. // Make this module available when building for vendor ramdisk.
  78. // On device without a dedicated recovery partition, the module is only
  79. // available after switching root into
  80. // /first_stage_ramdisk. To expose the module before switching root, install
  81. // the recovery variant instead.
  82. Vendor_ramdisk_available *bool
  83. // Make this module available when building for recovery.
  84. Recovery_available *bool
  85. }
  86. type TestProperties struct {
  87. // list of compatibility suites (for example "cts", "vts") that the module should be
  88. // installed into.
  89. Test_suites []string `android:"arch_variant"`
  90. // the name of the test configuration (for example "AndroidTest.xml") that should be
  91. // installed with the module.
  92. Test_config *string `android:"path,arch_variant"`
  93. // list of files or filegroup modules that provide data that should be installed alongside
  94. // the test.
  95. Data []string `android:"path,arch_variant"`
  96. // Add RootTargetPreparer to auto generated test config. This guarantees the test to run
  97. // with root permission.
  98. Require_root *bool
  99. // the name of the test configuration template (for example "AndroidTestTemplate.xml") that
  100. // should be installed with the module.
  101. Test_config_template *string `android:"path,arch_variant"`
  102. // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
  103. // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
  104. // explicitly.
  105. Auto_gen_config *bool
  106. // list of binary modules that should be installed alongside the test
  107. Data_bins []string `android:"path,arch_variant"`
  108. // list of library modules that should be installed alongside the test
  109. Data_libs []string `android:"path,arch_variant"`
  110. // list of device binary modules that should be installed alongside the test.
  111. // Only available for host sh_test modules.
  112. Data_device_bins []string `android:"path,arch_variant"`
  113. // list of device library modules that should be installed alongside the test.
  114. // Only available for host sh_test modules.
  115. Data_device_libs []string `android:"path,arch_variant"`
  116. // Install the test into a folder named for the module in all test suites.
  117. Per_testcase_directory *bool
  118. // Test options.
  119. Test_options android.CommonTestOptions
  120. }
  121. type ShBinary struct {
  122. android.ModuleBase
  123. android.BazelModuleBase
  124. properties shBinaryProperties
  125. sourceFilePath android.Path
  126. outputFilePath android.OutputPath
  127. installedFile android.InstallPath
  128. }
  129. var _ android.HostToolProvider = (*ShBinary)(nil)
  130. type ShTest struct {
  131. ShBinary
  132. testProperties TestProperties
  133. installDir android.InstallPath
  134. data android.Paths
  135. testConfig android.Path
  136. dataModules map[string]android.Path
  137. }
  138. func (s *ShBinary) HostToolPath() android.OptionalPath {
  139. return android.OptionalPathForPath(s.installedFile)
  140. }
  141. func (s *ShBinary) DepsMutator(ctx android.BottomUpMutatorContext) {
  142. }
  143. func (s *ShBinary) OutputFile() android.OutputPath {
  144. return s.outputFilePath
  145. }
  146. func (s *ShBinary) SubDir() string {
  147. return proptools.String(s.properties.Sub_dir)
  148. }
  149. func (s *ShBinary) RelativeInstallPath() string {
  150. return s.SubDir()
  151. }
  152. func (s *ShBinary) Installable() bool {
  153. return s.properties.Installable == nil || proptools.Bool(s.properties.Installable)
  154. }
  155. func (s *ShBinary) Symlinks() []string {
  156. return s.properties.Symlinks
  157. }
  158. var _ android.ImageInterface = (*ShBinary)(nil)
  159. func (s *ShBinary) ImageMutatorBegin(ctx android.BaseModuleContext) {}
  160. func (s *ShBinary) CoreVariantNeeded(ctx android.BaseModuleContext) bool {
  161. return !s.ModuleBase.InstallInRecovery() && !s.ModuleBase.InstallInRamdisk()
  162. }
  163. func (s *ShBinary) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
  164. return proptools.Bool(s.properties.Ramdisk_available) || s.ModuleBase.InstallInRamdisk()
  165. }
  166. func (s *ShBinary) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
  167. return proptools.Bool(s.properties.Vendor_ramdisk_available) || s.ModuleBase.InstallInVendorRamdisk()
  168. }
  169. func (s *ShBinary) DebugRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
  170. return false
  171. }
  172. func (s *ShBinary) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
  173. return proptools.Bool(s.properties.Recovery_available) || s.ModuleBase.InstallInRecovery()
  174. }
  175. func (s *ShBinary) ExtraImageVariations(ctx android.BaseModuleContext) []string {
  176. return nil
  177. }
  178. func (s *ShBinary) SetImageVariation(ctx android.BaseModuleContext, variation string, module android.Module) {
  179. }
  180. func (s *ShBinary) generateAndroidBuildActions(ctx android.ModuleContext) {
  181. if s.properties.Src == nil {
  182. ctx.PropertyErrorf("src", "missing prebuilt source file")
  183. }
  184. s.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(s.properties.Src))
  185. filename := proptools.String(s.properties.Filename)
  186. filenameFromSrc := proptools.Bool(s.properties.Filename_from_src)
  187. if filename == "" {
  188. if filenameFromSrc {
  189. filename = s.sourceFilePath.Base()
  190. } else {
  191. filename = ctx.ModuleName()
  192. }
  193. } else if filenameFromSrc {
  194. ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
  195. return
  196. }
  197. s.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath
  198. // This ensures that outputFilePath has the correct name for others to
  199. // use, as the source file may have a different name.
  200. ctx.Build(pctx, android.BuildParams{
  201. Rule: android.CpExecutable,
  202. Output: s.outputFilePath,
  203. Input: s.sourceFilePath,
  204. })
  205. }
  206. func (s *ShBinary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
  207. s.generateAndroidBuildActions(ctx)
  208. installDir := android.PathForModuleInstall(ctx, "bin", proptools.String(s.properties.Sub_dir))
  209. if !s.Installable() {
  210. s.SkipInstall()
  211. }
  212. s.installedFile = ctx.InstallExecutable(installDir, s.outputFilePath.Base(), s.outputFilePath)
  213. for _, symlink := range s.Symlinks() {
  214. ctx.InstallSymlink(installDir, symlink, s.installedFile)
  215. }
  216. }
  217. func (s *ShBinary) AndroidMkEntries() []android.AndroidMkEntries {
  218. return []android.AndroidMkEntries{android.AndroidMkEntries{
  219. Class: "EXECUTABLES",
  220. OutputFile: android.OptionalPathForPath(s.outputFilePath),
  221. Include: "$(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk",
  222. ExtraEntries: []android.AndroidMkExtraEntriesFunc{
  223. func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
  224. s.customAndroidMkEntries(entries)
  225. entries.SetString("LOCAL_MODULE_RELATIVE_PATH", proptools.String(s.properties.Sub_dir))
  226. entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !s.Installable())
  227. },
  228. },
  229. }}
  230. }
  231. func (s *ShBinary) customAndroidMkEntries(entries *android.AndroidMkEntries) {
  232. entries.SetString("LOCAL_MODULE_SUFFIX", "")
  233. entries.SetString("LOCAL_MODULE_STEM", s.outputFilePath.Rel())
  234. if len(s.properties.Symlinks) > 0 {
  235. entries.SetString("LOCAL_MODULE_SYMLINKS", strings.Join(s.properties.Symlinks, " "))
  236. }
  237. }
  238. type dependencyTag struct {
  239. blueprint.BaseDependencyTag
  240. name string
  241. }
  242. var (
  243. shTestDataBinsTag = dependencyTag{name: "dataBins"}
  244. shTestDataLibsTag = dependencyTag{name: "dataLibs"}
  245. shTestDataDeviceBinsTag = dependencyTag{name: "dataDeviceBins"}
  246. shTestDataDeviceLibsTag = dependencyTag{name: "dataDeviceLibs"}
  247. )
  248. var sharedLibVariations = []blueprint.Variation{{Mutator: "link", Variation: "shared"}}
  249. func (s *ShTest) DepsMutator(ctx android.BottomUpMutatorContext) {
  250. s.ShBinary.DepsMutator(ctx)
  251. ctx.AddFarVariationDependencies(ctx.Target().Variations(), shTestDataBinsTag, s.testProperties.Data_bins...)
  252. ctx.AddFarVariationDependencies(append(ctx.Target().Variations(), sharedLibVariations...),
  253. shTestDataLibsTag, s.testProperties.Data_libs...)
  254. if ctx.Target().Os.Class == android.Host && len(ctx.Config().Targets[android.Android]) > 0 {
  255. deviceVariations := ctx.Config().AndroidFirstDeviceTarget.Variations()
  256. ctx.AddFarVariationDependencies(deviceVariations, shTestDataDeviceBinsTag, s.testProperties.Data_device_bins...)
  257. ctx.AddFarVariationDependencies(append(deviceVariations, sharedLibVariations...),
  258. shTestDataDeviceLibsTag, s.testProperties.Data_device_libs...)
  259. } else if ctx.Target().Os.Class != android.Host {
  260. if len(s.testProperties.Data_device_bins) > 0 {
  261. ctx.PropertyErrorf("data_device_bins", "only available for host modules")
  262. }
  263. if len(s.testProperties.Data_device_libs) > 0 {
  264. ctx.PropertyErrorf("data_device_libs", "only available for host modules")
  265. }
  266. }
  267. }
  268. func (s *ShTest) addToDataModules(ctx android.ModuleContext, relPath string, path android.Path) {
  269. if _, exists := s.dataModules[relPath]; exists {
  270. ctx.ModuleErrorf("data modules have a conflicting installation path, %v - %s, %s",
  271. relPath, s.dataModules[relPath].String(), path.String())
  272. return
  273. }
  274. s.dataModules[relPath] = path
  275. }
  276. func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
  277. s.ShBinary.generateAndroidBuildActions(ctx)
  278. testDir := "nativetest"
  279. if ctx.Target().Arch.ArchType.Multilib == "lib64" {
  280. testDir = "nativetest64"
  281. }
  282. if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
  283. testDir = filepath.Join(testDir, ctx.Target().NativeBridgeRelativePath)
  284. } else if !ctx.Host() && ctx.Config().HasMultilibConflict(ctx.Arch().ArchType) {
  285. testDir = filepath.Join(testDir, ctx.Arch().ArchType.String())
  286. }
  287. if s.SubDir() != "" {
  288. // Don't add the module name to the installation path if sub_dir is specified for backward
  289. // compatibility.
  290. s.installDir = android.PathForModuleInstall(ctx, testDir, s.SubDir())
  291. } else {
  292. s.installDir = android.PathForModuleInstall(ctx, testDir, s.Name())
  293. }
  294. s.installedFile = ctx.InstallExecutable(s.installDir, s.outputFilePath.Base(), s.outputFilePath)
  295. s.data = android.PathsForModuleSrc(ctx, s.testProperties.Data)
  296. var configs []tradefed.Config
  297. if Bool(s.testProperties.Require_root) {
  298. configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", nil})
  299. } else {
  300. options := []tradefed.Option{{Name: "force-root", Value: "false"}}
  301. configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.RootTargetPreparer", options})
  302. }
  303. if len(s.testProperties.Data_device_bins) > 0 {
  304. moduleName := s.Name()
  305. remoteDir := "/data/local/tests/unrestricted/" + moduleName + "/"
  306. options := []tradefed.Option{{Name: "cleanup", Value: "true"}}
  307. for _, bin := range s.testProperties.Data_device_bins {
  308. options = append(options, tradefed.Option{Name: "push-file", Key: bin, Value: remoteDir + bin})
  309. }
  310. configs = append(configs, tradefed.Object{"target_preparer", "com.android.tradefed.targetprep.PushFilePreparer", options})
  311. }
  312. s.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
  313. TestConfigProp: s.testProperties.Test_config,
  314. TestConfigTemplateProp: s.testProperties.Test_config_template,
  315. TestSuites: s.testProperties.Test_suites,
  316. Config: configs,
  317. AutoGenConfig: s.testProperties.Auto_gen_config,
  318. OutputFileName: s.outputFilePath.Base(),
  319. DeviceTemplate: "${ShellTestConfigTemplate}",
  320. HostTemplate: "${ShellTestConfigTemplate}",
  321. })
  322. s.dataModules = make(map[string]android.Path)
  323. ctx.VisitDirectDeps(func(dep android.Module) {
  324. depTag := ctx.OtherModuleDependencyTag(dep)
  325. switch depTag {
  326. case shTestDataBinsTag, shTestDataDeviceBinsTag:
  327. path := android.OutputFileForModule(ctx, dep, "")
  328. s.addToDataModules(ctx, path.Base(), path)
  329. case shTestDataLibsTag, shTestDataDeviceLibsTag:
  330. if cc, isCc := dep.(*cc.Module); isCc {
  331. // Copy to an intermediate output directory to append "lib[64]" to the path,
  332. // so that it's compatible with the default rpath values.
  333. var relPath string
  334. if cc.Arch().ArchType.Multilib == "lib64" {
  335. relPath = filepath.Join("lib64", cc.OutputFile().Path().Base())
  336. } else {
  337. relPath = filepath.Join("lib", cc.OutputFile().Path().Base())
  338. }
  339. if _, exist := s.dataModules[relPath]; exist {
  340. return
  341. }
  342. relocatedLib := android.PathForModuleOut(ctx, "relocated", relPath)
  343. ctx.Build(pctx, android.BuildParams{
  344. Rule: android.Cp,
  345. Input: cc.OutputFile().Path(),
  346. Output: relocatedLib,
  347. })
  348. s.addToDataModules(ctx, relPath, relocatedLib)
  349. return
  350. }
  351. property := "data_libs"
  352. if depTag == shTestDataDeviceBinsTag {
  353. property = "data_device_libs"
  354. }
  355. ctx.PropertyErrorf(property, "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
  356. }
  357. })
  358. }
  359. func (s *ShTest) InstallInData() bool {
  360. return true
  361. }
  362. func (s *ShTest) AndroidMkEntries() []android.AndroidMkEntries {
  363. return []android.AndroidMkEntries{android.AndroidMkEntries{
  364. Class: "NATIVE_TESTS",
  365. OutputFile: android.OptionalPathForPath(s.outputFilePath),
  366. Include: "$(BUILD_SYSTEM)/soong_cc_rust_prebuilt.mk",
  367. ExtraEntries: []android.AndroidMkExtraEntriesFunc{
  368. func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
  369. s.customAndroidMkEntries(entries)
  370. entries.SetPath("LOCAL_MODULE_PATH", s.installDir)
  371. entries.AddCompatibilityTestSuites(s.testProperties.Test_suites...)
  372. if s.testConfig != nil {
  373. entries.SetPath("LOCAL_FULL_TEST_CONFIG", s.testConfig)
  374. }
  375. for _, d := range s.data {
  376. rel := d.Rel()
  377. path := d.String()
  378. if !strings.HasSuffix(path, rel) {
  379. panic(fmt.Errorf("path %q does not end with %q", path, rel))
  380. }
  381. path = strings.TrimSuffix(path, rel)
  382. entries.AddStrings("LOCAL_TEST_DATA", path+":"+rel)
  383. }
  384. relPaths := make([]string, 0)
  385. for relPath, _ := range s.dataModules {
  386. relPaths = append(relPaths, relPath)
  387. }
  388. sort.Strings(relPaths)
  389. for _, relPath := range relPaths {
  390. dir := strings.TrimSuffix(s.dataModules[relPath].String(), relPath)
  391. entries.AddStrings("LOCAL_TEST_DATA", dir+":"+relPath)
  392. }
  393. if s.testProperties.Data_bins != nil {
  394. entries.AddStrings("LOCAL_TEST_DATA_BINS", s.testProperties.Data_bins...)
  395. }
  396. entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", Bool(s.testProperties.Per_testcase_directory))
  397. s.testProperties.Test_options.SetAndroidMkEntries(entries)
  398. },
  399. },
  400. }}
  401. }
  402. func initShBinaryModule(s *ShBinary, useBazel bool) {
  403. s.AddProperties(&s.properties)
  404. if useBazel {
  405. android.InitBazelModule(s)
  406. }
  407. }
  408. // sh_binary is for a shell script or batch file to be installed as an
  409. // executable binary to <partition>/bin.
  410. func ShBinaryFactory() android.Module {
  411. module := &ShBinary{}
  412. initShBinaryModule(module, true)
  413. android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibFirst)
  414. return module
  415. }
  416. // sh_binary_host is for a shell script to be installed as an executable binary
  417. // to $(HOST_OUT)/bin.
  418. func ShBinaryHostFactory() android.Module {
  419. module := &ShBinary{}
  420. initShBinaryModule(module, true)
  421. android.InitAndroidArchModule(module, android.HostSupported, android.MultilibFirst)
  422. return module
  423. }
  424. // sh_test defines a shell script based test module.
  425. func ShTestFactory() android.Module {
  426. module := &ShTest{}
  427. initShBinaryModule(&module.ShBinary, false)
  428. module.AddProperties(&module.testProperties)
  429. android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibFirst)
  430. return module
  431. }
  432. // sh_test_host defines a shell script based test module that runs on a host.
  433. func ShTestHostFactory() android.Module {
  434. module := &ShTest{}
  435. initShBinaryModule(&module.ShBinary, false)
  436. module.AddProperties(&module.testProperties)
  437. // Default sh_test_host to unit_tests = true
  438. if module.testProperties.Test_options.Unit_test == nil {
  439. module.testProperties.Test_options.Unit_test = proptools.BoolPtr(true)
  440. }
  441. android.InitAndroidArchModule(module, android.HostSupported, android.MultilibFirst)
  442. return module
  443. }
  444. type bazelShBinaryAttributes struct {
  445. Srcs bazel.LabelListAttribute
  446. Filename *string
  447. Sub_dir *string
  448. // Bazel also supports the attributes below, but (so far) these are not required for Bionic
  449. // deps
  450. // data
  451. // args
  452. // compatible_with
  453. // deprecation
  454. // distribs
  455. // env
  456. // exec_compatible_with
  457. // exec_properties
  458. // features
  459. // licenses
  460. // output_licenses
  461. // restricted_to
  462. // tags
  463. // target_compatible_with
  464. // testonly
  465. // toolchains
  466. // visibility
  467. }
  468. func (m *ShBinary) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
  469. srcs := bazel.MakeLabelListAttribute(
  470. android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}))
  471. var filename *string
  472. if m.properties.Filename != nil {
  473. filename = m.properties.Filename
  474. }
  475. var subDir *string
  476. if m.properties.Sub_dir != nil {
  477. subDir = m.properties.Sub_dir
  478. }
  479. attrs := &bazelShBinaryAttributes{
  480. Srcs: srcs,
  481. Filename: filename,
  482. Sub_dir: subDir,
  483. }
  484. props := bazel.BazelTargetModuleProperties{
  485. Rule_class: "sh_binary",
  486. Bzl_load_location: "//build/bazel/rules:sh_binary.bzl",
  487. }
  488. ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
  489. }
  490. var Bool = proptools.Bool
  491. var _ snapshot.RelativeInstallPath = (*ShBinary)(nil)