Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 1 | // Copyright 2016 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 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 20 | "android/soong/android" |
Jingwen Chen | 8c1b97e | 2021-02-18 03:21:34 -0500 | [diff] [blame] | 21 | "android/soong/bazel" |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 22 | ) |
| 23 | |
| 24 | // |
| 25 | // Objects (for crt*.o) |
| 26 | // |
| 27 | |
| 28 | func init() { |
Colin Cross | e40b4ea | 2018-10-02 22:25:58 -0700 | [diff] [blame] | 29 | android.RegisterModuleType("cc_object", ObjectFactory) |
Martin Stjernholm | cd07bce | 2020-03-10 22:37:59 +0000 | [diff] [blame] | 30 | android.RegisterSdkMemberType(ccObjectSdkMemberType) |
Jingwen Chen | 8c1b97e | 2021-02-18 03:21:34 -0500 | [diff] [blame] | 31 | |
| 32 | android.RegisterBp2BuildMutator("cc_object", ObjectBp2Build) |
Martin Stjernholm | cd07bce | 2020-03-10 22:37:59 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | var ccObjectSdkMemberType = &librarySdkMemberType{ |
| 36 | SdkMemberTypeBase: android.SdkMemberTypeBase{ |
| 37 | PropertyName: "native_objects", |
| 38 | SupportsSdk: true, |
| 39 | }, |
| 40 | prebuiltModuleType: "cc_prebuilt_object", |
| 41 | linkTypes: nil, |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | type objectLinker struct { |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 45 | *baseLinker |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 46 | Properties ObjectLinkerProperties |
| 47 | } |
| 48 | |
Chris Parsons | 8d6e433 | 2021-02-22 16:13:50 -0500 | [diff] [blame] | 49 | type objectBazelHandler struct { |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 0d99045 | 2021-08-11 16:46:13 +0000 | [diff] [blame] | 50 | android.BazelHandler |
Chris Parsons | 8d6e433 | 2021-02-22 16:13:50 -0500 | [diff] [blame] | 51 | |
| 52 | module *Module |
| 53 | } |
| 54 | |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 0d99045 | 2021-08-11 16:46:13 +0000 | [diff] [blame] | 55 | func (handler *objectBazelHandler) GenerateBazelBuildActions(ctx android.ModuleContext, label string) bool { |
Liz Kammer | 8206d4f | 2021-03-03 16:40:52 -0500 | [diff] [blame] | 56 | bazelCtx := ctx.Config().BazelContext |
Chris Parsons | 787fb36 | 2021-10-14 18:43:51 -0400 | [diff] [blame] | 57 | objPaths, ok := bazelCtx.GetOutputFiles(label, android.GetConfigKey(ctx)) |
Liz Kammer | 8206d4f | 2021-03-03 16:40:52 -0500 | [diff] [blame] | 58 | if ok { |
| 59 | if len(objPaths) != 1 { |
| 60 | ctx.ModuleErrorf("expected exactly one object file for '%s', but got %s", label, objPaths) |
| 61 | return false |
| 62 | } |
| 63 | |
| 64 | handler.module.outputFile = android.OptionalPathForPath(android.PathForBazelOut(ctx, objPaths[0])) |
| 65 | } |
| 66 | return ok |
Chris Parsons | 8d6e433 | 2021-02-22 16:13:50 -0500 | [diff] [blame] | 67 | } |
| 68 | |
Pete Bentley | 74c9bba | 2019-08-16 20:25:06 +0100 | [diff] [blame] | 69 | type ObjectLinkerProperties struct { |
Colin Cross | 137d7da | 2021-06-21 16:41:29 -0700 | [diff] [blame] | 70 | // list of static library modules that should only provide headers for this module. |
| 71 | Static_libs []string `android:"arch_variant,variant_prepend"` |
| 72 | |
| 73 | // list of shared library modules should only provide headers for this module. |
| 74 | Shared_libs []string `android:"arch_variant"` |
| 75 | |
Pete Bentley | 74c9bba | 2019-08-16 20:25:06 +0100 | [diff] [blame] | 76 | // list of modules that should only provide headers for this module. |
| 77 | Header_libs []string `android:"arch_variant,variant_prepend"` |
| 78 | |
Colin Cross | 137d7da | 2021-06-21 16:41:29 -0700 | [diff] [blame] | 79 | // list of default libraries that will provide headers for this module. If unset, generally |
| 80 | // defaults to libc, libm, and libdl. Set to [] to prevent using headers from the defaults. |
Colin Cross | 6b8f425 | 2021-07-22 11:39:44 -0700 | [diff] [blame] | 81 | System_shared_libs []string `android:"arch_variant"` |
Colin Cross | 137d7da | 2021-06-21 16:41:29 -0700 | [diff] [blame] | 82 | |
Pete Bentley | 74c9bba | 2019-08-16 20:25:06 +0100 | [diff] [blame] | 83 | // names of other cc_object modules to link into this module using partial linking |
| 84 | Objs []string `android:"arch_variant"` |
| 85 | |
| 86 | // if set, add an extra objcopy --prefix-symbols= step |
| 87 | Prefix_symbols *string |
| 88 | |
| 89 | // if set, the path to a linker script to pass to ld -r when combining multiple object files. |
| 90 | Linker_script *string `android:"path,arch_variant"` |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame] | 91 | |
| 92 | // Indicates that this module is a CRT object. CRT objects will be split |
| 93 | // into a variant per-API level between min_sdk_version and current. |
| 94 | Crt *bool |
Pete Bentley | 74c9bba | 2019-08-16 20:25:06 +0100 | [diff] [blame] | 95 | } |
| 96 | |
Colin Cross | 7cabd42 | 2021-06-25 14:21:04 -0700 | [diff] [blame] | 97 | func newObject(hod android.HostOrDeviceSupported) *Module { |
| 98 | module := newBaseModule(hod, android.MultilibBoth) |
Martin Stjernholm | 0b92ac8 | 2020-03-11 21:45:49 +0000 | [diff] [blame] | 99 | module.sanitize = &sanitize{} |
| 100 | module.stl = &stl{} |
| 101 | return module |
| 102 | } |
| 103 | |
Patrice Arruda | baff0ce | 2019-03-26 10:39:49 -0700 | [diff] [blame] | 104 | // cc_object runs the compiler without running the linker. It is rarely |
| 105 | // necessary, but sometimes used to generate .s files from .c files to use as |
| 106 | // input to a cc_genrule module. |
Colin Cross | e40b4ea | 2018-10-02 22:25:58 -0700 | [diff] [blame] | 107 | func ObjectFactory() android.Module { |
Colin Cross | 7cabd42 | 2021-06-25 14:21:04 -0700 | [diff] [blame] | 108 | module := newObject(android.HostAndDeviceSupported) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 109 | module.linker = &objectLinker{ |
Peter Collingbourne | 1c648b8 | 2019-09-26 12:24:45 -0700 | [diff] [blame] | 110 | baseLinker: NewBaseLinker(module.sanitize), |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 111 | } |
| 112 | module.compiler = NewBaseCompiler() |
Chris Parsons | 8d6e433 | 2021-02-22 16:13:50 -0500 | [diff] [blame] | 113 | module.bazelHandler = &objectBazelHandler{module: module} |
Peter Collingbourne | 486e42c | 2018-10-25 10:53:44 -0700 | [diff] [blame] | 114 | |
| 115 | // Clang's address-significance tables are incompatible with ld -r. |
| 116 | module.compiler.appendCflags([]string{"-fno-addrsig"}) |
| 117 | |
Martin Stjernholm | cd07bce | 2020-03-10 22:37:59 +0000 | [diff] [blame] | 118 | module.sdkMemberTypes = []android.SdkMemberType{ccObjectSdkMemberType} |
Jingwen Chen | 8c1b97e | 2021-02-18 03:21:34 -0500 | [diff] [blame] | 119 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 120 | return module.Init() |
| 121 | } |
| 122 | |
Jingwen Chen | 8c1b97e | 2021-02-18 03:21:34 -0500 | [diff] [blame] | 123 | // For bp2build conversion. |
| 124 | type bazelObjectAttributes struct { |
Chris Parsons | a37e195 | 2021-09-28 16:47:36 -0400 | [diff] [blame] | 125 | Srcs bazel.LabelListAttribute |
| 126 | Srcs_as bazel.LabelListAttribute |
| 127 | Hdrs bazel.LabelListAttribute |
| 128 | Deps bazel.LabelListAttribute |
| 129 | System_dynamic_deps bazel.LabelListAttribute |
| 130 | Copts bazel.StringListAttribute |
| 131 | Asflags bazel.StringListAttribute |
| 132 | Local_includes bazel.StringListAttribute |
| 133 | Absolute_includes bazel.StringListAttribute |
| 134 | Stl *string |
| 135 | Linker_script bazel.LabelAttribute |
Jingwen Chen | 8c1b97e | 2021-02-18 03:21:34 -0500 | [diff] [blame] | 136 | } |
| 137 | |
Jingwen Chen | 8c1b97e | 2021-02-18 03:21:34 -0500 | [diff] [blame] | 138 | // ObjectBp2Build is the bp2build converter from cc_object modules to the |
| 139 | // Bazel equivalent target, plus any necessary include deps for the cc_object. |
| 140 | func ObjectBp2Build(ctx android.TopDownMutatorContext) { |
| 141 | m, ok := ctx.Module().(*Module) |
Jingwen Chen | 12b4c27 | 2021-03-10 02:05:59 -0500 | [diff] [blame] | 142 | if !ok || !m.ConvertWithBp2build(ctx) { |
Jingwen Chen | 8c1b97e | 2021-02-18 03:21:34 -0500 | [diff] [blame] | 143 | return |
| 144 | } |
| 145 | |
| 146 | // a Module can be something other than a cc_object. |
| 147 | if ctx.ModuleType() != "cc_object" { |
| 148 | return |
| 149 | } |
| 150 | |
| 151 | if m.compiler == nil { |
| 152 | // a cc_object must have access to the compiler decorator for its props. |
| 153 | ctx.ModuleErrorf("compiler must not be nil for a cc_object module") |
| 154 | } |
| 155 | |
Jingwen Chen | 5d86449 | 2021-02-24 07:20:12 -0500 | [diff] [blame] | 156 | // Set arch-specific configurable attributes |
Liz Kammer | e658348 | 2021-10-19 13:56:10 -0400 | [diff] [blame] | 157 | baseAttributes := bp2BuildParseBaseProps(ctx, m) |
| 158 | compilerAttrs := baseAttributes.compilerAttributes |
Jingwen Chen | 0702791 | 2021-03-15 06:02:43 -0400 | [diff] [blame] | 159 | var deps bazel.LabelListAttribute |
Chris Parsons | a37e195 | 2021-09-28 16:47:36 -0400 | [diff] [blame] | 160 | systemDynamicDeps := bazel.LabelListAttribute{ForceSpecifyEmptyList: true} |
| 161 | |
| 162 | var linkerScript bazel.LabelAttribute |
| 163 | |
| 164 | for axis, configToProps := range m.GetArchVariantProperties(ctx, &ObjectLinkerProperties{}) { |
| 165 | for config, props := range configToProps { |
| 166 | if objectLinkerProps, ok := props.(*ObjectLinkerProperties); ok { |
| 167 | if objectLinkerProps.Linker_script != nil { |
| 168 | linkerScript.SetSelectValue(axis, config, android.BazelLabelForModuleSrcSingle(ctx, *objectLinkerProps.Linker_script)) |
| 169 | } |
| 170 | deps.SetSelectValue(axis, config, android.BazelLabelForModuleDeps(ctx, objectLinkerProps.Objs)) |
| 171 | systemSharedLibs := objectLinkerProps.System_shared_libs |
| 172 | if len(systemSharedLibs) > 0 { |
| 173 | systemSharedLibs = android.FirstUniqueStrings(systemSharedLibs) |
| 174 | } |
| 175 | systemDynamicDeps.SetSelectValue(axis, config, bazelLabelForSharedDeps(ctx, systemSharedLibs)) |
| 176 | } |
Jingwen Chen | db12024 | 2021-02-23 00:46:47 -0500 | [diff] [blame] | 177 | } |
| 178 | } |
Chris Parsons | a37e195 | 2021-09-28 16:47:36 -0400 | [diff] [blame] | 179 | deps.ResolveExcludes() |
Jingwen Chen | db12024 | 2021-02-23 00:46:47 -0500 | [diff] [blame] | 180 | |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 181 | // Don't split cc_object srcs across languages. Doing so would add complexity, |
| 182 | // and this isn't typically done for cc_object. |
| 183 | srcs := compilerAttrs.srcs |
| 184 | srcs.Append(compilerAttrs.cSrcs) |
Chris Parsons | 69fa9f9 | 2021-07-13 11:47:44 -0400 | [diff] [blame] | 185 | |
| 186 | asFlags := compilerAttrs.asFlags |
| 187 | if compilerAttrs.asSrcs.IsEmpty() { |
| 188 | // Skip asflags for BUILD file simplicity if there are no assembly sources. |
| 189 | asFlags = bazel.MakeStringListAttribute(nil) |
| 190 | } |
Chris Parsons | 990c4f4 | 2021-05-25 12:10:58 -0400 | [diff] [blame] | 191 | |
Jingwen Chen | 8c1b97e | 2021-02-18 03:21:34 -0500 | [diff] [blame] | 192 | attrs := &bazelObjectAttributes{ |
Chris Parsons | a37e195 | 2021-09-28 16:47:36 -0400 | [diff] [blame] | 193 | Srcs: srcs, |
| 194 | Srcs_as: compilerAttrs.asSrcs, |
| 195 | Deps: deps, |
| 196 | System_dynamic_deps: systemDynamicDeps, |
| 197 | Copts: compilerAttrs.copts, |
| 198 | Asflags: asFlags, |
| 199 | Local_includes: compilerAttrs.localIncludes, |
| 200 | Absolute_includes: compilerAttrs.absoluteIncludes, |
| 201 | Stl: compilerAttrs.stl, |
| 202 | Linker_script: linkerScript, |
Jingwen Chen | 8c1b97e | 2021-02-18 03:21:34 -0500 | [diff] [blame] | 203 | } |
| 204 | |
Liz Kammer | fc46bc1 | 2021-02-19 11:06:17 -0500 | [diff] [blame] | 205 | props := bazel.BazelTargetModuleProperties{ |
| 206 | Rule_class: "cc_object", |
| 207 | Bzl_load_location: "//build/bazel/rules:cc_object.bzl", |
| 208 | } |
Jingwen Chen | 8c1b97e | 2021-02-18 03:21:34 -0500 | [diff] [blame] | 209 | |
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux | 447f6c9 | 2021-08-31 20:30:36 +0000 | [diff] [blame] | 210 | ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs) |
Jingwen Chen | 8c1b97e | 2021-02-18 03:21:34 -0500 | [diff] [blame] | 211 | } |
| 212 | |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 213 | func (object *objectLinker) appendLdflags(flags []string) { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 214 | panic(fmt.Errorf("appendLdflags on objectLinker not supported")) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 215 | } |
| 216 | |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 217 | func (object *objectLinker) linkerProps() []interface{} { |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 218 | return []interface{}{&object.Properties} |
| 219 | } |
| 220 | |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 221 | func (*objectLinker) linkerInit(ctx BaseModuleContext) {} |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 222 | |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 223 | func (object *objectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { |
Paul Duffin | a37832a | 2019-07-18 12:31:26 +0100 | [diff] [blame] | 224 | deps.HeaderLibs = append(deps.HeaderLibs, object.Properties.Header_libs...) |
Colin Cross | 137d7da | 2021-06-21 16:41:29 -0700 | [diff] [blame] | 225 | deps.SharedLibs = append(deps.SharedLibs, object.Properties.Shared_libs...) |
| 226 | deps.StaticLibs = append(deps.StaticLibs, object.Properties.Static_libs...) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 227 | deps.ObjFiles = append(deps.ObjFiles, object.Properties.Objs...) |
Colin Cross | 137d7da | 2021-06-21 16:41:29 -0700 | [diff] [blame] | 228 | |
Colin Cross | 6b8f425 | 2021-07-22 11:39:44 -0700 | [diff] [blame] | 229 | deps.SystemSharedLibs = object.Properties.System_shared_libs |
Colin Cross | 137d7da | 2021-06-21 16:41:29 -0700 | [diff] [blame] | 230 | if deps.SystemSharedLibs == nil { |
Colin Cross | 6b8f425 | 2021-07-22 11:39:44 -0700 | [diff] [blame] | 231 | // Provide a default set of shared libraries if system_shared_libs is unspecified. |
Colin Cross | 137d7da | 2021-06-21 16:41:29 -0700 | [diff] [blame] | 232 | // Note: If an empty list [] is specified, it implies that the module declines the |
| 233 | // default shared libraries. |
| 234 | deps.SystemSharedLibs = append(deps.SystemSharedLibs, ctx.toolchain().DefaultSharedLibraries()...) |
| 235 | } |
| 236 | deps.LateSharedLibs = append(deps.LateSharedLibs, deps.SystemSharedLibs...) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 237 | return deps |
| 238 | } |
| 239 | |
Pete Bentley | 74c9bba | 2019-08-16 20:25:06 +0100 | [diff] [blame] | 240 | func (object *objectLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { |
Colin Cross | 33bac24 | 2021-07-14 17:03:16 -0700 | [diff] [blame] | 241 | flags.Global.LdFlags = append(flags.Global.LdFlags, ctx.toolchain().ToolchainLdflags()) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 242 | |
Pete Bentley | 74c9bba | 2019-08-16 20:25:06 +0100 | [diff] [blame] | 243 | if lds := android.OptionalPathForModuleSrc(ctx, object.Properties.Linker_script); lds.Valid() { |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 244 | flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-T,"+lds.String()) |
Pete Bentley | 74c9bba | 2019-08-16 20:25:06 +0100 | [diff] [blame] | 245 | flags.LdFlagsDeps = append(flags.LdFlagsDeps, lds.Path()) |
| 246 | } |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 247 | return flags |
| 248 | } |
| 249 | |
| 250 | func (object *objectLinker) link(ctx ModuleContext, |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 251 | flags Flags, deps PathDeps, objs Objects) android.Path { |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 252 | |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 253 | objs = objs.Append(deps.Objs) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 254 | |
| 255 | var outputFile android.Path |
Dan Willemsen | efb1dd9 | 2017-09-18 22:47:20 -0700 | [diff] [blame] | 256 | builderFlags := flagsToBuilderFlags(flags) |
| 257 | |
Pete Bentley | ab65ba9 | 2019-10-18 12:39:56 +0100 | [diff] [blame] | 258 | if len(objs.objFiles) == 1 && String(object.Properties.Linker_script) == "" { |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 259 | outputFile = objs.objFiles[0] |
Dan Willemsen | efb1dd9 | 2017-09-18 22:47:20 -0700 | [diff] [blame] | 260 | |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 261 | if String(object.Properties.Prefix_symbols) != "" { |
Dan Willemsen | efb1dd9 | 2017-09-18 22:47:20 -0700 | [diff] [blame] | 262 | output := android.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension) |
Chris Parsons | bf4f55f | 2020-11-23 17:02:44 -0500 | [diff] [blame] | 263 | transformBinaryPrefixSymbols(ctx, String(object.Properties.Prefix_symbols), outputFile, |
Dan Willemsen | efb1dd9 | 2017-09-18 22:47:20 -0700 | [diff] [blame] | 264 | builderFlags, output) |
| 265 | outputFile = output |
| 266 | } |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 267 | } else { |
| 268 | output := android.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 269 | outputFile = output |
Dan Willemsen | efb1dd9 | 2017-09-18 22:47:20 -0700 | [diff] [blame] | 270 | |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 271 | if String(object.Properties.Prefix_symbols) != "" { |
Dan Willemsen | efb1dd9 | 2017-09-18 22:47:20 -0700 | [diff] [blame] | 272 | input := android.PathForModuleOut(ctx, "unprefixed", ctx.ModuleName()+objectExtension) |
Chris Parsons | bf4f55f | 2020-11-23 17:02:44 -0500 | [diff] [blame] | 273 | transformBinaryPrefixSymbols(ctx, String(object.Properties.Prefix_symbols), input, |
Dan Willemsen | efb1dd9 | 2017-09-18 22:47:20 -0700 | [diff] [blame] | 274 | builderFlags, output) |
| 275 | output = input |
| 276 | } |
| 277 | |
Chris Parsons | bf4f55f | 2020-11-23 17:02:44 -0500 | [diff] [blame] | 278 | transformObjsToObj(ctx, objs.objFiles, builderFlags, output, flags.LdFlagsDeps) |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | ctx.CheckbuildFile(outputFile) |
| 282 | return outputFile |
| 283 | } |
Jiyong Park | af6d895 | 2019-01-31 12:21:23 +0900 | [diff] [blame] | 284 | |
Colin Cross | 137d7da | 2021-06-21 16:41:29 -0700 | [diff] [blame] | 285 | func (object *objectLinker) linkerSpecifiedDeps(specifiedDeps specifiedDeps) specifiedDeps { |
| 286 | specifiedDeps.sharedLibs = append(specifiedDeps.sharedLibs, object.Properties.Shared_libs...) |
| 287 | |
Colin Cross | 6b8f425 | 2021-07-22 11:39:44 -0700 | [diff] [blame] | 288 | // Must distinguish nil and [] in system_shared_libs - ensure that [] in |
Colin Cross | 137d7da | 2021-06-21 16:41:29 -0700 | [diff] [blame] | 289 | // either input list doesn't come out as nil. |
Colin Cross | 6b8f425 | 2021-07-22 11:39:44 -0700 | [diff] [blame] | 290 | if specifiedDeps.systemSharedLibs == nil { |
| 291 | specifiedDeps.systemSharedLibs = object.Properties.System_shared_libs |
Colin Cross | 137d7da | 2021-06-21 16:41:29 -0700 | [diff] [blame] | 292 | } else { |
Colin Cross | 6b8f425 | 2021-07-22 11:39:44 -0700 | [diff] [blame] | 293 | specifiedDeps.systemSharedLibs = append(specifiedDeps.systemSharedLibs, object.Properties.System_shared_libs...) |
Colin Cross | 137d7da | 2021-06-21 16:41:29 -0700 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | return specifiedDeps |
| 297 | } |
| 298 | |
Jiyong Park | af6d895 | 2019-01-31 12:21:23 +0900 | [diff] [blame] | 299 | func (object *objectLinker) unstrippedOutputFilePath() android.Path { |
| 300 | return nil |
| 301 | } |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 302 | |
| 303 | func (object *objectLinker) nativeCoverage() bool { |
| 304 | return true |
| 305 | } |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 306 | |
| 307 | func (object *objectLinker) coverageOutputFilePath() android.OptionalPath { |
| 308 | return android.OptionalPath{} |
| 309 | } |
Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 310 | |
| 311 | func (object *objectLinker) object() bool { |
| 312 | return true |
| 313 | } |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame] | 314 | |
| 315 | func (object *objectLinker) isCrt() bool { |
| 316 | return Bool(object.Properties.Crt) |
| 317 | } |