• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2019 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 android
16
17import (
18	"sort"
19	"strings"
20
21	"github.com/google/blueprint"
22	"github.com/google/blueprint/proptools"
23)
24
25// Extracted from SdkAware to make it easier to define custom subsets of the
26// SdkAware interface and improve code navigation within the IDE.
27//
28// In addition to its use in SdkAware this interface must also be implemented by
29// APEX to specify the SDKs required by that module and its contents. e.g. APEX
30// is expected to implement RequiredSdks() by reading its own properties like
31// `uses_sdks`.
32type RequiredSdks interface {
33	// The set of SDKs required by an APEX and its contents.
34	RequiredSdks() SdkRefs
35}
36
37// Provided to improve code navigation with the IDE.
38type sdkAwareWithoutModule interface {
39	RequiredSdks
40
41	// SdkMemberComponentName will return the name to use for a component of this module based on the
42	// base name of this module.
43	//
44	// The baseName is the name returned by ModuleBase.BaseModuleName(), i.e. the name specified in
45	// the name property in the .bp file so will not include the prebuilt_ prefix.
46	//
47	// The componentNameCreator is a func for creating the name of a component from the base name of
48	// the module, e.g. it could just append ".component" to the name passed in.
49	//
50	// This is intended to be called by prebuilt modules that create component models. It is because
51	// prebuilt module base names come in a variety of different forms:
52	// * unversioned - this is the same as the source module.
53	// * internal to an sdk - this is the unversioned name prefixed by the base name of the sdk
54	//   module.
55	// * versioned - this is the same as the internal with the addition of an "@<version>" suffix.
56	//
57	// While this can be called from a source module in that case it will behave the same way as the
58	// unversioned name and return the result of calling the componentNameCreator func on the supplied
59	// base name.
60	//
61	// e.g. Assuming the componentNameCreator func simply appends ".component" to the name passed in
62	// then this will work as follows:
63	// * An unversioned name of "foo" will return "foo.component".
64	// * An internal to the sdk name of "sdk_foo" will return "sdk_foo.component".
65	// * A versioned name of "sdk_foo@current" will return "sdk_foo.component@current".
66	//
67	// Note that in the latter case the ".component" suffix is added before the version. Adding it
68	// after would change the version.
69	SdkMemberComponentName(baseName string, componentNameCreator func(string) string) string
70
71	sdkBase() *SdkBase
72	MakeMemberOf(sdk SdkRef)
73	IsInAnySdk() bool
74
75	// IsVersioned determines whether the module is versioned, i.e. has a name of the form
76	// <name>@<version>
77	IsVersioned() bool
78
79	ContainingSdk() SdkRef
80	MemberName() string
81	BuildWithSdks(sdks SdkRefs)
82}
83
84// SdkAware is the interface that must be supported by any module to become a member of SDK or to be
85// built with SDK
86type SdkAware interface {
87	Module
88	sdkAwareWithoutModule
89}
90
91// SdkRef refers to a version of an SDK
92type SdkRef struct {
93	Name    string
94	Version string
95}
96
97// Unversioned determines if the SdkRef is referencing to the unversioned SDK module
98func (s SdkRef) Unversioned() bool {
99	return s.Version == ""
100}
101
102// String returns string representation of this SdkRef for debugging purpose
103func (s SdkRef) String() string {
104	if s.Name == "" {
105		return "(No Sdk)"
106	}
107	if s.Unversioned() {
108		return s.Name
109	}
110	return s.Name + string(SdkVersionSeparator) + s.Version
111}
112
113// SdkVersionSeparator is a character used to separate an sdk name and its version
114const SdkVersionSeparator = '@'
115
116// ParseSdkRef parses a `name@version` style string into a corresponding SdkRef struct
117func ParseSdkRef(ctx BaseModuleContext, str string, property string) SdkRef {
118	tokens := strings.Split(str, string(SdkVersionSeparator))
119	if len(tokens) < 1 || len(tokens) > 2 {
120		ctx.PropertyErrorf(property, "%q does not follow name@version syntax", str)
121		return SdkRef{Name: "invalid sdk name", Version: "invalid sdk version"}
122	}
123
124	name := tokens[0]
125
126	var version string
127	if len(tokens) == 2 {
128		version = tokens[1]
129	}
130
131	return SdkRef{Name: name, Version: version}
132}
133
134type SdkRefs []SdkRef
135
136// Contains tells if the given SdkRef is in this list of SdkRef's
137func (refs SdkRefs) Contains(s SdkRef) bool {
138	for _, r := range refs {
139		if r == s {
140			return true
141		}
142	}
143	return false
144}
145
146type sdkProperties struct {
147	// The SDK that this module is a member of. nil if it is not a member of any SDK
148	ContainingSdk *SdkRef `blueprint:"mutated"`
149
150	// The list of SDK names and versions that are used to build this module
151	RequiredSdks SdkRefs `blueprint:"mutated"`
152
153	// Name of the module that this sdk member is representing
154	Sdk_member_name *string
155}
156
157// SdkBase is a struct that is expected to be included in module types to implement the SdkAware
158// interface. InitSdkAwareModule should be called to initialize this struct.
159type SdkBase struct {
160	properties sdkProperties
161	module     SdkAware
162}
163
164func (s *SdkBase) sdkBase() *SdkBase {
165	return s
166}
167
168func (s *SdkBase) SdkMemberComponentName(baseName string, componentNameCreator func(string) string) string {
169	if s.MemberName() == "" {
170		return componentNameCreator(baseName)
171	} else {
172		index := strings.LastIndex(baseName, "@")
173		unversionedName := baseName[:index]
174		unversionedComponentName := componentNameCreator(unversionedName)
175		versionSuffix := baseName[index:]
176		return unversionedComponentName + versionSuffix
177	}
178}
179
180// MakeMemberOf sets this module to be a member of a specific SDK
181func (s *SdkBase) MakeMemberOf(sdk SdkRef) {
182	s.properties.ContainingSdk = &sdk
183}
184
185// IsInAnySdk returns true if this module is a member of any SDK
186func (s *SdkBase) IsInAnySdk() bool {
187	return s.properties.ContainingSdk != nil
188}
189
190// IsVersioned returns true if this module is versioned.
191func (s *SdkBase) IsVersioned() bool {
192	return strings.Contains(s.module.Name(), "@")
193}
194
195// ContainingSdk returns the SDK that this module is a member of
196func (s *SdkBase) ContainingSdk() SdkRef {
197	if s.properties.ContainingSdk != nil {
198		return *s.properties.ContainingSdk
199	}
200	return SdkRef{Name: "", Version: ""}
201}
202
203// MemberName returns the name of the module that this SDK member is overriding
204func (s *SdkBase) MemberName() string {
205	return proptools.String(s.properties.Sdk_member_name)
206}
207
208// BuildWithSdks is used to mark that this module has to be built with the given SDK(s).
209func (s *SdkBase) BuildWithSdks(sdks SdkRefs) {
210	s.properties.RequiredSdks = sdks
211}
212
213// RequiredSdks returns the SDK(s) that this module has to be built with
214func (s *SdkBase) RequiredSdks() SdkRefs {
215	return s.properties.RequiredSdks
216}
217
218// InitSdkAwareModule initializes the SdkBase struct. This must be called by all modules including
219// SdkBase.
220func InitSdkAwareModule(m SdkAware) {
221	base := m.sdkBase()
222	base.module = m
223	m.AddProperties(&base.properties)
224}
225
226// IsModuleInVersionedSdk returns true if the module is an versioned sdk.
227func IsModuleInVersionedSdk(module Module) bool {
228	if s, ok := module.(SdkAware); ok {
229		if !s.ContainingSdk().Unversioned() {
230			return true
231		}
232	}
233	return false
234}
235
236// Provide support for generating the build rules which will build the snapshot.
237type SnapshotBuilder interface {
238	// Copy src to the dest (which is a snapshot relative path) and add the dest
239	// to the zip
240	CopyToSnapshot(src Path, dest string)
241
242	// Unzip the supplied zip into the snapshot relative directory destDir.
243	UnzipToSnapshot(zipPath Path, destDir string)
244
245	// Add a new prebuilt module to the snapshot. The returned module
246	// must be populated with the module type specific properties. The following
247	// properties will be automatically populated.
248	//
249	// * name
250	// * sdk_member_name
251	// * prefer
252	//
253	// This will result in two Soong modules being generated in the Android. One
254	// that is versioned, coupled to the snapshot version and marked as
255	// prefer=true. And one that is not versioned, not marked as prefer=true and
256	// will only be used if the equivalently named non-prebuilt module is not
257	// present.
258	AddPrebuiltModule(member SdkMember, moduleType string) BpModule
259
260	// The property tag to use when adding a property to a BpModule that contains
261	// references to other sdk members. Using this will ensure that the reference
262	// is correctly output for both versioned and unversioned prebuilts in the
263	// snapshot.
264	//
265	// "required: true" means that the property must only contain references
266	// to other members of the sdk. Passing a reference to a module that is not a
267	// member of the sdk will result in a build error.
268	//
269	// "required: false" means that the property can contain references to modules
270	// that are either members or not members of the sdk. If a reference is to a
271	// module that is a non member then the reference is left unchanged, i.e. it
272	// is not transformed as references to members are.
273	//
274	// The handling of the member names is dependent on whether it is an internal or
275	// exported member. An exported member is one whose name is specified in one of
276	// the member type specific properties. An internal member is one that is added
277	// due to being a part of an exported (or other internal) member and is not itself
278	// an exported member.
279	//
280	// Member names are handled as follows:
281	// * When creating the unversioned form of the module the name is left unchecked
282	//   unless the member is internal in which case it is transformed into an sdk
283	//   specific name, i.e. by prefixing with the sdk name.
284	//
285	// * When creating the versioned form of the module the name is transformed into
286	//   a versioned sdk specific name, i.e. by prefixing with the sdk name and
287	//   suffixing with the version.
288	//
289	// e.g.
290	// bpPropertySet.AddPropertyWithTag("libs", []string{"member1", "member2"}, builder.SdkMemberReferencePropertyTag(true))
291	SdkMemberReferencePropertyTag(required bool) BpPropertyTag
292}
293
294type BpPropertyTag interface{}
295
296// A set of properties for use in a .bp file.
297type BpPropertySet interface {
298	// Add a property, the value can be one of the following types:
299	// * string
300	// * array of the above
301	// * bool
302	// For these types it is an error if multiple properties with the same name
303	// are added.
304	//
305	// * pointer to a struct
306	// * BpPropertySet
307	//
308	// A pointer to a Blueprint-style property struct is first converted into a
309	// BpPropertySet by traversing the fields and adding their values as
310	// properties in a BpPropertySet. A field with a struct value is itself
311	// converted into a BpPropertySet before adding.
312	//
313	// Adding a BpPropertySet is done as follows:
314	// * If no property with the name exists then the BpPropertySet is added
315	//   directly to this property. Care must be taken to ensure that it does not
316	//   introduce a cycle.
317	// * If a property exists with the name and the current value is a
318	//   BpPropertySet then every property of the new BpPropertySet is added to
319	//   the existing BpPropertySet.
320	// * Otherwise, if a property exists with the name then it is an error.
321	AddProperty(name string, value interface{})
322
323	// Add a property with an associated tag
324	AddPropertyWithTag(name string, value interface{}, tag BpPropertyTag)
325
326	// Add a property set with the specified name and return so that additional
327	// properties can be added.
328	AddPropertySet(name string) BpPropertySet
329
330	// Add comment for property (or property set).
331	AddCommentForProperty(name, text string)
332}
333
334// A .bp module definition.
335type BpModule interface {
336	BpPropertySet
337
338	// ModuleType returns the module type of the module
339	ModuleType() string
340
341	// Name returns the name of the module or "" if no name has been specified.
342	Name() string
343}
344
345// An individual member of the SDK, includes all of the variants that the SDK
346// requires.
347type SdkMember interface {
348	// The name of the member.
349	Name() string
350
351	// All the variants required by the SDK.
352	Variants() []SdkAware
353}
354
355// SdkMemberTypeDependencyTag is the interface that a tag must implement in order to allow the
356// dependent module to be automatically added to the sdk.
357type SdkMemberTypeDependencyTag interface {
358	blueprint.DependencyTag
359
360	// SdkMemberType returns the SdkMemberType that will be used to automatically add the child module
361	// to the sdk.
362	//
363	// Returning nil will prevent the module being added to the sdk.
364	SdkMemberType(child Module) SdkMemberType
365
366	// ExportMember determines whether a module added to the sdk through this tag will be exported
367	// from the sdk or not.
368	//
369	// An exported member is added to the sdk using its own name, e.g. if "foo" was exported from sdk
370	// "bar" then its prebuilt would be simply called "foo". A member can be added to the sdk via
371	// multiple tags and if any of those tags returns true from this method then the membe will be
372	// exported. Every module added directly to the sdk via one of the member type specific
373	// properties, e.g. java_libs, will automatically be exported.
374	//
375	// If a member is not exported then it is treated as an internal implementation detail of the
376	// sdk and so will be added with an sdk specific name. e.g. if "foo" was an internal member of sdk
377	// "bar" then its prebuilt would be called "bar_foo". Additionally its visibility will be set to
378	// "//visibility:private" so it will not be accessible from outside its Android.bp file.
379	ExportMember() bool
380}
381
382var _ SdkMemberTypeDependencyTag = (*sdkMemberDependencyTag)(nil)
383var _ ReplaceSourceWithPrebuilt = (*sdkMemberDependencyTag)(nil)
384
385type sdkMemberDependencyTag struct {
386	blueprint.BaseDependencyTag
387	memberType SdkMemberType
388	export     bool
389}
390
391func (t *sdkMemberDependencyTag) SdkMemberType(_ Module) SdkMemberType {
392	return t.memberType
393}
394
395func (t *sdkMemberDependencyTag) ExportMember() bool {
396	return t.export
397}
398
399// Prevent dependencies from the sdk/module_exports onto their members from being
400// replaced with a preferred prebuilt.
401func (t *sdkMemberDependencyTag) ReplaceSourceWithPrebuilt() bool {
402	return false
403}
404
405// DependencyTagForSdkMemberType creates an SdkMemberTypeDependencyTag that will cause any
406// dependencies added by the tag to be added to the sdk as the specified SdkMemberType and exported
407// (or not) as specified by the export parameter.
408func DependencyTagForSdkMemberType(memberType SdkMemberType, export bool) SdkMemberTypeDependencyTag {
409	return &sdkMemberDependencyTag{memberType: memberType, export: export}
410}
411
412// Interface that must be implemented for every type that can be a member of an
413// sdk.
414//
415// The basic implementation should look something like this, where ModuleType is
416// the name of the module type being supported.
417//
418//    type moduleTypeSdkMemberType struct {
419//        android.SdkMemberTypeBase
420//    }
421//
422//    func init() {
423//        android.RegisterSdkMemberType(&moduleTypeSdkMemberType{
424//            SdkMemberTypeBase: android.SdkMemberTypeBase{
425//                PropertyName: "module_types",
426//            },
427//        }
428//    }
429//
430//    ...methods...
431//
432type SdkMemberType interface {
433	// The name of the member type property on an sdk module.
434	SdkPropertyName() string
435
436	// RequiresBpProperty returns true if this member type requires its property to be usable within
437	// an Android.bp file.
438	RequiresBpProperty() bool
439
440	// True if the member type supports the sdk/sdk_snapshot, false otherwise.
441	UsableWithSdkAndSdkSnapshot() bool
442
443	// Return true if prebuilt host artifacts may be specific to the host OS. Only
444	// applicable to modules where HostSupported() is true. If this is true,
445	// snapshots will list each host OS variant explicitly and disable all other
446	// host OS'es.
447	IsHostOsDependent() bool
448
449	// Add dependencies from the SDK module to all the module variants the member
450	// type contributes to the SDK. `names` is the list of module names given in
451	// the member type property (as returned by SdkPropertyName()) in the SDK
452	// module. The exact set of variants required is determined by the SDK and its
453	// properties. The dependencies must be added with the supplied tag.
454	//
455	// The BottomUpMutatorContext provided is for the SDK module.
456	AddDependencies(mctx BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string)
457
458	// Return true if the supplied module is an instance of this member type.
459	//
460	// This is used to check the type of each variant before added to the
461	// SdkMember. Returning false will cause an error to be logged expaining that
462	// the module is not allowed in whichever sdk property it was added.
463	IsInstance(module Module) bool
464
465	// UsesSourceModuleTypeInSnapshot returns true when the AddPrebuiltModule() method returns a
466	// source module type.
467	UsesSourceModuleTypeInSnapshot() bool
468
469	// Add a prebuilt module that the sdk will populate.
470	//
471	// The sdk module code generates the snapshot as follows:
472	//
473	// * A properties struct of type SdkMemberProperties is created for each variant and
474	//   populated with information from the variant by calling PopulateFromVariant(SdkAware)
475	//   on the struct.
476	//
477	// * An additional properties struct is created into which the common properties will be
478	//   added.
479	//
480	// * The variant property structs are analysed to find exported (capitalized) fields which
481	//   have common values. Those fields are cleared and the common value added to the common
482	//   properties.
483	//
484	//   A field annotated with a tag of `sdk:"keep"` will be treated as if it
485	//   was not capitalized, i.e. not optimized for common values.
486	//
487	//   A field annotated with a tag of `android:"arch_variant"` will be allowed to have
488	//   values that differ by arch, fields not tagged as such must have common values across
489	//   all variants.
490	//
491	// * Additional field tags can be specified on a field that will ignore certain values
492	//   for the purpose of common value optimization. A value that is ignored must have the
493	//   default value for the property type. This is to ensure that significant value are not
494	//   ignored by accident. The purpose of this is to allow the snapshot generation to reflect
495	//   the behavior of the runtime. e.g. if a property is ignored on the host then a property
496	//   that is common for android can be treated as if it was common for android and host as
497	//   the setting for host is ignored anyway.
498	//   * `sdk:"ignored-on-host" - this indicates the property is ignored on the host variant.
499	//
500	// * The sdk module type populates the BpModule structure, creating the arch specific
501	//   structure and calls AddToPropertySet(...) on the properties struct to add the member
502	//   specific properties in the correct place in the structure.
503	//
504	AddPrebuiltModule(ctx SdkMemberContext, member SdkMember) BpModule
505
506	// Create a structure into which variant specific properties can be added.
507	CreateVariantPropertiesStruct() SdkMemberProperties
508}
509
510// Base type for SdkMemberType implementations.
511type SdkMemberTypeBase struct {
512	PropertyName string
513
514	// When set to true BpPropertyNotRequired indicates that the member type does not require the
515	// property to be specifiable in an Android.bp file.
516	BpPropertyNotRequired bool
517
518	SupportsSdk     bool
519	HostOsDependent bool
520
521	// When set to true UseSourceModuleTypeInSnapshot indicates that the member type creates a source
522	// module type in its SdkMemberType.AddPrebuiltModule() method. That prevents the sdk snapshot
523	// code from automatically adding a prefer: true flag.
524	UseSourceModuleTypeInSnapshot bool
525}
526
527func (b *SdkMemberTypeBase) SdkPropertyName() string {
528	return b.PropertyName
529}
530
531func (b *SdkMemberTypeBase) RequiresBpProperty() bool {
532	return !b.BpPropertyNotRequired
533}
534
535func (b *SdkMemberTypeBase) UsableWithSdkAndSdkSnapshot() bool {
536	return b.SupportsSdk
537}
538
539func (b *SdkMemberTypeBase) IsHostOsDependent() bool {
540	return b.HostOsDependent
541}
542
543func (b *SdkMemberTypeBase) UsesSourceModuleTypeInSnapshot() bool {
544	return b.UseSourceModuleTypeInSnapshot
545}
546
547// Encapsulates the information about registered SdkMemberTypes.
548type SdkMemberTypesRegistry struct {
549	// The list of types sorted by property name.
550	list []SdkMemberType
551
552	// The key that uniquely identifies this registry instance.
553	key OnceKey
554}
555
556func (r *SdkMemberTypesRegistry) copyAndAppend(memberType SdkMemberType) *SdkMemberTypesRegistry {
557	oldList := r.list
558
559	// Copy the slice just in case this is being read while being modified, e.g. when testing.
560	list := make([]SdkMemberType, 0, len(oldList)+1)
561	list = append(list, oldList...)
562	list = append(list, memberType)
563
564	// Sort the member types by their property name to ensure that registry order has no effect
565	// on behavior.
566	sort.Slice(list, func(i1, i2 int) bool {
567		t1 := list[i1]
568		t2 := list[i2]
569
570		return t1.SdkPropertyName() < t2.SdkPropertyName()
571	})
572
573	// Generate a key that identifies the slice of SdkMemberTypes by joining the property names
574	// from all the SdkMemberType .
575	var properties []string
576	for _, t := range list {
577		properties = append(properties, t.SdkPropertyName())
578	}
579	key := NewOnceKey(strings.Join(properties, "|"))
580
581	// Create a new registry so the pointer uniquely identifies the set of registered types.
582	return &SdkMemberTypesRegistry{
583		list: list,
584		key:  key,
585	}
586}
587
588func (r *SdkMemberTypesRegistry) RegisteredTypes() []SdkMemberType {
589	return r.list
590}
591
592func (r *SdkMemberTypesRegistry) UniqueOnceKey() OnceKey {
593	// Use the pointer to the registry as the unique key.
594	return NewCustomOnceKey(r)
595}
596
597// The set of registered SdkMemberTypes, one for sdk module and one for module_exports.
598var ModuleExportsMemberTypes = &SdkMemberTypesRegistry{}
599var SdkMemberTypes = &SdkMemberTypesRegistry{}
600
601// Register an SdkMemberType object to allow them to be used in the sdk and sdk_snapshot module
602// types.
603func RegisterSdkMemberType(memberType SdkMemberType) {
604	// All member types are usable with module_exports.
605	ModuleExportsMemberTypes = ModuleExportsMemberTypes.copyAndAppend(memberType)
606
607	// Only those that explicitly indicate it are usable with sdk.
608	if memberType.UsableWithSdkAndSdkSnapshot() {
609		SdkMemberTypes = SdkMemberTypes.copyAndAppend(memberType)
610	}
611}
612
613// Base structure for all implementations of SdkMemberProperties.
614//
615// Contains common properties that apply across many different member types.
616type SdkMemberPropertiesBase struct {
617	// The number of unique os types supported by the member variants.
618	//
619	// If a member has a variant with more than one os type then it will need to differentiate
620	// the locations of any of their prebuilt files in the snapshot by os type to prevent them
621	// from colliding. See OsPrefix().
622	//
623	// This property is the same for all variants of a member and so would be optimized away
624	// if it was not explicitly kept.
625	Os_count int `sdk:"keep"`
626
627	// The os type for which these properties refer.
628	//
629	// Provided to allow a member to differentiate between os types in the locations of their
630	// prebuilt files when it supports more than one os type.
631	//
632	// This property is the same for all os type specific variants of a member and so would be
633	// optimized away if it was not explicitly kept.
634	Os OsType `sdk:"keep"`
635
636	// The setting to use for the compile_multilib property.
637	Compile_multilib string `android:"arch_variant"`
638}
639
640// The os prefix to use for any file paths in the sdk.
641//
642// Is an empty string if the member only provides variants for a single os type, otherwise
643// is the OsType.Name.
644func (b *SdkMemberPropertiesBase) OsPrefix() string {
645	if b.Os_count == 1 {
646		return ""
647	} else {
648		return b.Os.Name
649	}
650}
651
652func (b *SdkMemberPropertiesBase) Base() *SdkMemberPropertiesBase {
653	return b
654}
655
656// Interface to be implemented on top of a structure that contains variant specific
657// information.
658//
659// Struct fields that are capitalized are examined for common values to extract. Fields
660// that are not capitalized are assumed to be arch specific.
661type SdkMemberProperties interface {
662	// Access the base structure.
663	Base() *SdkMemberPropertiesBase
664
665	// Populate this structure with information from the variant.
666	PopulateFromVariant(ctx SdkMemberContext, variant Module)
667
668	// Add the information from this structure to the property set.
669	AddToPropertySet(ctx SdkMemberContext, propertySet BpPropertySet)
670}
671
672// Provides access to information common to a specific member.
673type SdkMemberContext interface {
674
675	// The module context of the sdk common os variant which is creating the snapshot.
676	SdkModuleContext() ModuleContext
677
678	// The builder of the snapshot.
679	SnapshotBuilder() SnapshotBuilder
680
681	// The type of the member.
682	MemberType() SdkMemberType
683
684	// The name of the member.
685	//
686	// Provided for use by sdk members to create a member specific location within the snapshot
687	// into which to copy the prebuilt files.
688	Name() string
689}
690
691// ExportedComponentsInfo contains information about the components that this module exports to an
692// sdk snapshot.
693//
694// A component of a module is a child module that the module creates and which forms an integral
695// part of the functionality that the creating module provides. A component module is essentially
696// owned by its creator and is tightly coupled to the creator and other components.
697//
698// e.g. the child modules created by prebuilt_apis are not components because they are not tightly
699// coupled to the prebuilt_apis module. Once they are created the prebuilt_apis ignores them. The
700// child impl and stub library created by java_sdk_library (and corresponding import) are components
701// because the creating module depends upon them in order to provide some of its own functionality.
702//
703// A component is exported if it is part of an sdk snapshot. e.g. The xml and impl child modules are
704// components but they are not exported as they are not part of an sdk snapshot.
705//
706// This information is used by the sdk snapshot generation code to ensure that it does not create
707// an sdk snapshot that contains a declaration of the component module and the module that creates
708// it as that would result in duplicate modules when attempting to use the snapshot. e.g. a snapshot
709// that included the java_sdk_library_import "foo" and also a java_import "foo.stubs" would fail
710// as there would be two modules called "foo.stubs".
711type ExportedComponentsInfo struct {
712	// The names of the exported components.
713	Components []string
714}
715
716var ExportedComponentsInfoProvider = blueprint.NewProvider(ExportedComponentsInfo{})
717