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
802301e1
Unverified
Commit
802301e1
authored
May 01, 2018
by
Chris Bracken
Committed by
GitHub
May 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract shared library build from AOT snapshotting (#17166)
parent
73334599
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
32 deletions
+65
-32
build.dart
packages/flutter_tools/lib/src/base/build.dart
+55
-32
build_test.dart
packages/flutter_tools/test/base/build_test.dart
+10
-0
No files found.
packages/flutter_tools/lib/src/base/build.dart
View file @
802301e1
...
@@ -336,38 +336,13 @@ class AOTSnapshotter {
...
@@ -336,38 +336,13 @@ class AOTSnapshotter {
// On iOS, we use Xcode to compile the snapshot into a dynamic library that the
// On iOS, we use Xcode to compile the snapshot into a dynamic library that the
// end-developer can link into their app.
// end-developer can link into their app.
if
(
platform
==
TargetPlatform
.
ios
)
{
if
(
platform
==
TargetPlatform
.
ios
)
{
printStatus
(
'Building App.framework...'
);
final
RunResult
result
=
await
_buildIosFramework
(
assemblyPath:
assembly
,
outputPath:
outputDir
.
path
);
const
List
<
String
>
commonBuildOptions
=
const
<
String
>[
'-arch'
,
'arm64'
,
'-miphoneos-version-min=8.0'
];
if
(
result
.
exitCode
!=
0
)
return
result
.
exitCode
;
final
String
assemblyO
=
fs
.
path
.
join
(
outputDir
.
path
,
'snapshot_assembly.o'
);
}
else
if
(
compileToSharedLibrary
)
{
await
xcode
.
cc
(
commonBuildOptions
.
toList
()..
addAll
(<
String
>[
'-c'
,
assembly
,
'-o'
,
assemblyO
]));
final
RunResult
result
=
await
_buildAndroidSharedLibrary
(
assemblyPath:
assembly
,
outputPath:
outputDir
.
path
);
if
(
result
.
exitCode
!=
0
)
final
String
frameworkDir
=
fs
.
path
.
join
(
outputDir
.
path
,
'App.framework'
);
return
result
.
exitCode
;
fs
.
directory
(
frameworkDir
).
createSync
(
recursive:
true
);
final
String
appLib
=
fs
.
path
.
join
(
frameworkDir
,
'App'
);
final
List
<
String
>
linkArgs
=
commonBuildOptions
.
toList
()..
addAll
(<
String
>[
'-dynamiclib'
,
'-Xlinker'
,
'-rpath'
,
'-Xlinker'
,
'@executable_path/Frameworks'
,
'-Xlinker'
,
'-rpath'
,
'-Xlinker'
,
'@loader_path/Frameworks'
,
'-install_name'
,
'@rpath/App.framework/App'
,
'-o'
,
appLib
,
assemblyO
,
]);
await
xcode
.
clang
(
linkArgs
);
}
else
{
if
(
compileToSharedLibrary
)
{
// A word of warning: Instead of compiling via two steps, to a .o file and
// then to a .so file we use only one command. When using two commands
// gcc will end up putting a .eh_frame and a .debug_frame into the shared
// library. Without stripping .debug_frame afterwards, unwinding tools
// based upon libunwind use just one and ignore the contents of the other
// (which causes it to not look into the other section and therefore not
// find the correct unwinding information).
final
String
assemblySo
=
fs
.
path
.
join
(
outputDir
.
path
,
'app.so'
);
await
runCheckedAsync
(<
String
>[
androidSdk
.
ndkCompiler
]
..
addAll
(
androidSdk
.
ndkCompilerArgs
)
..
addAll
(<
String
>[
'-shared'
,
'-nostdlib'
,
'-o'
,
assemblySo
,
assembly
]));
}
}
}
// Compute and record build fingerprint.
// Compute and record build fingerprint.
...
@@ -375,6 +350,54 @@ class AOTSnapshotter {
...
@@ -375,6 +350,54 @@ class AOTSnapshotter {
return
0
;
return
0
;
}
}
/// Builds an iOS framework at [outputPath]/App.framework from the assembly
/// source at [assemblyPath].
Future
<
RunResult
>
_buildIosFramework
({
@required
String
assemblyPath
,
@required
String
outputPath
,
})
async
{
printStatus
(
'Building App.framework...'
);
const
List
<
String
>
commonBuildOptions
=
const
<
String
>[
'-arch'
,
'arm64'
,
'-miphoneos-version-min=8.0'
];
final
String
assemblyO
=
fs
.
path
.
join
(
outputPath
,
'snapshot_assembly.o'
);
final
RunResult
compileResult
=
await
xcode
.
cc
(
commonBuildOptions
.
toList
()..
addAll
(<
String
>[
'-c'
,
assemblyPath
,
'-o'
,
assemblyO
]));
if
(
compileResult
.
exitCode
!=
0
)
return
compileResult
;
final
String
frameworkDir
=
fs
.
path
.
join
(
outputPath
,
'App.framework'
);
fs
.
directory
(
frameworkDir
).
createSync
(
recursive:
true
);
final
String
appLib
=
fs
.
path
.
join
(
frameworkDir
,
'App'
);
final
List
<
String
>
linkArgs
=
commonBuildOptions
.
toList
()..
addAll
(<
String
>[
'-dynamiclib'
,
'-Xlinker'
,
'-rpath'
,
'-Xlinker'
,
'@executable_path/Frameworks'
,
'-Xlinker'
,
'-rpath'
,
'-Xlinker'
,
'@loader_path/Frameworks'
,
'-install_name'
,
'@rpath/App.framework/App'
,
'-o'
,
appLib
,
assemblyO
,
]);
final
RunResult
linkResult
=
await
xcode
.
clang
(
linkArgs
);
return
linkResult
;
}
/// Builds an Android shared library at [outputPath]/app.so from the assembly
/// source at [assemblyPath].
Future
<
RunResult
>
_buildAndroidSharedLibrary
({
@required
String
assemblyPath
,
@required
String
outputPath
,
})
async
{
// A word of warning: Instead of compiling via two steps, to a .o file and
// then to a .so file we use only one command. When using two commands
// gcc will end up putting a .eh_frame and a .debug_frame into the shared
// library. Without stripping .debug_frame afterwards, unwinding tools
// based upon libunwind use just one and ignore the contents of the other
// (which causes it to not look into the other section and therefore not
// find the correct unwinding information).
final
String
assemblySo
=
fs
.
path
.
join
(
outputPath
,
'app.so'
);
return
await
runCheckedAsync
(<
String
>[
androidSdk
.
ndkCompiler
]
..
addAll
(
androidSdk
.
ndkCompilerArgs
)
..
addAll
(<
String
>[
'-shared'
,
'-nostdlib'
,
'-o'
,
assemblySo
,
assemblyPath
]));
}
/// Compiles a Dart file to kernel.
/// Compiles a Dart file to kernel.
///
///
/// Returns the output kernel file path, or null on failure.
/// Returns the output kernel file path, or null on failure.
...
...
packages/flutter_tools/test/base/build_test.dart
View file @
802301e1
...
@@ -12,6 +12,8 @@ import 'package:flutter_tools/src/build_info.dart';
...
@@ -12,6 +12,8 @@ import 'package:flutter_tools/src/build_info.dart';
import
'package:flutter_tools/src/base/build.dart'
;
import
'package:flutter_tools/src/base/build.dart'
;
import
'package:flutter_tools/src/base/context.dart'
;
import
'package:flutter_tools/src/base/context.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/process.dart'
;
import
'package:flutter_tools/src/ios/mac.dart'
;
import
'package:flutter_tools/src/ios/mac.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:mockito/mockito.dart'
;
...
@@ -646,6 +648,10 @@ void main() {
...
@@ -646,6 +648,10 @@ void main() {
fs
.
path
.
join
(
outputPath
,
'snapshot.d'
):
''
,
fs
.
path
.
join
(
outputPath
,
'snapshot.d'
):
''
,
};
};
final
RunResult
successResult
=
new
RunResult
(
new
ProcessResult
(
1
,
0
,
''
,
''
));
when
(
xcode
.
cc
(
any
)).
thenAnswer
((
_
)
=>
new
Future
<
RunResult
>.
value
(
successResult
));
when
(
xcode
.
clang
(
any
)).
thenAnswer
((
_
)
=>
new
Future
<
RunResult
>.
value
(
successResult
));
final
int
genSnapshotExitCode
=
await
snapshotter
.
build
(
final
int
genSnapshotExitCode
=
await
snapshotter
.
build
(
platform:
TargetPlatform
.
ios
,
platform:
TargetPlatform
.
ios
,
buildMode:
BuildMode
.
profile
,
buildMode:
BuildMode
.
profile
,
...
@@ -688,6 +694,10 @@ void main() {
...
@@ -688,6 +694,10 @@ void main() {
fs
.
path
.
join
(
outputPath
,
'snapshot.d'
):
''
,
fs
.
path
.
join
(
outputPath
,
'snapshot.d'
):
''
,
};
};
final
RunResult
successResult
=
new
RunResult
(
new
ProcessResult
(
1
,
0
,
''
,
''
));
when
(
xcode
.
cc
(
any
)).
thenAnswer
((
_
)
=>
new
Future
<
RunResult
>.
value
(
successResult
));
when
(
xcode
.
clang
(
any
)).
thenAnswer
((
_
)
=>
new
Future
<
RunResult
>.
value
(
successResult
));
final
int
genSnapshotExitCode
=
await
snapshotter
.
build
(
final
int
genSnapshotExitCode
=
await
snapshotter
.
build
(
platform:
TargetPlatform
.
ios
,
platform:
TargetPlatform
.
ios
,
buildMode:
BuildMode
.
release
,
buildMode:
BuildMode
.
release
,
...
...
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