Skip to content

Commit b20940e

Browse files
authored
Merge pull request #6 from google/master
Merge from google/master
2 parents b2fc8b9 + a7c25b3 commit b20940e

File tree

99 files changed

+1849
-1707
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1849
-1707
lines changed

BUILD.gn

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
group("gn_all") {
1616
deps = [
1717
"//library:flutter_embedder",
18-
"//plugins/color_panel:color_panel",
19-
"//plugins/file_chooser:file_chooser",
20-
"//plugins/menubar:menubar",
2118
]
19+
if (is_linux) {
20+
deps += [
21+
"//plugins/color_panel:color_panel",
22+
"//plugins/file_chooser:file_chooser",
23+
"//plugins/menubar:menubar",
24+
]
25+
}
2226
}

analysis_options.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
# Root analysis options shared among all Dart code in the respository. Based
66
# on the Fuchsia standard analysis options, with some changes.
7-
analyzer:
8-
strong-mode: true
9-
language:
10-
enableSuperMixins: true
117
linter:
128
# Full list available at http://dart-lang.github.io/linter/lints/options/options.html.
139
rules:
@@ -29,7 +25,8 @@ linter:
2925
- avoid_null_checks_in_equality_operators
3026
- avoid_positional_boolean_parameters
3127
- avoid_private_typedef_functions
32-
- avoid_relative_lib_imports
28+
# TODO: Change relative imports for package imports
29+
# - avoid_relative_lib_imports
3330
# This puts an unnecessary burden on API clients.
3431
# - avoid_renaming_method_parameters
3532
- avoid_return_types_on_setters
@@ -75,7 +72,6 @@ linter:
7572
- parameter_assignments
7673
- prefer_adjacent_string_concatenation
7774
- prefer_asserts_in_initializer_lists
78-
- prefer_bool_in_asserts
7975
- prefer_collection_literals
8076
- prefer_conditional_assignment
8177
# Disabled until bug is fixed

build/BUILD.gn

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,33 @@
1313
# limitations under the License.
1414

1515
config("defaults") {
16-
cflags = [
17-
"-std=c++14",
18-
"-Wall",
19-
"-Werror",
20-
"-pthread",
21-
]
16+
if (is_linux) {
17+
cflags = [
18+
"-std=c++14",
19+
"-Wall",
20+
"-Werror",
21+
"-pthread",
22+
]
23+
}
24+
if (is_win) {
25+
cflags = [
26+
"/EHsc",
27+
"/W3",
28+
"/Od",
29+
]
30+
}
2231
include_dirs = [
23-
"//"
32+
"//",
2433
]
2534
}
2635

2736
config("shared_library_defaults") {
28-
cflags = [
29-
"-shared",
30-
"-fPIC",
31-
]
37+
if (is_linux) {
38+
cflags = [
39+
"-shared",
40+
"-fPIC",
41+
# Default to hidden for consistency with Windows builds.
42+
"-fvisibility=hidden",
43+
]
44+
}
3245
}

build/BUILDCONFIG.gn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
set_default_toolchain("//third_party/chromium/build/toolchain:gcc")
16-
1715
set_defaults("executable") {
1816
configs = [ "//build:defaults" ]
1917
}
@@ -28,6 +26,7 @@ set_defaults("published_shared_library") {
2826
}
2927

