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
37c73e77
Unverified
Commit
37c73e77
authored
Apr 24, 2019
by
Jonah Williams
Committed by
GitHub
Apr 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove need for build/name scripts on Linux desktop (#31567)
parent
0572f158
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
27 deletions
+78
-27
build_info.dart
packages/flutter_tools/lib/src/build_info.dart
+5
-0
application_package.dart
...ages/flutter_tools/lib/src/linux/application_package.dart
+6
-10
build_linux.dart
packages/flutter_tools/lib/src/linux/build_linux.dart
+14
-5
linux_device.dart
packages/flutter_tools/lib/src/linux/linux_device.dart
+5
-2
makefile.dart
packages/flutter_tools/lib/src/linux/makefile.dart
+20
-0
project.dart
packages/flutter_tools/lib/src/project.dart
+4
-5
build_linux_test.dart
packages/flutter_tools/test/commands/build_linux_test.dart
+24
-5
No files found.
packages/flutter_tools/lib/src/build_info.dart
View file @
37c73e77
...
...
@@ -392,6 +392,11 @@ String getWebBuildDirectory() {
return
fs
.
path
.
join
(
getBuildDirectory
(),
'web'
);
}
/// Returns the linux build output directory.
String
getLinuxBuildDirectory
(
)
{
return
fs
.
path
.
join
(
getBuildDirectory
(),
'linux'
);
}
/// Returns directory used by incremental compiler (IKG - incremental kernel
/// generator) to store cached intermediate state.
String
getIncrementalCompilerByteStoreDirectory
(
)
{
...
...
packages/flutter_tools/lib/src/linux/application_package.dart
View file @
37c73e77
...
...
@@ -5,12 +5,10 @@
import
'package:meta/meta.dart'
;
import
'../application_package.dart'
;
import
'../base/common.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
;
import
'../base/process_manager.dart'
;
import
'../build_info.dart'
;
import
'../project.dart'
;
import
'makefile.dart'
;
abstract
class
LinuxApp
extends
ApplicationPackage
{
LinuxApp
({
@required
String
projectBundleId
})
:
super
(
id:
projectBundleId
);
...
...
@@ -59,14 +57,12 @@ class BuildableLinuxApp extends LinuxApp {
@override
String
executable
(
BuildMode
buildMode
)
{
final
ProcessResult
result
=
processManager
.
runSync
(<
String
>[
project
.
nameScript
.
path
,
buildMode
==
BuildMode
.
debug
?
'debug'
:
'release'
,
]);
if
(
result
.
exitCode
!=
0
)
{
throwToolExit
(
'Failed to find Linux project name'
);
final
String
binaryName
=
makefileExecutableName
(
project
);
if
(
buildMode
==
BuildMode
.
debug
)
{
return
fs
.
path
.
join
(
getLinuxBuildDirectory
(),
'debug'
,
binaryName
);
}
else
{
return
fs
.
path
.
join
(
getLinuxBuildDirectory
(),
'release'
,
binaryName
);
}
return
result
.
stdout
.
toString
().
trim
();
}
@override
...
...
packages/flutter_tools/lib/src/linux/build_linux.dart
View file @
37c73e77
...
...
@@ -12,13 +12,22 @@ import '../convert.dart';
import
'../globals.dart'
;
import
'../project.dart'
;
/// Builds the Linux project through the
project shell script
.
/// 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'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
Cache
.
flutterRoot
);
final
String
buildFlag
=
buildInfo
?.
isDebug
==
true
?
'debug'
:
'release'
;
final
String
bundleFlags
=
buildInfo
?.
trackWidgetCreation
==
true
?
'--track-widget-creation'
:
''
;
final
Process
process
=
await
processManager
.
start
(<
String
>[
linuxProject
.
buildScript
.
path
,
Cache
.
flutterRoot
,
buildInfo
?.
isDebug
==
true
?
'debug'
:
'release'
,
buildInfo
?.
trackWidgetCreation
==
true
?
'track-widget-creation'
:
'no-track-widget-creation'
,
'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/linux/linux_device.dart
View file @
37c73e77
...
...
@@ -71,6 +71,7 @@ class LinuxDevice extends Device {
bool
usesTerminalUi
=
true
,
bool
ipv6
=
false
,
})
async
{
_lastBuiltMode
=
debuggingOptions
.
buildInfo
.
mode
;
if
(!
prebuiltApplication
)
{
await
buildLinux
((
await
FlutterProject
.
current
()).
linux
,
debuggingOptions
.
buildInfo
);
}
...
...
@@ -96,8 +97,7 @@ class LinuxDevice extends Device {
@override
Future
<
bool
>
stopApp
(
covariant
LinuxApp
app
)
async
{
// Assume debug for now.
return
killProcess
(
app
.
executable
(
BuildMode
.
debug
));
return
killProcess
(
app
.
executable
(
_lastBuiltMode
));
}
@override
...
...
@@ -107,6 +107,9 @@ class LinuxDevice extends Device {
// to uninstall the application.
@override
Future
<
bool
>
uninstallApp
(
ApplicationPackage
app
)
async
=>
true
;
// Track the last built mode from startApp.
BuildMode
_lastBuiltMode
;
}
class
LinuxDevices
extends
PollingDeviceDiscovery
{
...
...
packages/flutter_tools/lib/src/linux/makefile.dart
0 → 100644
View file @
37c73e77
// 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
'../project.dart'
;
// The setting that controls the executable name in the linux makefile.
const
String
_kBinaryNameVariable
=
'BINARY_NAME='
;
/// Extracts the `BINARY_NAME` from a linux project Makefile.
///
/// Returns `null` if it cannot be found.
String
makefileExecutableName
(
LinuxProject
project
)
{
for
(
String
line
in
project
.
makeFile
.
readAsLinesSync
())
{
if
(
line
.
startsWith
(
_kBinaryNameVariable
))
{
return
line
.
split
(
_kBinaryNameVariable
).
last
.
trim
();
}
}
return
null
;
}
\ No newline at end of file
packages/flutter_tools/lib/src/project.dart
View file @
37c73e77
...
...
@@ -584,11 +584,10 @@ class LinuxProject {
final
FlutterProject
project
;
bool
existsSync
()
=>
project
.
directory
.
childDirectory
(
'linux'
).
existsSync
(
);
Directory
get
editableHostAppDirectory
=>
project
.
directory
.
childDirectory
(
'linux'
);
// Note: The build script file exists as a temporary shim.
File
get
buildScript
=>
project
.
directory
.
childDirectory
(
'linux'
).
childFile
(
'build.sh'
);
bool
existsSync
()
=>
editableHostAppDirectory
.
existsSync
();
//
Note: The name script file exists as a temporary shim
.
File
get
nameScript
=>
project
.
directory
.
childDirectory
(
'linux'
).
childFile
(
'name_output.sh
'
);
//
/ The Linux project makefile
.
File
get
makeFile
=>
editableHostAppDirectory
.
childFile
(
'Makefile
'
);
}
\ No newline at end of file
packages/flutter_tools/test/commands/build_linux_test.dart
View file @
37c73e77
...
...
@@ -9,6 +9,8 @@ import 'package:flutter_tools/src/base/io.dart';
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/build.dart'
;
import
'package:flutter_tools/src/linux/makefile.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
...
...
@@ -62,17 +64,19 @@ void main() {
FileSystem:
()
=>
memoryFilesystem
,
});
testUsingContext
(
'Linux build invokes
build script
'
,
()
async
{
testUsingContext
(
'Linux build invokes
make
'
,
()
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
>[
'/linux/build.sh'
,
'/'
,
'release'
,
'no-track-widget-creation'
,
'make'
,
'-C'
,
'/linux'
,
'BUILD=release'
,
'FLUTTER_ROOT=/'
,
'FLUTTER_BUNDLE_FLAGS='
,
],
runInShell:
true
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
mockProcess
;
});
...
...
@@ -85,6 +89,21 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Platform:
()
=>
linuxPlatform
,
});
testUsingContext
(
'linux can extract binary name from Makefile'
,
()
async
{
fs
.
file
(
'linux/Makefile'
)
..
createSync
(
recursive:
true
)
..
writeAsStringSync
(
r''
'
# Comment
SOMETHING_ELSE=FOO
BINARY_NAME=fizz_bar
'''
);
fs
.
file
(
'pubspec.yaml'
).
createSync
();
fs
.
file
(
'.packages'
).
createSync
();
final
FlutterProject
flutterProject
=
await
FlutterProject
.
current
();
expect
(
makefileExecutableName
(
flutterProject
.
linux
),
'fizz_bar'
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
MemoryFileSystem
()});
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
...
...
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