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
752e341d
Commit
752e341d
authored
Nov 18, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #449 from abarth/run_build
Make flutter run_mojo imply flutter build
parents
4d0520bb
f6bd26a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
22 deletions
+57
-22
apk.dart
packages/flutter_tools/lib/src/commands/apk.dart
+8
-14
build.dart
packages/flutter_tools/lib/src/commands/build.dart
+6
-2
run_mojo.dart
packages/flutter_tools/lib/src/commands/run_mojo.dart
+28
-6
file_system.dart
packages/flutter_tools/lib/src/file_system.dart
+15
-0
No files found.
packages/flutter_tools/lib/src/commands/apk.dart
View file @
752e341d
...
...
@@ -9,6 +9,7 @@ import 'package:logging/logging.dart';
import
'package:path/path.dart'
as
path
;
import
'../build_configuration.dart'
;
import
'../file_system.dart'
;
import
'build.dart'
;
import
'flutter_command.dart'
;
import
'start.dart'
;
...
...
@@ -20,13 +21,6 @@ const String _kKeystorePassword = "chromium";
final
Logger
_logging
=
new
Logger
(
'flutter_tools.apk'
);
/// Create the ancestor directories of a file path if they do not already exist.
void
_ensureDirectoryExists
(
String
filePath
)
{
Directory
dir
=
new
Directory
(
path
.
dirname
(
filePath
));
if
(!
dir
.
existsSync
())
dir
.
createSync
(
recursive:
true
);
}
/// Copies files into a new directory structure.
class
_AssetBuilder
{
final
Directory
outDir
;
...
...
@@ -40,7 +34,7 @@ class _AssetBuilder {
void
add
(
File
asset
,
String
relativePath
)
{
String
destPath
=
path
.
join
(
_assetDir
.
path
,
relativePath
);
_
ensureDirectoryExists
(
destPath
);
ensureDirectoryExists
(
destPath
);
asset
.
copySync
(
destPath
);
}
...
...
@@ -147,7 +141,7 @@ class ApkCommand extends FlutterCommand {
}
Directory
tempDir
=
Directory
.
systemTemp
.
createTempSync
(
'flutter_tools'
);
try
{
try
{
_AssetBuilder
assetBuilder
=
new
_AssetBuilder
(
tempDir
,
'assets'
);
assetBuilder
.
add
(
icuData
,
'icudtl.dat'
);
assetBuilder
.
add
(
new
File
(
flxPath
),
'app.flx'
);
...
...
@@ -163,7 +157,7 @@ class ApkCommand extends FlutterCommand {
builder
.
sign
(
keystore
,
_kKeystorePassword
,
_kKeystoreKeyName
,
unalignedApk
);
File
finalApk
=
new
File
(
argResults
[
'output-file'
]);
_
ensureDirectoryExists
(
finalApk
.
path
);
ensureDirectoryExists
(
finalApk
.
path
);
builder
.
align
(
unalignedApk
,
finalApk
);
return
0
;
...
...
@@ -203,10 +197,10 @@ class ApkCommand extends FlutterCommand {
builder
.
inheritFromParent
(
this
);
int
result
;
await
builder
.
buildInTempDir
(
mainPath:
mainPath
,
onBundleAvailable:
(
String
localBundlePath
)
{
result
=
_buildApk
(
config
,
localBundlePath
);
}
mainPath:
mainPath
,
onBundleAvailable:
(
String
localBundlePath
)
{
result
=
_buildApk
(
config
,
localBundlePath
);
}
);
return
result
;
...
...
packages/flutter_tools/lib/src/commands/build.dart
View file @
752e341d
...
...
@@ -12,6 +12,7 @@ import 'package:flx/signing.dart';
import
'package:path/path.dart'
as
path
;
import
'package:yaml/yaml.dart'
;
import
'../file_system.dart'
;
import
'../toolchain.dart'
;
import
'flutter_command.dart'
;
...
...
@@ -109,8 +110,8 @@ ArchiveFile _createSnapshotFile(String snapshotPath) {
const
String
_kDefaultAssetBase
=
'packages/material_design_icons/icons'
;
const
String
_kDefaultMainPath
=
'lib/main.dart'
;
const
String
_kDefaultManifestPath
=
'flutter.yaml'
;
const
String
_kDefaultOutputPath
=
'app.flx'
;
const
String
_kDefaultSnapshotPath
=
'snapshot_blob.bin'
;
const
String
_kDefaultOutputPath
=
'
build/
app.flx'
;
const
String
_kDefaultSnapshotPath
=
'
build/
snapshot_blob.bin'
;
const
String
_kDefaultPrivateKeyPath
=
'privatekey.der'
;
class
BuildCommand
extends
FlutterCommand
{
...
...
@@ -186,6 +187,8 @@ class BuildCommand extends FlutterCommand {
Archive
archive
=
new
Archive
();
if
(!
precompiledSnapshot
)
{
ensureDirectoryExists
(
snapshotPath
);
// In a precompiled snapshot, the instruction buffer contains script
// content equivalents
int
result
=
await
toolchain
.
compiler
.
compile
(
mainPath:
mainPath
,
snapshotPath:
snapshotPath
);
...
...
@@ -208,6 +211,7 @@ class BuildCommand extends FlutterCommand {
AsymmetricKeyPair
keyPair
=
keyPairFromPrivateKeyFileSync
(
privateKeyPath
);
Uint8List
zipBytes
=
new
Uint8List
.
fromList
(
new
ZipEncoder
().
encode
(
archive
));
ensureDirectoryExists
(
outputPath
);
Bundle
bundle
=
new
Bundle
.
fromContent
(
path:
outputPath
,
manifest:
manifestDescriptor
,
...
...
packages/flutter_tools/lib/src/commands/run_mojo.dart
View file @
752e341d
...
...
@@ -11,7 +11,11 @@ import 'package:path/path.dart' as path;
import
'../artifacts.dart'
;
import
'../build_configuration.dart'
;
import
'../process.dart'
;
import
'build.dart'
;
import
'flutter_command.dart'
;
import
'start.dart'
;
const
String
_kDefaultBundlePath
=
'build/app.flx'
;
final
Logger
_logging
=
new
Logger
(
'flutter_tools.run_mojo'
);
...
...
@@ -25,7 +29,11 @@ class RunMojoCommand extends FlutterCommand {
argParser
.
addFlag
(
'mojo-debug'
,
negatable:
false
,
help:
'Use Debug build of mojo'
);
argParser
.
addFlag
(
'mojo-release'
,
negatable:
false
,
help:
'Use Release build of mojo (default)'
);
argParser
.
addOption
(
'app'
,
defaultsTo:
'app.flx'
);
argParser
.
addOption
(
'target'
,
defaultsTo:
''
,
abbr:
't'
,
help:
'Target app path or filename to start.'
);
argParser
.
addOption
(
'app'
,
help:
'Run this Flutter app instead of building the target.'
);
argParser
.
addOption
(
'mojo-path'
,
help:
'Path to directory containing mojo_shell and services.'
);
argParser
.
addOption
(
'devtools-path'
,
help:
'Path to mojo devtools
\'
mojo_run command.'
);
}
...
...
@@ -72,7 +80,7 @@ class RunMojoCommand extends FlutterCommand {
return
result
;
}
Future
<
List
<
String
>>
_getShellConfig
()
async
{
Future
<
List
<
String
>>
_getShellConfig
(
String
bundlePath
)
async
{
List
<
String
>
args
=
<
String
>[];
final
bool
useDevtools
=
_useDevtools
();
...
...
@@ -82,7 +90,7 @@ class RunMojoCommand extends FlutterCommand {
if
(
argResults
[
'android'
])
{
args
.
add
(
'--android'
);
final
String
cloudStorageBaseUrl
=
ArtifactStore
.
getCloudStorageBaseUrl
(
'shell'
,
'android-arm'
);
final
String
appPath
=
_makePathAbsolute
(
argResults
[
'app'
]
);
final
String
appPath
=
_makePathAbsolute
(
bundlePath
);
final
String
appName
=
path
.
basename
(
appPath
);
final
String
appDir
=
path
.
dirname
(
appPath
);
args
.
add
(
'http://app/
$appName
'
);
...
...
@@ -90,7 +98,7 @@ class RunMojoCommand extends FlutterCommand {
args
.
add
(
'--map-origin=http://flutter/=
$cloudStorageBaseUrl
'
);
args
.
add
(
'--url-mappings=mojo:flutter=http://flutter/flutter.mojo'
);
}
else
{
final
String
appPath
=
_makePathAbsolute
(
argResults
[
'app'
]
);
final
String
appPath
=
_makePathAbsolute
(
bundlePath
);
String
flutterPath
;
BuildConfiguration
config
=
_getCurrentHostConfig
();
if
(
config
==
null
||
config
.
type
==
BuildType
.
prebuilt
)
{
...
...
@@ -136,7 +144,21 @@ class RunMojoCommand extends FlutterCommand {
return
1
;
}
return
await
runCommandAndStreamOutput
(
await
_getShellConfig
());
}
await
downloadToolchain
();
String
bundlePath
=
argResults
[
'app'
];
if
(
bundlePath
==
null
)
{
bundlePath
=
_kDefaultBundlePath
;
String
mainPath
=
StartCommand
.
findMainDartFile
(
argResults
[
'target'
]);
BuildCommand
builder
=
new
BuildCommand
();
builder
.
inheritFromParent
(
this
);
int
result
=
await
builder
.
build
(
mainPath:
mainPath
,
outputPath:
bundlePath
);
if
(
result
!=
0
)
return
result
;
}
return
await
runCommandAndStreamOutput
(
await
_getShellConfig
(
bundlePath
));
}
}
packages/flutter_tools/lib/src/file_system.dart
0 → 100644
View file @
752e341d
// Copyright 2015 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'
;
import
'package:path/path.dart'
as
path
;
/// Create the ancestor directories of a file path if they do not already exist.
void
ensureDirectoryExists
(
String
filePath
)
{
String
dirPath
=
path
.
dirname
(
filePath
);
if
(
FileSystemEntity
.
isDirectorySync
(
dirPath
))
return
;
new
Directory
(
dirPath
).
createSync
(
recursive:
true
);
}
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