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
8b0243f4
Unverified
Commit
8b0243f4
authored
May 11, 2019
by
Jonah Williams
Committed by
GitHub
May 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Teach Linux to use local engine (#31631)
parent
829bdeb4
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
432 additions
and
18 deletions
+432
-18
tool_backend.dart
packages/flutter_tools/bin/tool_backend.dart
+82
-0
tool_backend.sh
packages/flutter_tools/bin/tool_backend.sh
+9
-0
executable.dart
packages/flutter_tools/lib/executable.dart
+2
-0
unpack.dart
packages/flutter_tools/lib/src/commands/unpack.dart
+308
-0
build_linux.dart
packages/flutter_tools/lib/src/linux/build_linux.dart
+22
-9
project.dart
packages/flutter_tools/lib/src/project.dart
+2
-0
pubspec.yaml
packages/flutter_tools/pubspec.yaml
+1
-1
build_linux_test.dart
packages/flutter_tools/test/commands/build_linux_test.dart
+6
-8
No files found.
packages/flutter_tools/bin/tool_backend.dart
0 → 100644
View file @
8b0243f4
// Copyright 2019 The Chromium 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
'dart:io'
;
// ignore: dart_io_import.
import
'package:path/path.dart'
as
path
;
// ignore: package_path_import.
/// Executes the required flutter tasks for a linux build.
Future
<
void
>
main
(
List
<
String
>
arguments
)
async
{
final
String
targetPlatform
=
arguments
[
0
];
final
String
buildMode
=
arguments
[
1
];
final
String
projectDirectory
=
Platform
.
environment
[
'PROJECT_DIR'
];
final
bool
verbose
=
Platform
.
environment
[
'VERBOSE_SCRIPT_LOGGING'
]
!=
null
;
final
bool
trackWidgetCreation
=
Platform
.
environment
[
'TRACK_WIDGET_CREATION'
]
!=
null
;
final
String
flutterTarget
=
Platform
.
environment
[
'FLUTTER_TARGET'
]
??
'lib/main.dart'
;
final
String
flutterEngine
=
Platform
.
environment
[
'FLUTTER_ENGINE'
];
final
String
localEngine
=
Platform
.
environment
[
'LOCAL_ENGINE'
];
final
String
flutterRoot
=
Platform
.
environment
[
'FLUTTER_ROOT'
];
Directory
.
current
=
projectDirectory
;
if
(
localEngine
!=
null
&&
!
localEngine
.
contains
(
buildMode
))
{
stderr
.
write
(
'''
ERROR: Requested build with Flutter local engine at '
$localEngine
'
This engine is not compatible with FLUTTER_BUILD_MODE: '
$buildMode
'.
You can fix this by updating the LOCAL_ENGINE environment variable, or
by running:
flutter build linux --local-engine=host_
$buildMode
or
flutter build linux --local-engine=host_
${buildMode}
_unopt
========================================================================
'''
);
exit
(
1
);
}
String
cacheDirectory
;
switch
(
targetPlatform
)
{
case
'linux-x64'
:
cacheDirectory
=
'linux/flutter'
;
break
;
default
:
stderr
.
write
(
'Unsupported target platform
$targetPlatform
'
);
exit
(
1
);
}
final
String
flutterExecutable
=
path
.
join
(
flutterRoot
,
'bin'
,
Platform
.
isWindows
?
'flutter.bat'
:
'flutter'
);
final
ProcessResult
unpackResult
=
await
Process
.
run
(
flutterExecutable
,
<
String
>[
'--suppress-analytics'
,
if
(
verbose
)
'--verbose'
,
'unpack'
,
'--target-platform=
$targetPlatform
'
,
'--cache-dir=
$cacheDirectory
'
,
if
(
flutterEngine
!=
null
)
'--local-engine-src-path=
$flutterEngine
'
,
if
(
localEngine
!=
null
)
'--local-engine=
$localEngine
'
,
]);
if
(
unpackResult
.
exitCode
!=
0
)
{
stderr
.
write
(
unpackResult
.
stderr
);
exit
(
1
);
}
final
ProcessResult
buildResult
=
await
Process
.
run
(
flutterExecutable
,
<
String
>[
'--suppress-analytics'
,
if
(
verbose
)
'--verbose'
,
'build'
,
'bundle'
,
'--target=
$flutterTarget
'
,
'--target-platform=
$targetPlatform
'
,
if
(
trackWidgetCreation
)
'--track-widget-creation'
,
if
(
flutterEngine
!=
null
)
'--local-engine-src-path=
$flutterEngine
'
,
if
(
localEngine
!=
null
)
'--local-engine=
$localEngine
'
,
]);
if
(
buildResult
.
exitCode
!=
0
)
{
stderr
.
write
(
buildResult
.
stderr
);
exit
(
1
);
}
exit
(
0
);
}
packages/flutter_tools/bin/tool_backend.sh
0 → 100755
View file @
8b0243f4
#!/usr/bin/env bash
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
readonly
flutter_bin_dir
=
"
${
FLUTTER_ROOT
}
/bin"
readonly
dart_bin_dir
=
"
${
flutter_bin_dir
}
/cache/dart-sdk/bin"
exec
"
${
dart_bin_dir
}
/dart"
"
${
FLUTTER_ROOT
}
/packages/flutter_tools/bin/tool_backend.dart"
"
${
@
:1
}
"
packages/flutter_tools/lib/executable.dart
View file @
8b0243f4
...
...
@@ -37,6 +37,7 @@ import 'src/commands/screenshot.dart';
import
'src/commands/shell_completion.dart'
;
import
'src/commands/test.dart'
;
import
'src/commands/train.dart'
;
import
'src/commands/unpack.dart'
;
import
'src/commands/update_packages.dart'
;
import
'src/commands/upgrade.dart'
;
import
'src/commands/version.dart'
;
...
...
@@ -82,6 +83,7 @@ Future<void> main(List<String> args) async {
ShellCompletionCommand
(),
TestCommand
(
verboseHelp:
verboseHelp
),
TrainingCommand
(),
UnpackCommand
(),
UpdatePackagesCommand
(
hidden:
!
verboseHelp
),
UpgradeCommand
(),
VersionCommand
(),
...
...
packages/flutter_tools/lib/src/commands/unpack.dart
0 → 100644
View file @
8b0243f4
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/linux/build_linux.dart
View file @
8b0243f4
...
...
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'../artifacts.dart'
;
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/logger.dart'
;
import
'../base/process_manager.dart'
;
...
...
@@ -13,21 +15,32 @@ import '../globals.dart';
import
'../project.dart'
;
/// Builds the Linux project through the Makefile.
Future
<
void
>
buildLinux
(
LinuxProject
linuxProject
,
BuildInfo
buildInfo
)
async
{
/// Cache flutter root in linux directory.
linuxProject
.
editableHostAppDirectory
.
childFile
(
'.generated_flutter_root'
)
Future
<
void
>
buildLinux
(
LinuxProject
linuxProject
,
BuildInfo
buildInfo
,
{
String
target
=
'lib/main.dart'
})
async
{
final
String
buildFlag
=
buildInfo
?.
isDebug
==
true
?
'debug'
:
'release'
;
final
StringBuffer
buffer
=
StringBuffer
(
'''
# Generated code do not commit.
export FLUTTER_ROOT=
${Cache.flutterRoot}
export BUILD=
$buildFlag
export TRACK_WIDGET_CREATION=
${buildInfo?.trackWidgetCreation == true}
export FLUTTER_TARGET=
$target
export PROJECT_DIR=
${linuxProject.project.directory.path}
'''
);
if
(
artifacts
is
LocalEngineArtifacts
)
{
final
LocalEngineArtifacts
localEngineArtifacts
=
artifacts
;
final
String
engineOutPath
=
localEngineArtifacts
.
engineOutPath
;
buffer
.
writeln
(
'export FLUTTER_ENGINE=
${fs.path.dirname(fs.path.dirname(engineOutPath))}
'
);
buffer
.
writeln
(
'export LOCAL_ENGINE=
${fs.path.basename(engineOutPath)}
'
);
}
/// Cache flutter configuration files in the linux directory.
linuxProject
.
cacheDirectory
.
childFile
(
'generated_config'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
Cache
.
flutterRoot
);
..
writeAsStringSync
(
buffer
.
toString
()
);
final
String
buildFlag
=
buildInfo
?.
isDebug
==
true
?
'debug'
:
'release'
;
final
String
bundleFlags
=
buildInfo
?.
trackWidgetCreation
==
true
?
'--track-widget-creation'
:
''
;
final
Process
process
=
await
processManager
.
start
(<
String
>[
'make'
,
'-C'
,
linuxProject
.
editableHostAppDirectory
.
path
,
'BUILD=
$buildFlag
'
,
'FLUTTER_ROOT=
${Cache.flutterRoot}
'
,
'FLUTTER_BUNDLE_FLAGS=
$bundleFlags
'
,
],
runInShell:
true
);
final
Status
status
=
logger
.
startProgress
(
'Building Linux application...'
,
...
...
packages/flutter_tools/lib/src/project.dart
View file @
8b0243f4
...
...
@@ -599,6 +599,8 @@ class LinuxProject {
Directory
get
editableHostAppDirectory
=>
project
.
directory
.
childDirectory
(
'linux'
);
Directory
get
cacheDirectory
=>
editableHostAppDirectory
.
childDirectory
(
'flutter'
);
bool
existsSync
()
=>
editableHostAppDirectory
.
existsSync
();
/// The Linux project makefile.
...
...
packages/flutter_tools/pubspec.yaml
View file @
8b0243f4
...
...
@@ -5,7 +5,7 @@ author: Flutter Authors <flutter-dev@googlegroups.com>
environment
:
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
sdk
:
"
>=2.2.
0
<3.0.0"
sdk
:
"
>=2.2.
2
<3.0.0"
dependencies
:
# To update these, use "flutter update-packages --force-upgrade".
...
...
packages/flutter_tools/test/commands/build_linux_test.dart
View file @
8b0243f4
...
...
@@ -21,7 +21,6 @@ import '../src/mocks.dart';
void
main
(
)
{
Cache
.
disableLocking
();
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
final
MemoryFileSystem
memoryFilesystem
=
MemoryFileSystem
();
final
MockProcess
mockProcess
=
MockProcess
();
final
MockPlatform
linuxPlatform
=
MockPlatform
();
final
MockPlatform
notLinuxPlatform
=
MockPlatform
();
...
...
@@ -46,7 +45,7 @@ void main() {
),
throwsA
(
isInstanceOf
<
ToolExit
>()));
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
linuxPlatform
,
FileSystem:
()
=>
memoryFilesystem
,
FileSystem:
()
=>
MemoryFileSystem
()
,
});
testUsingContext
(
'Linux build fails on non-linux platform'
,
()
async
{
...
...
@@ -61,22 +60,20 @@ void main() {
),
throwsA
(
isInstanceOf
<
ToolExit
>()));
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
notLinuxPlatform
,
FileSystem:
()
=>
memoryFilesystem
,
FileSystem:
()
=>
MemoryFileSystem
()
,
});
testUsingContext
(
'Linux build invokes make'
,
()
async
{
testUsingContext
(
'Linux build invokes make
and writes temporary files
'
,
()
async
{
final
BuildCommand
command
=
BuildCommand
();
applyMocksToCommand
(
command
);
fs
.
file
(
'linux/build.sh'
).
createSync
(
recursive:
true
);
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
when
(
mockProcessManager
.
start
(<
String
>[
'make'
,
'-C'
,
'/linux'
,
'BUILD=release'
,
'FLUTTER_ROOT=/'
,
'FLUTTER_BUNDLE_FLAGS='
,
],
runInShell:
true
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
mockProcess
;
});
...
...
@@ -84,8 +81,9 @@ void main() {
await
createTestCommandRunner
(
command
).
run
(
const
<
String
>[
'build'
,
'linux'
]
);
expect
(
fs
.
file
(
'linux/flutter/generated_config'
).
existsSync
(),
true
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
memoryFilesystem
,
FileSystem:
()
=>
MemoryFileSystem
()
,
ProcessManager:
()
=>
mockProcessManager
,
Platform:
()
=>
linuxPlatform
,
});
...
...
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