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
2d07436d
Unverified
Commit
2d07436d
authored
Jul 27, 2021
by
Christopher Fujino
Committed by
GitHub
Jul 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Port xcode backend to dart (#86753)
parent
93de096e
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
772 additions
and
263 deletions
+772
-263
xcode_backend.dart
packages/flutter_tools/bin/xcode_backend.dart
+466
-0
xcode_backend.sh
packages/flutter_tools/bin/xcode_backend.sh
+24
-263
xcode_backend_test.dart
.../flutter_tools/test/general.shard/xcode_backend_test.dart
+280
-0
forbidden_imports_test.dart
..._tools/test/integration.shard/forbidden_imports_test.dart
+2
-0
No files found.
packages/flutter_tools/bin/xcode_backend.dart
0 → 100644
View file @
2d07436d
This diff is collapsed.
Click to expand it.
packages/flutter_tools/bin/xcode_backend.sh
View file @
2d07436d
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/xcode_backend_test.dart
0 → 100644
View file @
2d07436d
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'../../bin/xcode_backend.dart'
;
import
'../src/common.dart'
;
import
'../src/fake_process_manager.dart'
;
void
main
(
)
{
late
MemoryFileSystem
fileSystem
;
setUp
(()
{
fileSystem
=
MemoryFileSystem
();
});
group
(
'build'
,
()
{
test
(
'exits with useful error message when build mode not set'
,
()
{
final
Directory
buildDir
=
fileSystem
.
directory
(
'/path/to/builds'
)
..
createSync
(
recursive:
true
);
final
Directory
flutterRoot
=
fileSystem
.
directory
(
'/path/to/flutter'
)
..
createSync
(
recursive:
true
);
final
File
pipe
=
fileSystem
.
file
(
'/tmp/pipe'
)
..
createSync
(
recursive:
true
);
const
String
buildMode
=
'Debug'
;
final
TestContext
context
=
TestContext
(
<
String
>[
'build'
],
<
String
,
String
>{
'BUILT_PRODUCTS_DIR'
:
buildDir
.
path
,
'ENABLE_BITCODE'
:
'YES'
,
'FLUTTER_ROOT'
:
flutterRoot
.
path
,
'INFOPLIST_PATH'
:
'Info.plist'
,
},
commands:
<
FakeCommand
>[
FakeCommand
(
command:
<
String
>[
'
${flutterRoot.path}
/bin/flutter'
,
'assemble'
,
'--no-version-check'
,
'--output=
${buildDir.path}
/'
,
'-dTargetPlatform=ios'
,
'-dTargetFile=lib/main.dart'
,
'-dBuildMode=
${buildMode.toLowerCase()}
'
,
'-dIosArchs='
,
'-dSdkRoot='
,
'-dSplitDebugInfo='
,
'-dTreeShakeIcons='
,
'-dTrackWidgetCreation='
,
'-dDartObfuscation='
,
'-dEnableBitcode='
,
'--ExtraGenSnapshotOptions='
,
'--DartDefines='
,
'--ExtraFrontEndOptions='
,
'debug_ios_bundle_flutter_assets'
,
],
),
],
fileSystem:
fileSystem
,
scriptOutputStreamFile:
pipe
,
);
expect
(
()
=>
context
.
run
(),
throwsException
,
);
expect
(
context
.
stderr
,
contains
(
'ERROR: Unknown FLUTTER_BUILD_MODE: null.
\n
'
),
);
});
test
(
'calls flutter assemble'
,
()
{
final
Directory
buildDir
=
fileSystem
.
directory
(
'/path/to/builds'
)
..
createSync
(
recursive:
true
);
final
Directory
flutterRoot
=
fileSystem
.
directory
(
'/path/to/flutter'
)
..
createSync
(
recursive:
true
);
final
File
pipe
=
fileSystem
.
file
(
'/tmp/pipe'
)
..
createSync
(
recursive:
true
);
const
String
buildMode
=
'Debug'
;
final
TestContext
context
=
TestContext
(
<
String
>[
'build'
],
<
String
,
String
>{
'BUILT_PRODUCTS_DIR'
:
buildDir
.
path
,
'CONFIGURATION'
:
buildMode
,
'ENABLE_BITCODE'
:
'YES'
,
'FLUTTER_ROOT'
:
flutterRoot
.
path
,
'INFOPLIST_PATH'
:
'Info.plist'
,
},
commands:
<
FakeCommand
>[
FakeCommand
(
command:
<
String
>[
'
${flutterRoot.path}
/bin/flutter'
,
'assemble'
,
'--no-version-check'
,
'--output=
${buildDir.path}
/'
,
'-dTargetPlatform=ios'
,
'-dTargetFile=lib/main.dart'
,
'-dBuildMode=
${buildMode.toLowerCase()}
'
,
'-dIosArchs='
,
'-dSdkRoot='
,
'-dSplitDebugInfo='
,
'-dTreeShakeIcons='
,
'-dTrackWidgetCreation='
,
'-dDartObfuscation='
,
'-dEnableBitcode='
,
'--ExtraGenSnapshotOptions='
,
'--DartDefines='
,
'--ExtraFrontEndOptions='
,
'debug_ios_bundle_flutter_assets'
,
],
),
],
fileSystem:
fileSystem
,
scriptOutputStreamFile:
pipe
,
)..
run
();
final
List
<
String
>
streamedLines
=
pipe
.
readAsLinesSync
();
// Ensure after line splitting, the exact string 'done' appears
expect
(
streamedLines
,
contains
(
'done'
));
expect
(
streamedLines
,
contains
(
' └─Compiling, linking and signing...'
));
expect
(
context
.
stdout
,
contains
(
'built and packaged successfully.'
),
);
expect
(
context
.
stderr
,
isEmpty
);
});
test
(
'forwards all env variables to flutter assemble'
,
()
{
final
Directory
buildDir
=
fileSystem
.
directory
(
'/path/to/builds'
)
..
createSync
(
recursive:
true
);
final
Directory
flutterRoot
=
fileSystem
.
directory
(
'/path/to/flutter'
)
..
createSync
(
recursive:
true
);
const
String
archs
=
'arm64 armv7'
;
const
String
buildMode
=
'Release'
;
const
String
dartObfuscation
=
'false'
;
const
String
dartDefines
=
'flutter.inspector.structuredErrors%3Dtrue'
;
const
String
expandedCodeSignIdentity
=
'F1326572E0B71C3C8442805230CB4B33B708A2E2'
;
const
String
extraFrontEndOptions
=
'--some-option'
;
const
String
extraGenSnapshotOptions
=
'--obfuscate'
;
const
String
sdkRoot
=
'/path/to/sdk'
;
const
String
splitDebugInfo
=
'/path/to/split/debug/info'
;
const
String
trackWidgetCreation
=
'true'
;
const
String
treeShake
=
'true'
;
final
TestContext
context
=
TestContext
(
<
String
>[
'build'
],
<
String
,
String
>{
'ACTION'
:
'install'
,
'ARCHS'
:
archs
,
'BUILT_PRODUCTS_DIR'
:
buildDir
.
path
,
'CODE_SIGNING_REQUIRED'
:
'YES'
,
'CONFIGURATION'
:
buildMode
,
'DART_DEFINES'
:
dartDefines
,
'DART_OBFUSCATION'
:
dartObfuscation
,
'ENABLE_BITCODE'
:
'YES'
,
'EXPANDED_CODE_SIGN_IDENTITY'
:
expandedCodeSignIdentity
,
'EXTRA_FRONT_END_OPTIONS'
:
extraFrontEndOptions
,
'EXTRA_GEN_SNAPSHOT_OPTIONS'
:
extraGenSnapshotOptions
,
'FLUTTER_ROOT'
:
flutterRoot
.
path
,
'INFOPLIST_PATH'
:
'Info.plist'
,
'SDKROOT'
:
sdkRoot
,
'SPLIT_DEBUG_INFO'
:
splitDebugInfo
,
'TRACK_WIDGET_CREATION'
:
trackWidgetCreation
,
'TREE_SHAKE_ICONS'
:
treeShake
,
},
commands:
<
FakeCommand
>[
FakeCommand
(
command:
<
String
>[
'
${flutterRoot.path}
/bin/flutter'
,
'assemble'
,
'--no-version-check'
,
'--output=
${buildDir.path}
/'
,
'-dTargetPlatform=ios'
,
'-dTargetFile=lib/main.dart'
,
'-dBuildMode=
${buildMode.toLowerCase()}
'
,
'-dIosArchs=
$archs
'
,
'-dSdkRoot=
$sdkRoot
'
,
'-dSplitDebugInfo=
$splitDebugInfo
'
,
'-dTreeShakeIcons=
$treeShake
'
,
'-dTrackWidgetCreation=
$trackWidgetCreation
'
,
'-dDartObfuscation=
$dartObfuscation
'
,
'-dEnableBitcode=true'
,
'--ExtraGenSnapshotOptions=
$extraGenSnapshotOptions
'
,
'--DartDefines=
$dartDefines
'
,
'--ExtraFrontEndOptions=
$extraFrontEndOptions
'
,
'-dCodesignIdentity=
$expandedCodeSignIdentity
'
,
'release_ios_bundle_flutter_assets'
,
],
),
],
fileSystem:
fileSystem
,
)..
run
();
expect
(
context
.
stdout
,
contains
(
'built and packaged successfully.'
),
);
expect
(
context
.
stderr
,
isEmpty
);
});
});
group
(
'test_observatory_bonjour_service'
,
()
{
test
(
'handles when the Info.plist is missing'
,
()
{
final
Directory
buildDir
=
fileSystem
.
directory
(
'/path/to/builds'
);
buildDir
.
createSync
(
recursive:
true
);
final
TestContext
context
=
TestContext
(
<
String
>[
'test_observatory_bonjour_service'
],
<
String
,
String
>{
'CONFIGURATION'
:
'Debug'
,
'BUILT_PRODUCTS_DIR'
:
buildDir
.
path
,
'INFOPLIST_PATH'
:
'Info.plist'
,
},
commands:
<
FakeCommand
>[],
fileSystem:
fileSystem
,
)..
run
();
expect
(
context
.
stdout
,
contains
(
'Info.plist does not exist. Skipping _dartobservatory._tcp NSBonjourServices insertion.'
),
);
});
});
}
class
TestContext
extends
Context
{
TestContext
(
List
<
String
>
arguments
,
Map
<
String
,
String
>
environment
,
{
required
this
.
fileSystem
,
required
List
<
FakeCommand
>
commands
,
File
?
scriptOutputStreamFile
,
})
:
processManager
=
FakeProcessManager
.
list
(
commands
),
super
(
arguments:
arguments
,
environment:
environment
,
scriptOutputStreamFile:
scriptOutputStreamFile
);
final
FileSystem
fileSystem
;
final
FakeProcessManager
processManager
;
String
stdout
=
''
;
String
stderr
=
''
;
@override
bool
existsDir
(
String
path
)
{
return
fileSystem
.
directory
(
path
).
existsSync
();
}
@override
bool
existsFile
(
String
path
)
{
return
fileSystem
.
file
(
path
).
existsSync
();
}
@override
ProcessResult
runSync
(
String
bin
,
List
<
String
>
args
,
{
bool
verbose
=
false
,
bool
allowFail
=
false
,
String
?
workingDirectory
,
})
{
return
processManager
.
runSync
(
<
dynamic
>[
bin
,
...
args
],
workingDirectory:
workingDirectory
,
environment:
environment
,
);
}
@override
void
echoError
(
String
message
)
{
stderr
+=
'
$message
\n
'
;
}
@override
void
echo
(
String
message
)
{
stdout
+=
message
;
}
@override
Never
exitApp
(
int
code
)
{
// This is an exception for the benefit of unit tests.
// The real implementation calls `exit(code)`.
throw
Exception
(
'App exited with code
$code
'
);
}
}
packages/flutter_tools/test/integration.shard/forbidden_imports_test.dart
View file @
2d07436d
...
...
@@ -63,6 +63,8 @@ void main() {
test
(
'no unauthorized imports of dart:io'
,
()
{
final
List
<
String
>
allowedPaths
=
<
String
>[
// This is a standalone script invoked by xcode, not part of the tool
fileSystem
.
path
.
join
(
flutterTools
,
'bin'
,
'xcode_backend.dart'
),
fileSystem
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
,
'base'
,
'io.dart'
),
fileSystem
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
,
'base'
,
'platform.dart'
),
fileSystem
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
,
'base'
,
'error_handling_io.dart'
),
...
...
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