3028
if (host_os == "linux") {
29+
set_default_toolchain("//third_party/chromium/build/toolchain:gcc")
3130
is_linux = true
3231
is_mac = false
3332
is_win = false
@@ -36,6 +35,7 @@ if (host_os == "linux") {
3635
is_mac = true
3736
is_win = false
3837
} else if (host_os == "win") {
38+
set_default_toolchain("//build/win/toolchain:msvc")
3939
is_linux = false
4040
is_mac = false
4141
is_win = true

build/packaging.gni

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,29 @@
1616
# under the top-level include/ directory in the build output.
1717
#
1818
# This is intended to make consuming public headers of all the libraries built
19-
# by GN easy for outside build systems on Linux, by requiring only a single
20-
# include directory.
21-
if (is_linux) {
22-
template("copy_includes") {
23-
copy(target_name) {
24-
assert(defined(invoker.sources),
25-
"|sources| must be provided for copy_includes.")
26-
forward_variables_from(invoker, [ "deps", "sources", "subdir" ])
27-
output_dir = "$root_out_dir/include"
28-
if (defined(subdir)) {
29-
output_dir = "$output_dir/$subdir"
30-
}
31-
outputs = [ "$output_dir/{{source_file_part}}"]
19+
# by GN easy for outside build systems, by requiring only a single include
20+
# directory.
21+
template("copy_includes") {
22+
copy(target_name) {
23+
assert(defined(invoker.sources),
24+
"|sources| must be provided for copy_includes.")
25+
forward_variables_from(invoker, [ "deps", "sources", "subdir" ])
26+
output_dir = "$root_out_dir/include"
27+
if (defined(subdir)) {
28+
output_dir = "$output_dir/$subdir"
3229
}
30+
outputs = [ "$output_dir/{{source_file_part}}"]
3331
}
3432
}
3533

3634
# An abstraction for a shared library with associated headers that is intended
3735
# to be consumed from the build output.
3836
#
39-
# On Linux, this performs a copy_includes in addition to building the library.
37+
# This performs a copy_includes in addition to building the library.
4038
template("published_shared_library") {
4139
template_target_name = target_name
4240

43-
if (is_linux) {
41+
if (is_linux || is_win) {
4442
copy_includes("_publish_${template_target_name}_headers") {
4543
sources = invoker.public
4644
subdir = invoker.public_header_subdir

build/win/config/BUILD.gn

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2018 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//library/windows/glfw.gni")
16+
import("//library/windows/jsoncpp.gni")
17+
18+
config("glfw3") {
19+
libs = [
20+
"$glfw_lib_name",
21+
"opengl32.lib",
22+
23+
"user32.lib",
24+
"gdi32.lib",
25+
"shell32.lib",
26+
]
27+
}
28+
29+
config("jsoncpp") {
30+
libs = [
31+
"$jsoncpp_lib_name",
32+
]
33+
}

build/win/toolchain/BUILD.gn

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Copyright 2018 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
toolchain("msvc") {
16+
env_setup = "vcvars64.bat 1> nul &&"
17+
18+
tool("cc") {
19+
pdbfile = "{{target_out_dir}}/{{label_name}}_c.pdb"
20+
command = "$env_setup cl /nologo /showIncludes /MDd /FC {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd$pdbfile"
21+
depsformat = "msvc"
22+
description = "CC {{output}}"
23+
outputs = [
24+
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
25+
]
26+
}
27+
28+
tool("cxx") {
29+
pdbfile = "{{target_out_dir}}/{{label_name}}_c.pdb"
30+
command = "$env_setup cl /nologo /showIncludes /MDd /FC {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd$pdbfile"
31+
depsformat = "msvc"
32+
description = "CXX {{output}}"
33+
outputs = [
34+
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
35+
]
36+
}
37+
38+
tool("alink") {
39+
rspfile = "{{output}}.rsp"
40+
command = "$env_setup lib /nologo /OUT:{{output}} @$rspfile"
41+
description = "AR {{target_output_name}}{{output_extension}}"
42+
rspfile_content = "{{inputs}}"
43+
outputs = [
44+
"{{target_out_dir}}/{{target_output_name}}{{output_extension}}",
45+
]
46+
default_output_extension = ".lib"
47+
}
48+
49+
tool("solink") {
50+
dllname = "{{target_output_name}}{{output_extension}}" # e.g. foo.dll
51+
dllfile = "{{output_dir}}/$dllname"
52+
libfile = dllname + ".lib" # e.g. foo.dll.lib
53+
pdbfile = dllname + ".pdb"
54+
rspfile = dllname + ".rsp"
55+
56+
command = "$env_setup link /nologo /DLL {{ldflags}} /IMPLIB:$libfile /OUT:$dllfile /DEBUG /PDB:$pdbfile @$rspfile"
57+
rspfile_content = "{{inputs}} {{solibs}} {{libs}}"
58+
59+
description = "SOLINK $dllfile"
60+
61+
# Use this for {{output_extension}} expansions unless a target manually
62+
# overrides it (in which case {{output_extension}} will be what the target
63+
# specifies).
64+
default_output_extension = ".dll"
65+
66+
# Use this for {{output_dir}} expansions unless a target manually overrides
67+
# it (in which case {{output_dir}} will be what the target specifies).
68+
default_output_dir = "{{root_out_dir}}"
69+
70+
lib_dir_switch = "/LIBPATH:"
71+
72+
outputs = [
73+
dllfile,
74+
libfile,
75+
pdbfile,
76+
]
77+
78+
link_output = dllfile
79+
depend_output = dllfile
80+
}
81+
82+
tool("link") {
83+
outfile = "{{target_output_name}}{{output_extension}}"
84+
rspfile = "$outfile.rsp"
85+
pdbfile = "$outfile.pdb"
86+
command = "$env_setup link {{ldflags}} /nologo /OUT:$outfile /PDB:$pdbfile @$rspfile"
87+
description = "LINK $outfile"
88+
default_output_dir = "{{root_out_dir}}"
89+
rspfile_content = "{{inputs}} {{libs}} {{solibs}}"
90+
lib_dir_switch = "/LIBPATH:"
91+
outputs = [
92+
outfile,
93+
]
94+
}
95+
96+
tool("stamp") {
97+
command = "cmd /c echo > {{output}}"
98+
description = "STAMP {{output}}"
99+
}
100+
101+
tool("copy") {
102+
command = "powershell -Command Copy-Item {{source}} {{output}}"
103+
description = "COPY {{source}} {{output}}"
104+
}
105+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include: ../analysis_options.yaml
1+
include: ../../analysis_options.yaml

example/flutter_app/lib/keyboard_test_page.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ class _KeyboardTestPageState extends State<KeyboardTestPage> {
2929
final FocusNode _focusNode = FocusNode();
3030
final ScrollController _scrollController = new ScrollController();
3131

32-
@override
33-
void initState() {
34-
super.initState();
35-
}
36-
3732
@override
3833
void didChangeDependencies() {
3934
super.didChangeDependencies();

example/flutter_app/lib/main.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,18 @@ class _AppState extends State<MyApp> {
140140
}
141141

142142
class _MyHomePage extends StatelessWidget {
143+
const _MyHomePage({this.title, this.counter = 0});
144+
143145
final String title;
144146
final int counter;
145147

146-
const _MyHomePage({this.title, this.counter = 0});
147-
148148
void _changePrimaryThemeColor(BuildContext context) {
149149
final colorPanel = ColorPanel.instance;
150150
if (!colorPanel.showing) {
151151
colorPanel.show((color) {
152152
_AppState.of(context).setPrimaryColor(color);
153-
// Setting the primary color to a non-opaque color raises an exception.
154-
}, showAlpha: false);
153+
// Setting the primary color to a non-opaque color raises an exception.
154+
}, showAlpha: false);
155155
}
156156
}
157157

example/linux/flutter_embedder_example.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,15 @@ int main(int argc, char **argv) {
8383
}
8484

8585
// Register any native plugins.
86-
AddPlugin(window, std::make_unique<plugins_menubar::MenubarPlugin>());
87-
AddPlugin(window, std::make_unique<plugins_color_panel::ColorPanelPlugin>());
88-
AddPlugin(window,
89-
std::make_unique<plugins_file_chooser::FileChooserPlugin>());
86+
plugins_menubar::MenubarPlugin::RegisterWithRegistrar(
87+
flutter_desktop_embedding::GetRegistrarForPlugin(
88+
window, "plugins_menubar::MenubarPlugin"));
89+
plugins_color_panel::ColorPanelPlugin::RegisterWithRegistrar(
90+
flutter_desktop_embedding::GetRegistrarForPlugin(
91+
window, "plugins_color_panel::ColorPanelPlugin"));
92+
plugins_file_chooser::FileChooserPlugin::RegisterWithRegistrar(
93+
flutter_desktop_embedding::GetRegistrarForPlugin(
94+
window, "plugins_file_chooser::FileChooserPlugin"));
9095

9196
flutter_desktop_embedding::FlutterWindowLoop(window);
9297
glfwTerminate();

example/macos/ExampleWindow.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ class ExampleWindow: NSWindow {
1818
@IBOutlet weak var flutterViewController: FLEViewController!
1919

2020
override func awakeFromNib() {
21-
flutterViewController.add(FLEColorPanelPlugin())
22-
flutterViewController.add(FLEFileChooserPlugin())
23-
flutterViewController.add(FLEMenubarPlugin())
21+
FLEColorPanelPlugin.register(
22+
with: flutterViewController.registrar(forPlugin: "FLEColorPanelPlugin"))
23+
FLEFileChooserPlugin.register(
24+
with: flutterViewController.registrar(forPlugin: "FLEFileChooserPlugin"))
25+
FLEMenubarPlugin.register(
26+
with: flutterViewController.registrar(forPlugin: "FLEMenubarPlugin"))
2427

2528
let assets = NSURL.fileURL(withPath: "flutter_assets", relativeTo: Bundle.main.resourceURL)
2629
// Pass through argument zero, since the Flutter engine expects to be processing a full

0 commit comments

Comments
 (0)