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
3a479e7e
Unverified
Commit
3a479e7e
authored
Nov 23, 2020
by
Jenn Magder
Committed by
GitHub
Nov 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename SdkType -> EnvironmentType (#71095)
parent
2b4a2358
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
59 deletions
+49
-59
build_info.dart
packages/flutter_tools/lib/src/build_info.dart
+17
-16
build_ios_framework.dart
...s/flutter_tools/lib/src/commands/build_ios_framework.dart
+10
-8
xcode.dart
packages/flutter_tools/lib/src/macos/xcode.dart
+18
-20
xcode_test.dart
...es/flutter_tools/test/general.shard/macos/xcode_test.dart
+4
-15
No files found.
packages/flutter_tools/lib/src/build_info.dart
View file @
3a479e7e
...
@@ -12,7 +12,6 @@ import 'base/logger.dart';
...
@@ -12,7 +12,6 @@ import 'base/logger.dart';
import
'base/utils.dart'
;
import
'base/utils.dart'
;
import
'build_system/targets/icon_tree_shaker.dart'
;
import
'build_system/targets/icon_tree_shaker.dart'
;
import
'globals.dart'
as
globals
;
import
'globals.dart'
as
globals
;
import
'macos/xcode.dart'
;
/// Information about a build to be performed or used.
/// Information about a build to be performed or used.
class
BuildInfo
{
class
BuildInfo
{
...
@@ -320,6 +319,12 @@ BuildMode getBuildModeForName(String name) {
...
@@ -320,6 +319,12 @@ BuildMode getBuildModeForName(String name) {
return
BuildMode
.
fromName
(
name
);
return
BuildMode
.
fromName
(
name
);
}
}
/// Environment type of the target device.
enum
EnvironmentType
{
physical
,
simulator
,
}
String
validatedBuildNumberForPlatform
(
TargetPlatform
targetPlatform
,
String
buildNumber
,
Logger
logger
)
{
String
validatedBuildNumberForPlatform
(
TargetPlatform
targetPlatform
,
String
buildNumber
,
Logger
logger
)
{
if
(
buildNumber
==
null
)
{
if
(
buildNumber
==
null
)
{
return
null
;
return
null
;
...
@@ -481,22 +486,18 @@ enum AndroidArch {
...
@@ -481,22 +486,18 @@ enum AndroidArch {
}
}
/// The default set of iOS device architectures to build for.
/// The default set of iOS device architectures to build for.
List
<
DarwinArch
>
defaultIOSArchsForSdk
(
SdkType
sdkType
)
{
List
<
DarwinArch
>
defaultIOSArchsForEnvironment
(
switch
(
sdkType
)
{
EnvironmentType
environmentType
)
{
case
SdkType
.
iPhone
:
if
(
environmentType
==
EnvironmentType
.
simulator
)
{
return
<
DarwinArch
>[
DarwinArch
.
armv7
,
DarwinArch
.
arm64
,
];
case
SdkType
.
iPhoneSimulator
:
return
<
DarwinArch
>[
return
<
DarwinArch
>[
// Apple Silicon ARM simulators not yet supported.
// Apple Silicon ARM simulators not yet supported.
DarwinArch
.
x86_64
,
DarwinArch
.
x86_64
,
];
];
default
:
assert
(
false
,
'Unknown SDK type
$sdkType
'
);
return
null
;
}
}
return
<
DarwinArch
>[
DarwinArch
.
armv7
,
DarwinArch
.
arm64
,
];
}
}
String
getNameForDarwinArch
(
DarwinArch
arch
)
{
String
getNameForDarwinArch
(
DarwinArch
arch
)
{
...
...
packages/flutter_tools/lib/src/commands/build_ios_framework.dart
View file @
3a479e7e
...
@@ -21,7 +21,6 @@ import '../cache.dart';
...
@@ -21,7 +21,6 @@ import '../cache.dart';
import
'../convert.dart'
;
import
'../convert.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
import
'../macos/cocoapod_utils.dart'
;
import
'../macos/cocoapod_utils.dart'
;
import
'../macos/xcode.dart'
;
import
'../plugins.dart'
;
import
'../plugins.dart'
;
import
'../project.dart'
;
import
'../project.dart'
;
import
'../runner/flutter_command.dart'
show
DevelopmentArtifact
,
FlutterCommandResult
;
import
'../runner/flutter_command.dart'
show
DevelopmentArtifact
,
FlutterCommandResult
;
...
@@ -375,11 +374,13 @@ end
...
@@ -375,11 +374,13 @@ end
final Status status = globals.logger.startProgress(
final Status status = globals.logger.startProgress(
'
├─
Building
App
.
framework
...
',
'
├─
Building
App
.
framework
...
',
);
);
final List<SdkType> sdkTypes = <SdkType>[SdkType.iPhone];
final List<EnvironmentType> environmentTypes = <EnvironmentType>[
EnvironmentType.physical,
];
final List<Directory> frameworks = <Directory>[];
final List<Directory> frameworks = <Directory>[];
Target target;
Target target;
if (buildInfo.isDebug) {
if (buildInfo.isDebug) {
sdkTypes.add(SdkType.iPhoneS
imulator);
environmentTypes.add(EnvironmentType.s
imulator);
target = const DebugIosApplicationBundle();
target = const DebugIosApplicationBundle();
} else if (buildInfo.isProfile) {
} else if (buildInfo.isProfile) {
target = const ProfileIosApplicationBundle();
target = const ProfileIosApplicationBundle();
...
@@ -388,8 +389,9 @@ end
...
@@ -388,8 +389,9 @@ end
}
}
try {
try {
for (final SdkType sdkType in sdkTypes) {
for (final EnvironmentType sdkType in environmentTypes) {
final Directory outputBuildDirectory = sdkType == SdkType.iPhone
final Directory outputBuildDirectory =
sdkType == EnvironmentType.physical
? iPhoneBuildOutput
? iPhoneBuildOutput
: simulatorBuildOutput;
: simulatorBuildOutput;
frameworks.add(outputBuildDirectory.childDirectory(appFrameworkName));
frameworks.add(outputBuildDirectory.childDirectory(appFrameworkName));
...
@@ -411,7 +413,7 @@ end
...
@@ -411,7 +413,7 @@ end
buildInfo.extraGenSnapshotOptions.join('
,
'),
buildInfo.extraGenSnapshotOptions.join('
,
'),
if (buildInfo?.extraFrontEndOptions?.isNotEmpty ?? false)
if (buildInfo?.extraFrontEndOptions?.isNotEmpty ?? false)
kExtraFrontEndOptions: buildInfo.extraFrontEndOptions.join('
,
'),
kExtraFrontEndOptions: buildInfo.extraFrontEndOptions.join('
,
'),
kIosArchs: defaultIOSArchsFor
Sdk
(sdkType)
kIosArchs: defaultIOSArchsFor
Environment
(sdkType)
.map(getNameForDarwinArch)
.map(getNameForDarwinArch)
.join('
'),
.join('
'),
kSdkRoot: await globals.xcode.sdkLocation(sdkType),
kSdkRoot: await globals.xcode.sdkLocation(sdkType),
...
...
packages/flutter_tools/lib/src/macos/xcode.dart
View file @
3a479e7e
...
@@ -29,29 +29,16 @@ const int kXcodeRequiredVersionMajor = 11;
...
@@ -29,29 +29,16 @@ const int kXcodeRequiredVersionMajor = 11;
const
int
kXcodeRequiredVersionMinor
=
0
;
const
int
kXcodeRequiredVersionMinor
=
0
;
const
int
kXcodeRequiredVersionPatch
=
0
;
const
int
kXcodeRequiredVersionPatch
=
0
;
enum
SdkType
{
iPhone
,
iPhoneSimulator
,
macOS
,
}
/// SDK name passed to `xcrun --sdk`. Corresponds to undocumented Xcode
/// SDK name passed to `xcrun --sdk`. Corresponds to undocumented Xcode
/// SUPPORTED_PLATFORMS values.
/// SUPPORTED_PLATFORMS values.
///
///
/// Usage: xcrun [options] <tool name> ... arguments ...
/// Usage: xcrun [options] <tool name> ... arguments ...
/// ...
/// ...
/// --sdk <sdk name> find the tool for the given SDK name.
/// --sdk <sdk name> find the tool for the given SDK name.
String
getNameForSdk
(
SdkType
sdk
)
{
String
getSDKNameForIOSEnvironmentType
(
EnvironmentType
environmentType
)
{
switch
(
sdk
)
{
return
(
environmentType
==
EnvironmentType
.
simulator
)
case
SdkType
.
iPhone
:
?
'iphonesimulator'
return
'iphoneos'
;
:
'iphoneos'
;
case
SdkType
.
iPhoneSimulator
:
return
'iphonesimulator'
;
case
SdkType
.
macOS
:
return
'macosx'
;
}
assert
(
false
);
return
null
;
}
}
/// A utility class for interacting with Xcode command line tools.
/// A utility class for interacting with Xcode command line tools.
...
@@ -178,10 +165,10 @@ class Xcode {
...
@@ -178,10 +165,10 @@ class Xcode {
);
);
}
}
Future
<
String
>
sdkLocation
(
SdkType
sdk
)
async
{
Future
<
String
>
sdkLocation
(
EnvironmentType
environmentType
)
async
{
assert
(
sdk
!=
null
);
assert
(
environmentType
!=
null
);
final
RunResult
runResult
=
await
_processUtils
.
run
(
final
RunResult
runResult
=
await
_processUtils
.
run
(
<
String
>[...
xcrunCommand
(),
'--sdk'
,
get
NameForSdk
(
sdk
),
'--show-sdk-path'
],
<
String
>[...
xcrunCommand
(),
'--sdk'
,
get
SDKNameForIOSEnvironmentType
(
environmentType
),
'--show-sdk-path'
],
);
);
if
(
runResult
.
exitCode
!=
0
)
{
if
(
runResult
.
exitCode
!=
0
)
{
throwToolExit
(
'Could not find SDK location:
${runResult.stderr}
'
);
throwToolExit
(
'Could not find SDK location:
${runResult.stderr}
'
);
...
@@ -203,6 +190,17 @@ class Xcode {
...
@@ -203,6 +190,17 @@ class Xcode {
}
}
}
}
EnvironmentType
environmentTypeFromSdkroot
(
Directory
sdkroot
)
{
assert
(
sdkroot
!=
null
);
// iPhoneSimulator.sdk or iPhoneOS.sdk
final
String
sdkName
=
sdkroot
.
basename
.
toLowerCase
();
if
(
sdkName
.
contains
(
'iphone'
))
{
return
sdkName
.
contains
(
'simulator'
)
?
EnvironmentType
.
simulator
:
EnvironmentType
.
physical
;
}
assert
(
false
);
return
null
;
}
enum
XCDeviceEvent
{
enum
XCDeviceEvent
{
attach
,
attach
,
detach
,
detach
,
...
...
packages/flutter_tools/test/general.shard/macos/xcode_test.dart
View file @
3a479e7e
...
@@ -300,9 +300,8 @@ void main() {
...
@@ -300,9 +300,8 @@ void main() {
});
});
testWithoutContext
(
'SDK name'
,
()
{
testWithoutContext
(
'SDK name'
,
()
{
expect
(
getNameForSdk
(
SdkType
.
iPhone
),
'iphoneos'
);
expect
(
getSDKNameForIOSEnvironmentType
(
EnvironmentType
.
physical
),
'iphoneos'
);
expect
(
getNameForSdk
(
SdkType
.
iPhoneSimulator
),
'iphonesimulator'
);
expect
(
getSDKNameForIOSEnvironmentType
(
EnvironmentType
.
simulator
),
'iphonesimulator'
);
expect
(
getNameForSdk
(
SdkType
.
macOS
),
'macosx'
);
});
});
group
(
'SDK location'
,
()
{
group
(
'SDK location'
,
()
{
...
@@ -314,17 +313,7 @@ void main() {
...
@@ -314,17 +313,7 @@ void main() {
stdout:
sdkroot
,
stdout:
sdkroot
,
));
));
expect
(
await
xcode
.
sdkLocation
(
SdkType
.
iPhone
),
sdkroot
);
expect
(
await
xcode
.
sdkLocation
(
EnvironmentType
.
physical
),
sdkroot
);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
});
testWithoutContext
(
'--show-sdk-path macosx'
,
()
async
{
fakeProcessManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'xcrun'
,
'--sdk'
,
'macosx'
,
'--show-sdk-path'
],
stdout:
sdkroot
,
));
expect
(
await
xcode
.
sdkLocation
(
SdkType
.
macOS
),
sdkroot
);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
});
});
...
@@ -335,7 +324,7 @@ void main() {
...
@@ -335,7 +324,7 @@ void main() {
stderr:
'xcrun: error:'
,
stderr:
'xcrun: error:'
,
));
));
expect
(()
async
=>
await
xcode
.
sdkLocation
(
SdkType
.
iPhone
),
expect
(()
async
=>
await
xcode
.
sdkLocation
(
EnvironmentType
.
physical
),
throwsToolExit
(
message:
'Could not find SDK location'
));
throwsToolExit
(
message:
'Could not find SDK location'
));
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
expect
(
fakeProcessManager
.
hasRemainingExpectations
,
isFalse
);
});
});
...
...
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