Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
1cdf0f44
Unverified
Commit
1cdf0f44
authored
Dec 17, 2019
by
Jenn Magder
Committed by
GitHub
Dec 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only set `flutter run` usage values for targeted device platforms (#46931)
parent
853c8c56
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
33 deletions
+56
-33
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+37
-11
cocoapod_utils.dart
packages/flutter_tools/lib/src/macos/cocoapod_utils.dart
+0
-1
cocoapods.dart
packages/flutter_tools/lib/src/macos/cocoapods.dart
+0
-1
project.dart
packages/flutter_tools/lib/src/project.dart
+0
-10
run_test.dart
.../flutter_tools/test/commands.shard/hermetic/run_test.dart
+18
-1
project_test.dart
packages/flutter_tools/test/general.shard/project_test.dart
+1
-9
No files found.
packages/flutter_tools/lib/src/commands/run.dart
View file @
1cdf0f44
...
...
@@ -228,30 +228,55 @@ class RunCommand extends RunCommandBase {
Future
<
Map
<
CustomDimensions
,
String
>>
get
usageValues
async
{
String
deviceType
,
deviceOsVersion
;
bool
isEmulator
;
bool
anyAndroidDevices
=
false
;
bool
anyIOSDevices
=
false
;
if
(
devices
==
null
||
devices
.
isEmpty
)
{
deviceType
=
'none'
;
deviceOsVersion
=
'none'
;
isEmulator
=
false
;
}
else
if
(
devices
.
length
==
1
)
{
deviceType
=
getNameForTargetPlatform
(
await
devices
[
0
].
targetPlatform
);
final
TargetPlatform
platform
=
await
devices
[
0
].
targetPlatform
;
anyAndroidDevices
=
platform
==
TargetPlatform
.
android
;
anyIOSDevices
=
platform
==
TargetPlatform
.
ios
;
deviceType
=
getNameForTargetPlatform
(
platform
);
deviceOsVersion
=
await
devices
[
0
].
sdkNameAndVersion
;
isEmulator
=
await
devices
[
0
].
isLocalEmulator
;
}
else
{
deviceType
=
'multiple'
;
deviceOsVersion
=
'multiple'
;
isEmulator
=
false
;
for
(
Device
device
in
devices
)
{
final
TargetPlatform
platform
=
await
device
.
targetPlatform
;
anyAndroidDevices
=
anyAndroidDevices
||
(
platform
==
TargetPlatform
.
android
);
anyIOSDevices
=
anyIOSDevices
||
(
platform
==
TargetPlatform
.
ios
);
if
(
anyAndroidDevices
&&
anyIOSDevices
)
{
break
;
}
}
}
final
String
modeName
=
getBuildInfo
().
modeName
;
final
AndroidProject
androidProject
=
FlutterProject
.
current
().
android
;
final
IosProject
iosProject
=
FlutterProject
.
current
().
ios
;
final
List
<
String
>
hostLanguage
=
<
String
>[
if
(
androidProject
!=
null
&&
androidProject
.
existsSync
())
if
(
androidProject
.
isKotlin
)
'kotlin'
else
'java'
,
if
(
iosProject
!=
null
&&
iosProject
.
exists
)
if
(
await
iosProject
.
isSwift
)
'swift'
else
'objc'
,
];
String
androidEmbeddingVersion
;
final
List
<
String
>
hostLanguage
=
<
String
>[];
if
(
anyAndroidDevices
)
{
final
AndroidProject
androidProject
=
FlutterProject
.
current
().
android
;
if
(
androidProject
!=
null
&&
androidProject
.
existsSync
())
{
hostLanguage
.
add
(
androidProject
.
isKotlin
?
'kotlin'
:
'java'
);
androidEmbeddingVersion
=
androidProject
.
getEmbeddingVersion
().
toString
().
split
(
'.'
).
last
;
}
}
if
(
anyIOSDevices
)
{
final
IosProject
iosProject
=
FlutterProject
.
current
().
ios
;
if
(
iosProject
!=
null
&&
iosProject
.
exists
)
{
final
Iterable
<
File
>
swiftFiles
=
iosProject
.
hostAppRoot
.
listSync
(
recursive:
true
,
followLinks:
false
)
.
whereType
<
File
>()
.
where
((
File
file
)
=>
fs
.
path
.
extension
(
file
.
path
)
==
'.swift'
);
hostLanguage
.
add
(
swiftFiles
.
isNotEmpty
?
'swift'
:
'objc'
);
}
}
final
String
modeName
=
getBuildInfo
().
modeName
;
return
<
CustomDimensions
,
String
>{
CustomDimensions
.
commandRunIsEmulator
:
'
$isEmulator
'
,
CustomDimensions
.
commandRunTargetName
:
deviceType
,
...
...
@@ -259,7 +284,8 @@ class RunCommand extends RunCommandBase {
CustomDimensions
.
commandRunModeName
:
modeName
,
CustomDimensions
.
commandRunProjectModule
:
'
${FlutterProject.current().isModule}
'
,
CustomDimensions
.
commandRunProjectHostLanguage
:
hostLanguage
.
join
(
','
),
CustomDimensions
.
commandRunAndroidEmbeddingVersion
:
androidProject
.
getEmbeddingVersion
().
toString
().
split
(
'.'
).
last
,
if
(
androidEmbeddingVersion
!=
null
)
CustomDimensions
.
commandRunAndroidEmbeddingVersion
:
androidEmbeddingVersion
,
};
}
...
...
packages/flutter_tools/lib/src/macos/cocoapod_utils.dart
View file @
1cdf0f44
...
...
@@ -36,7 +36,6 @@ Future<void> processPodsIfNeeded(XcodeBasedProject xcodeProject, String buildDir
final
bool
didPodInstall
=
await
cocoaPods
.
processPods
(
xcodeProject:
xcodeProject
,
engineDir:
flutterFrameworkDir
(
buildMode
),
isSwift:
await
xcodeProject
.
isSwift
,
dependenciesChanged:
!
fingerprinter
.
doesFingerprintMatch
(),
);
if
(
didPodInstall
)
{
...
...
packages/flutter_tools/lib/src/macos/cocoapods.dart
View file @
1cdf0f44
...
...
@@ -138,7 +138,6 @@ class CocoaPods {
@required
XcodeBasedProject
xcodeProject
,
// For backward compatibility with previously created Podfile only.
@required
String
engineDir
,
bool
isSwift
=
false
,
bool
dependenciesChanged
=
true
,
})
async
{
if
(!
xcodeProject
.
podfile
.
existsSync
())
{
...
...
packages/flutter_tools/lib/src/project.dart
View file @
1cdf0f44
...
...
@@ -292,9 +292,6 @@ abstract class XcodeBasedProject {
/// The CocoaPods 'Manifest.lock'.
File
get
podManifestLock
;
/// True if the host app project is using Swift.
Future
<
bool
>
get
isSwift
;
/// Directory containing symlinks to pub cache plugins source generated on `pod install`.
Directory
get
symlinks
;
}
...
...
@@ -410,10 +407,6 @@ class IosProject implements XcodeBasedProject {
return null;
}
@override
Future<bool> get isSwift async =>
(await buildSettings)?.containsKey('
SWIFT_VERSION
') ?? false;
/// The build settings for the host app of this project, as a detached map.
///
/// Returns null, if iOS tooling is unavailable.
...
...
@@ -820,9 +813,6 @@ class MacOSProject implements XcodeBasedProject {
@override
Directory
get
symlinks
=>
ephemeralDirectory
.
childDirectory
(
'.symlinks'
);
@override
Future
<
bool
>
get
isSwift
async
=>
true
;
/// The file where the Xcode build will write the name of the built app.
///
/// Ideally this will be replaced in the future with inspection of the Runner
...
...
packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
View file @
1cdf0f44
...
...
@@ -237,6 +237,7 @@ void main() {
when
(
mockDevice
.
isLocalEmulator
).
thenAnswer
((
Invocation
invocation
)
=>
Future
<
bool
>.
value
(
false
));
when
(
mockDevice
.
getLogReader
(
app:
anyNamed
(
'app'
))).
thenReturn
(
MockDeviceLogReader
());
when
(
mockDevice
.
supportsFastStart
).
thenReturn
(
true
);
when
(
mockDevice
.
sdkNameAndVersion
).
thenAnswer
((
Invocation
invocation
)
=>
Future
<
String
>.
value
(
'iOS 13'
));
// App fails to start because we're only interested in usage
when
(
mockDevice
.
startApp
(
any
,
...
...
@@ -262,6 +263,15 @@ void main() {
(
Invocation
invocation
)
=>
Future
<
List
<
Device
>>.
value
(<
Device
>[
mockDevice
])
);
final
Directory
tempDir
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_run_test.'
);
tempDir
.
childDirectory
(
'ios'
).
childFile
(
'AppDelegate.swift'
).
createSync
(
recursive:
true
);
tempDir
.
childFile
(
'.packages'
).
createSync
();
tempDir
.
childDirectory
(
'lib'
).
childFile
(
'main.dart'
).
createSync
(
recursive:
true
);
tempDir
.
childFile
(
'pubspec.yaml'
)
..
createSync
()
..
writeAsStringSync
(
'# Hello, World'
);
fs
.
currentDirectory
=
tempDir
;
try
{
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'run'
,
...
...
@@ -281,7 +291,14 @@ void main() {
)).
captured
;
expect
(
captures
[
0
],
'run'
);
final
Map
<
String
,
String
>
parameters
=
captures
[
1
]
as
Map
<
String
,
String
>;
expect
(
parameters
[
'cd4'
],
'ios'
);
expect
(
parameters
[
cdKey
(
CustomDimensions
.
commandRunIsEmulator
)],
'false'
);
expect
(
parameters
[
cdKey
(
CustomDimensions
.
commandRunTargetName
)],
'ios'
);
expect
(
parameters
[
cdKey
(
CustomDimensions
.
commandRunProjectHostLanguage
)],
'swift'
);
expect
(
parameters
[
cdKey
(
CustomDimensions
.
commandRunTargetOsVersion
)],
'iOS 13'
);
expect
(
parameters
[
cdKey
(
CustomDimensions
.
commandRunModeName
)],
'debug'
);
expect
(
parameters
[
cdKey
(
CustomDimensions
.
commandRunProjectModule
)],
'false'
);
expect
(
parameters
.
containsKey
(
cdKey
(
CustomDimensions
.
commandRunAndroidEmbeddingVersion
)),
false
);
},
overrides:
<
Type
,
Generator
>{
ApplicationPackageFactory:
()
=>
mockApplicationPackageFactory
,
Artifacts:
()
=>
mockArtifacts
,
...
...
packages/flutter_tools/test/general.shard/project_test.dart
View file @
1cdf0f44
...
...
@@ -304,19 +304,12 @@ void main() {
testInMemory
(
'default host app language'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
expect
(
await
project
.
ios
.
isSwift
,
isFalse
);
expect
(
project
.
android
.
isKotlin
,
isFalse
);
});
testUsingContext
(
'
swift and
kotlin host app language'
,
()
async
{
testUsingContext
(
'kotlin host app language'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
when
(
mockXcodeProjectInterpreter
.
getBuildSettings
(
any
,
any
)).
thenAnswer
(
(
_
)
{
return
Future
<
Map
<
String
,
String
>>.
value
(<
String
,
String
>{
'SWIFT_VERSION'
:
'5.0'
,
});
});
addAndroidGradleFile
(
project
.
directory
,
gradleFileContent:
()
{
return
'''
...
...
@@ -324,7 +317,6 @@ apply plugin: 'com.android.application'
apply plugin: '
kotlin
-
android
'
'''
;
});
expect
(
await
project
.
ios
.
isSwift
,
isTrue
);
expect
(
project
.
android
.
isKotlin
,
isTrue
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment