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
ef15eac8
Commit
ef15eac8
authored
Jan 23, 2020
by
Jonah Williams
Committed by
Flutter GitHub Bot
Jan 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Remove context from Xcode and most of Xcodeproj (#48661)
parent
7cf2ff1f
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
576 additions
and
511 deletions
+576
-511
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+14
-2
mac.dart
packages/flutter_tools/lib/src/ios/mac.dart
+1
-1
xcodeproj.dart
packages/flutter_tools/lib/src/ios/xcodeproj.dart
+37
-16
build_macos.dart
packages/flutter_tools/lib/src/macos/build_macos.dart
+1
-1
xcode.dart
packages/flutter_tools/lib/src/macos/xcode.dart
+37
-15
xcodeproj_test.dart
.../flutter_tools/test/general.shard/ios/xcodeproj_test.dart
+337
-307
xcode_test.dart
...es/flutter_tools/test/general.shard/macos/xcode_test.dart
+149
-169
No files found.
packages/flutter_tools/lib/src/context_runner.dart
View file @
ef15eac8
...
...
@@ -145,8 +145,20 @@ Future<T> runInContext<T>(
VisualStudioValidator:
()
=>
const
VisualStudioValidator
(),
WebWorkflow:
()
=>
const
WebWorkflow
(),
WindowsWorkflow:
()
=>
const
WindowsWorkflow
(),
Xcode:
()
=>
Xcode
(),
XcodeProjectInterpreter:
()
=>
XcodeProjectInterpreter
(),
Xcode:
()
=>
Xcode
(
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
platform:
globals
.
platform
,
fileSystem:
globals
.
fs
,
xcodeProjectInterpreter:
xcodeProjectInterpreter
,
),
XcodeProjectInterpreter:
()
=>
XcodeProjectInterpreter
(
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
platform:
globals
.
platform
,
fileSystem:
globals
.
fs
,
terminal:
globals
.
terminal
,
),
XcodeValidator:
()
=>
const
XcodeValidator
(),
},
);
...
...
packages/flutter_tools/lib/src/ios/mac.dart
View file @
ef15eac8
...
...
@@ -458,7 +458,7 @@ Future<XcodeBuildResult> buildXcodeProject({
// e.g. `flutter build bundle`.
buildCommands
.
add
(
'FLUTTER_SUPPRESS_ANALYTICS=true'
);
buildCommands
.
add
(
'COMPILER_INDEX_STORE_ENABLE=NO'
);
buildCommands
.
addAll
(
environmentVariablesAsXcodeBuildSettings
());
buildCommands
.
addAll
(
environmentVariablesAsXcodeBuildSettings
(
globals
.
platform
));
final
Stopwatch
sw
=
Stopwatch
()..
start
();
initialBuildStatus
=
globals
.
logger
.
startProgress
(
'Running Xcode build...'
,
timeout:
timeoutConfiguration
.
fastOperation
);
...
...
packages/flutter_tools/lib/src/ios/xcodeproj.dart
View file @
ef15eac8
...
...
@@ -5,6 +5,8 @@
import
'dart:async'
;
import
'package:meta/meta.dart'
;
import
'package:platform/platform.dart'
;
import
'package:process/process.dart'
;
import
'../artifacts.dart'
;
import
'../base/common.dart'
;
...
...
@@ -14,6 +16,7 @@ import '../base/io.dart';
import
'../base/logger.dart'
;
import
'../base/os.dart'
;
import
'../base/process.dart'
;
import
'../base/terminal.dart'
;
import
'../base/utils.dart'
;
import
'../build_info.dart'
;
import
'../cache.dart'
;
...
...
@@ -221,15 +224,33 @@ XcodeProjectInterpreter get xcodeProjectInterpreter => context.get<XcodeProjectI
/// Interpreter of Xcode projects.
class
XcodeProjectInterpreter
{
XcodeProjectInterpreter
({
@required
Platform
platform
,
@required
ProcessManager
processManager
,
@required
Logger
logger
,
@required
FileSystem
fileSystem
,
@required
AnsiTerminal
terminal
,
})
:
_platform
=
platform
,
_fileSystem
=
fileSystem
,
_terminal
=
terminal
,
_logger
=
logger
,
_processUtils
=
ProcessUtils
(
logger:
logger
,
processManager:
processManager
);
final
Platform
_platform
;
final
FileSystem
_fileSystem
;
final
ProcessUtils
_processUtils
;
final
AnsiTerminal
_terminal
;
final
Logger
_logger
;
static
const
String
_executable
=
'/usr/bin/xcodebuild'
;
static
final
RegExp
_versionRegex
=
RegExp
(
r'Xcode ([0-9.]+)'
);
void
_updateVersion
()
{
if
(!
globals
.
platform
.
isMacOS
||
!
globals
.
fs
.
file
(
_executable
).
existsSync
())
{
if
(!
_platform
.
isMacOS
||
!
_fileSystem
.
file
(
_executable
).
existsSync
())
{
return
;
}
try
{
final
RunResult
result
=
processUtils
.
runSync
(
final
RunResult
result
=
_
processUtils
.
runSync
(
<
String
>[
_executable
,
'-version'
],
);
if
(
result
.
exitCode
!=
0
)
{
...
...
@@ -283,26 +304,26 @@ class XcodeProjectInterpreter {
Duration
timeout
=
const
Duration
(
minutes:
1
),
})
async
{
final
Status
status
=
Status
.
withSpinner
(
timeout:
timeoutConfiguration
.
fastOperation
,
timeoutConfiguration:
timeoutConfiguration
,
platform:
globals
.
platform
,
timeout:
const
TimeoutConfiguration
()
.
fastOperation
,
timeoutConfiguration:
const
TimeoutConfiguration
()
,
platform:
_
platform
,
stopwatch:
Stopwatch
(),
supportsColor:
globals
.
terminal
.
supportsColor
,
supportsColor:
_
terminal
.
supportsColor
,
);
final
List
<
String
>
showBuildSettingsCommand
=
<
String
>[
_executable
,
'-project'
,
globals
.
fs
.
path
.
absolute
(
projectPath
),
_fileSystem
.
path
.
absolute
(
projectPath
),
'-target'
,
target
,
'-showBuildSettings'
,
...
environmentVariablesAsXcodeBuildSettings
()
...
environmentVariablesAsXcodeBuildSettings
(
_platform
)
];
try
{
// showBuildSettings is reported to occasionally timeout. Here, we give it
// a lot of wiggle room (locally on Flutter Gallery, this takes ~1s).
// When there is a timeout, we retry once.
final
RunResult
result
=
await
processUtils
.
run
(
final
RunResult
result
=
await
_
processUtils
.
run
(
showBuildSettingsCommand
,
throwOnError:
true
,
workingDirectory:
projectPath
,
...
...
@@ -317,7 +338,7 @@ class XcodeProjectInterpreter {
command:
showBuildSettingsCommand
.
join
(
' '
),
).
send
();
}
globals
.
printTrace
(
'Unexpected failure to get the build settings:
$error
.'
);
_logger
.
printTrace
(
'Unexpected failure to get the build settings:
$error
.'
);
return
const
<
String
,
String
>{};
}
finally
{
status
.
stop
();
...
...
@@ -325,7 +346,7 @@ class XcodeProjectInterpreter {
}
void
cleanWorkspace
(
String
workspacePath
,
String
scheme
)
{
processUtils
.
runSync
(<
String
>[
_
processUtils
.
runSync
(<
String
>[
_executable
,
'-workspace'
,
workspacePath
,
...
...
@@ -333,8 +354,8 @@ class XcodeProjectInterpreter {
scheme
,
'-quiet'
,
'clean'
,
...
environmentVariablesAsXcodeBuildSettings
()
],
workingDirectory:
globals
.
fs
.
currentDirectory
.
path
);
...
environmentVariablesAsXcodeBuildSettings
(
_platform
)
],
workingDirectory:
_fileSystem
.
currentDirectory
.
path
);
}
Future
<
XcodeProjectInfo
>
getInfo
(
String
projectPath
,
{
String
projectFilename
})
async
{
...
...
@@ -342,7 +363,7 @@ class XcodeProjectInterpreter {
// * -project is passed and the given project isn't there, or
// * no -project is passed and there isn't a project.
const
int
missingProjectExitCode
=
66
;
final
RunResult
result
=
await
processUtils
.
run
(
final
RunResult
result
=
await
_
processUtils
.
run
(
<
String
>[
_executable
,
'-list'
,
...
...
@@ -363,9 +384,9 @@ class XcodeProjectInterpreter {
/// This allows developers to pass arbitrary build settings in without the tool needing to make a flag
/// for or be aware of each one. This could be used to set code signing build settings in a CI
/// environment without requiring settings changes in the Xcode project.
List
<
String
>
environmentVariablesAsXcodeBuildSettings
()
{
List
<
String
>
environmentVariablesAsXcodeBuildSettings
(
Platform
platform
)
{
const
String
xcodeBuildSettingPrefix
=
'FLUTTER_XCODE_'
;
return
globals
.
platform
.
environment
.
entries
.
where
((
MapEntry
<
String
,
String
>
mapEntry
)
{
return
platform
.
environment
.
entries
.
where
((
MapEntry
<
String
,
String
>
mapEntry
)
{
return
mapEntry
.
key
.
startsWith
(
xcodeBuildSettingPrefix
);
}).
expand
<
String
>((
MapEntry
<
String
,
String
>
mapEntry
)
{
// Remove FLUTTER_XCODE_ prefix from the environment variable to get the build setting.
...
...
packages/flutter_tools/lib/src/macos/build_macos.dart
View file @
ef15eac8
...
...
@@ -85,7 +85,7 @@ Future<void> buildMacOS({
'OBJROOT=
${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}
'
,
'SYMROOT=
${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}
'
,
'COMPILER_INDEX_STORE_ENABLE=NO'
,
...
environmentVariablesAsXcodeBuildSettings
()
...
environmentVariablesAsXcodeBuildSettings
(
globals
.
platform
)
],
trace:
true
);
}
finally
{
status
.
cancel
();
...
...
packages/flutter_tools/lib/src/macos/xcode.dart
View file @
ef15eac8
...
...
@@ -4,11 +4,16 @@
import
'dart:async'
;
import
'package:meta/meta.dart'
;
import
'package:platform/platform.dart'
;
import
'package:process/process.dart'
;
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
import
'../base/process.dart'
;
import
'../globals.dart'
as
globals
;
import
'../ios/xcodeproj.dart'
;
const
int
kXcodeRequiredVersionMajor
=
10
;
...
...
@@ -41,14 +46,31 @@ String getNameForSdk(SdkType sdk) {
return
null
;
}
/// A utility class for interacting with Xcode command line tools.
class
Xcode
{
bool
get
isInstalledAndMeetsVersionCheck
=>
globals
.
platform
.
isMacOS
&&
isInstalled
&&
isVersionSatisfactory
;
Xcode
({
@required
Platform
platform
,
@required
ProcessManager
processManager
,
@required
Logger
logger
,
@required
FileSystem
fileSystem
,
@required
XcodeProjectInterpreter
xcodeProjectInterpreter
,
})
:
_platform
=
platform
,
_fileSystem
=
fileSystem
,
_xcodeProjectInterpreter
=
xcodeProjectInterpreter
,
_processUtils
=
ProcessUtils
(
logger:
logger
,
processManager:
processManager
);
final
Platform
_platform
;
final
ProcessUtils
_processUtils
;
final
FileSystem
_fileSystem
;
final
XcodeProjectInterpreter
_xcodeProjectInterpreter
;
bool
get
isInstalledAndMeetsVersionCheck
=>
_platform
.
isMacOS
&&
isInstalled
&&
isVersionSatisfactory
;
String
_xcodeSelectPath
;
String
get
xcodeSelectPath
{
if
(
_xcodeSelectPath
==
null
)
{
try
{
_xcodeSelectPath
=
processUtils
.
runSync
(
_xcodeSelectPath
=
_
processUtils
.
runSync
(
<
String
>[
'/usr/bin/xcode-select'
,
'--print-path'
],
).
stdout
.
trim
();
}
on
ProcessException
{
...
...
@@ -64,21 +86,21 @@ class Xcode {
if
(
xcodeSelectPath
==
null
||
xcodeSelectPath
.
isEmpty
)
{
return
false
;
}
return
xcodeProjectInterpreter
.
isInstalled
;
return
_
xcodeProjectInterpreter
.
isInstalled
;
}
int
get
majorVersion
=>
xcodeProjectInterpreter
.
majorVersion
;
int
get
majorVersion
=>
_
xcodeProjectInterpreter
.
majorVersion
;
int
get
minorVersion
=>
xcodeProjectInterpreter
.
minorVersion
;
int
get
minorVersion
=>
_
xcodeProjectInterpreter
.
minorVersion
;
String
get
versionText
=>
xcodeProjectInterpreter
.
versionText
;
String
get
versionText
=>
_
xcodeProjectInterpreter
.
versionText
;
bool
_eulaSigned
;
/// Has the EULA been signed?
bool
get
eulaSigned
{
if
(
_eulaSigned
==
null
)
{
try
{
final
RunResult
result
=
processUtils
.
runSync
(
final
RunResult
result
=
_
processUtils
.
runSync
(
<
String
>[
'/usr/bin/xcrun'
,
'clang'
],
);
if
(
result
.
stdout
!=
null
&&
result
.
stdout
.
contains
(
'license'
))
{
...
...
@@ -103,7 +125,7 @@ class Xcode {
try
{
// This command will error if additional components need to be installed in
// xcode 9.2 and above.
final
RunResult
result
=
processUtils
.
runSync
(
final
RunResult
result
=
_
processUtils
.
runSync
(
<
String
>[
'/usr/bin/xcrun'
,
'simctl'
,
'list'
],
);
_isSimctlInstalled
=
result
.
stderr
==
null
||
result
.
stderr
==
''
;
...
...
@@ -115,7 +137,7 @@ class Xcode {
}
bool
get
isVersionSatisfactory
{
if
(!
xcodeProjectInterpreter
.
isInstalled
)
{
if
(!
_
xcodeProjectInterpreter
.
isInstalled
)
{
return
false
;
}
if
(
majorVersion
>
kXcodeRequiredVersionMajor
)
{
...
...
@@ -128,14 +150,14 @@ class Xcode {
}
Future
<
RunResult
>
cc
(
List
<
String
>
args
)
{
return
processUtils
.
run
(
return
_
processUtils
.
run
(
<
String
>[
'xcrun'
,
'cc'
,
...
args
],
throwOnError:
true
,
);
}
Future
<
RunResult
>
clang
(
List
<
String
>
args
)
{
return
processUtils
.
run
(
return
_
processUtils
.
run
(
<
String
>[
'xcrun'
,
'clang'
,
...
args
],
throwOnError:
true
,
);
...
...
@@ -143,7 +165,7 @@ class Xcode {
Future
<
String
>
sdkLocation
(
SdkType
sdk
)
async
{
assert
(
sdk
!=
null
);
final
RunResult
runResult
=
await
processUtils
.
run
(
final
RunResult
runResult
=
await
_
processUtils
.
run
(
<
String
>[
'xcrun'
,
'--sdk'
,
getNameForSdk
(
sdk
),
'--show-sdk-path'
],
throwOnError:
true
,
);
...
...
@@ -158,10 +180,10 @@ class Xcode {
return
null
;
}
final
List
<
String
>
searchPaths
=
<
String
>[
globals
.
fs
.
path
.
join
(
xcodeSelectPath
,
'Applications'
,
'Simulator.app'
),
_fileSystem
.
path
.
join
(
xcodeSelectPath
,
'Applications'
,
'Simulator.app'
),
];
return
searchPaths
.
where
((
String
p
)
=>
p
!=
null
).
firstWhere
(
(
String
p
)
=>
globals
.
fs
.
directory
(
p
).
existsSync
(),
(
String
p
)
=>
_fileSystem
.
directory
(
p
).
existsSync
(),
orElse:
()
=>
null
,
);
}
...
...
packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart
View file @
ef15eac8
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/macos/xcode_test.dart
View file @
ef15eac8
This diff is collapsed.
Click to expand it.
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