5
5
import '../config.dart' ;
6
6
import '../encoded_asset.dart' ;
7
7
import 'architecture.dart' ;
8
+ import 'config.dart' ;
8
9
import 'link_mode.dart' ;
9
10
import 'os.dart' ;
10
11
import 'syntax.g.dart' as syntax;
@@ -34,31 +35,30 @@ import 'syntax.g.dart' as syntax;
34
35
/// * Assets which designate symbols present in the target system
35
36
/// ([DynamicLoadingSystem] ), process ([LookupInProcess] ), or executable
36
37
/// ([LookupInExecutable] ). These assets do not have a [file] .
37
- /// * Dynamic libraries bundled into the application
38
- /// ([DynamicLoadingBundled] ). These assets must provide a [file] to be
39
- /// bundled.
38
+ /// * Dynamic libraries bundled into the application ([DynamicLoadingBundled] ).
39
+ /// These assets must provide a [file] to be bundled.
40
40
///
41
- /// An application is compiled to run on a specific target [os] and
42
- /// [architecture] . Different targets require different assets, so the package
43
- /// developer must specify which asset to bundle for which target.
41
+ /// An application is compiled to run on a specific target [CodeConfig.targetOS]
42
+ /// and [CodeConfig.targetArchitecture] . Different targets require different
43
+ /// assets, so the package developer must specify which asset to bundle for
44
+ /// which target.
44
45
///
45
46
/// An asset has different ways of being accessible in the final application. It
46
47
/// is either brought in "manually" by having the package developer specify a
47
48
/// [file] path of the asset on the current system, it can be part of the Dart
48
49
/// or Flutter SDK ([LookupInProcess] ), or it can be already present in the
49
- /// target system ([DynamicLoadingSystem] ). If the asset is bundled
50
- /// "manually", the Dart or Flutter SDK will take care of copying the asset
51
- /// [file] from its specified location on the current system into the
52
- /// application bundle.
50
+ /// target system ([DynamicLoadingSystem] ). If the asset is bundled "manually",
51
+ /// the Dart or Flutter SDK will take care of copying the asset [file] from its
52
+ /// specified location on the current system into the application bundle.
53
53
final class CodeAsset {
54
54
/// The id of this code asset.
55
55
final String id;
56
56
57
57
/// The operating system this asset can run on.
58
- final OS os ;
58
+ final OS _os ;
59
59
60
60
/// The architecture this asset can run on.
61
- final Architecture architecture ;
61
+ final Architecture _architecture ;
62
62
63
63
/// The link mode for this native code.
64
64
///
@@ -99,10 +99,11 @@ final class CodeAsset {
99
99
CodeAsset ._({
100
100
required this .id,
101
101
required this .linkMode,
102
- required this . os,
102
+ required OS os,
103
103
required this .file,
104
- required this .architecture,
105
- });
104
+ required Architecture architecture,
105
+ }) : _architecture = architecture,
106
+ _os = os;
106
107
107
108
factory CodeAsset .fromEncoded (EncodedAsset asset) {
108
109
assert (asset.type == CodeAsset .type);
@@ -128,8 +129,8 @@ final class CodeAsset {
128
129
}) => CodeAsset ._(
129
130
id: id ?? this .id,
130
131
linkMode: linkMode ?? this .linkMode,
131
- os: os ?? this .os ,
132
- architecture: architecture ?? this .architecture ,
132
+ os: os ?? _os ,
133
+ architecture: architecture ?? _architecture ,
133
134
file: file ?? this .file,
134
135
);
135
136
@@ -140,28 +141,36 @@ final class CodeAsset {
140
141
}
141
142
return other.id == id &&
142
143
other.linkMode == linkMode &&
143
- other.architecture == architecture &&
144
- other.os == os &&
144
+ other._architecture == _architecture &&
145
+ other._os == _os &&
145
146
other.file == file;
146
147
}
147
148
148
149
@override
149
- int get hashCode => Object .hash (id, linkMode, architecture, os , file);
150
+ int get hashCode => Object .hash (id, linkMode, _architecture, _os , file);
150
151
151
152
EncodedAsset encode () {
152
153
final encoding = syntax.NativeCodeAssetEncoding (
153
- architecture: architecture .toSyntax (),
154
+ architecture: _architecture .toSyntax (),
154
155
file: file,
155
156
id: id,
156
157
linkMode: linkMode.toSyntax (),
157
- os: os.toSyntax (),
158
+
159
+ os: _os.toSyntax (),
158
160
);
159
161
return EncodedAsset (CodeAsset .type, encoding.json);
160
162
}
161
163
162
164
static const String type = 'native_code' ;
163
165
}
164
166
167
+ // These field will be removed in the future, prevent anyone from reading them.
168
+ extension ForValidationOnly on CodeAsset {
169
+ OS get os => _os;
170
+
171
+ Architecture get architecture => _architecture;
172
+ }
173
+
165
174
extension OSLibraryNaming on OS {
166
175
/// The default dynamic library file name on this os.
167
176
String dylibFileName (String name) {
0 commit comments