Skip to content

Merge from google/master #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
group("gn_all") {
deps = [
"//library:flutter_embedder",
"//plugins/color_panel:color_panel",
"//plugins/file_chooser:file_chooser",
"//plugins/menubar:menubar",
]
if (is_linux) {
deps += [
"//plugins/color_panel:color_panel",
"//plugins/file_chooser:file_chooser",
"//plugins/menubar:menubar",
]
}
}
8 changes: 2 additions & 6 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

# Root analysis options shared among all Dart code in the respository. Based
# on the Fuchsia standard analysis options, with some changes.
analyzer:
strong-mode: true
language:
enableSuperMixins: true
linter:
# Full list available at http://dart-lang.github.io/linter/lints/options/options.html.
rules:
Expand All @@ -29,7 +25,8 @@ linter:
- avoid_null_checks_in_equality_operators
- avoid_positional_boolean_parameters
- avoid_private_typedef_functions
- avoid_relative_lib_imports
# TODO: Change relative imports for package imports
# - avoid_relative_lib_imports
# This puts an unnecessary burden on API clients.
# - avoid_renaming_method_parameters
- avoid_return_types_on_setters
Expand Down Expand Up @@ -75,7 +72,6 @@ linter:
- parameter_assignments
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
- prefer_bool_in_asserts
- prefer_collection_literals
- prefer_conditional_assignment
# Disabled until bug is fixed
Expand Down
35 changes: 24 additions & 11 deletions build/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,33 @@
# limitations under the License.

config("defaults") {
cflags = [
"-std=c++14",
"-Wall",
"-Werror",
"-pthread",
]
if (is_linux) {
cflags = [
"-std=c++14",
"-Wall",
"-Werror",
"-pthread",
]
}
if (is_win) {
cflags = [
"/EHsc",
"/W3",
"/Od",
]
}
include_dirs = [
"//"
"//",
]
}

config("shared_library_defaults") {
cflags = [
"-shared",
"-fPIC",
]
if (is_linux) {
cflags = [
"-shared",
"-fPIC",
# Default to hidden for consistency with Windows builds.
"-fvisibility=hidden",
]
}
}
4 changes: 2 additions & 2 deletions build/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set_default_toolchain("//third_party/chromium/build/toolchain:gcc")

set_defaults("executable") {
configs = [ "//build:defaults" ]
}
Expand All @@ -28,6 +26,7 @@ set_defaults("published_shared_library") {
}

if (host_os == "linux") {
set_default_toolchain("//third_party/chromium/build/toolchain:gcc")
is_linux = true
is_mac = false
is_win = false
Expand All @@ -36,6 +35,7 @@ if (host_os == "linux") {
is_mac = true
is_win = false
} else if (host_os == "win") {
set_default_toolchain("//build/win/toolchain:msvc")
is_linux = false
is_mac = false
is_win = true
Expand Down
28 changes: 13 additions & 15 deletions build/packaging.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,29 @@
# under the top-level include/ directory in the build output.
#
# This is intended to make consuming public headers of all the libraries built
# by GN easy for outside build systems on Linux, by requiring only a single
# include directory.
if (is_linux) {
template("copy_includes") {
copy(target_name) {
assert(defined(invoker.sources),
"|sources| must be provided for copy_includes.")
forward_variables_from(invoker, [ "deps", "sources", "subdir" ])
output_dir = "$root_out_dir/include"
if (defined(subdir)) {
output_dir = "$output_dir/$subdir"
}
outputs = [ "$output_dir/{{source_file_part}}"]
# by GN easy for outside build systems, by requiring only a single include
# directory.
template("copy_includes") {
copy(target_name) {
assert(defined(invoker.sources),
"|sources| must be provided for copy_includes.")
forward_variables_from(invoker, [ "deps", "sources", "subdir" ])
output_dir = "$root_out_dir/include"
if (defined(subdir)) {
output_dir = "$output_dir/$subdir"
}
outputs = [ "$output_dir/{{source_file_part}}"]
}
}

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

if (is_linux) {
if (is_linux || is_win) {
copy_includes("_publish_${template_target_name}_headers") {
sources = invoker.public
subdir = invoker.public_header_subdir
Expand Down
33 changes: 33 additions & 0 deletions build/win/config/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//library/windows/glfw.gni")
import("//library/windows/jsoncpp.gni")

config("glfw3") {
libs = [
"$glfw_lib_name",
"opengl32.lib",

"user32.lib",
"gdi32.lib",
"shell32.lib",
]
}

config("jsoncpp") {
libs = [
"$jsoncpp_lib_name",
]
}
105 changes: 105 additions & 0 deletions build/win/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

toolchain("msvc") {
env_setup = "vcvars64.bat 1> nul &&"

tool("cc") {
pdbfile = "{{target_out_dir}}/{{label_name}}_c.pdb"
command = "$env_setup cl /nologo /showIncludes /MDd /FC {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd$pdbfile"
depsformat = "msvc"
description = "CC {{output}}"
outputs = [
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
]
}

tool("cxx") {
pdbfile = "{{target_out_dir}}/{{label_name}}_c.pdb"
command = "$env_setup cl /nologo /showIncludes /MDd /FC {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd$pdbfile"
depsformat = "msvc"
description = "CXX {{output}}"
outputs = [
"{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.obj",
]
}

tool("alink") {
rspfile = "{{output}}.rsp"
command = "$env_setup lib /nologo /OUT:{{output}} @$rspfile"
description = "AR {{target_output_name}}{{output_extension}}"
rspfile_content = "{{inputs}}"
outputs = [
"{{target_out_dir}}/{{target_output_name}}{{output_extension}}",
]
default_output_extension = ".lib"
}

tool("solink") {
dllname = "{{target_output_name}}{{output_extension}}" # e.g. foo.dll
dllfile = "{{output_dir}}/$dllname"
libfile = dllname + ".lib" # e.g. foo.dll.lib
pdbfile = dllname + ".pdb"
rspfile = dllname + ".rsp"

command = "$env_setup link /nologo /DLL {{ldflags}} /IMPLIB:$libfile /OUT:$dllfile /DEBUG /PDB:$pdbfile @$rspfile"
rspfile_content = "{{inputs}} {{solibs}} {{libs}}"

description = "SOLINK $dllfile"

# Use this for {{output_extension}} expansions unless a target manually
# overrides it (in which case {{output_extension}} will be what the target
# specifies).
default_output_extension = ".dll"

# Use this for {{output_dir}} expansions unless a target manually overrides
# it (in which case {{output_dir}} will be what the target specifies).
default_output_dir = "{{root_out_dir}}"

lib_dir_switch = "/LIBPATH:"

outputs = [
dllfile,
libfile,
pdbfile,
]

link_output = dllfile
depend_output = dllfile
}

tool("link") {
outfile = "{{target_output_name}}{{output_extension}}"
rspfile = "$outfile.rsp"
pdbfile = "$outfile.pdb"
command = "$env_setup link {{ldflags}} /nologo /OUT:$outfile /PDB:$pdbfile @$rspfile"
description = "LINK $outfile"
default_output_dir = "{{root_out_dir}}"
rspfile_content = "{{inputs}} {{libs}} {{solibs}}"
lib_dir_switch = "/LIBPATH:"
outputs = [
outfile,
]
}

tool("stamp") {
command = "cmd /c echo > {{output}}"
description = "STAMP {{output}}"
}

tool("copy") {
command = "powershell -Command Copy-Item {{source}} {{output}}"
description = "COPY {{source}} {{output}}"
}
}
2 changes: 1 addition & 1 deletion example/flutter_app/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: ../analysis_options.yaml
include: ../../analysis_options.yaml
5 changes: 0 additions & 5 deletions example/flutter_app/lib/keyboard_test_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ class _KeyboardTestPageState extends State<KeyboardTestPage> {
final FocusNode _focusNode = FocusNode();
final ScrollController _scrollController = new ScrollController();

@override
void initState() {
super.initState();
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
Expand Down
8 changes: 4 additions & 4 deletions example/flutter_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,18 @@ class _AppState extends State<MyApp> {
}

class _MyHomePage extends StatelessWidget {
const _MyHomePage({this.title, this.counter = 0});

final String title;
final int counter;

const _MyHomePage({this.title, this.counter = 0});

void _changePrimaryThemeColor(BuildContext context) {
final colorPanel = ColorPanel.instance;
if (!colorPanel.showing) {
colorPanel.show((color) {
_AppState.of(context).setPrimaryColor(color);
// Setting the primary color to a non-opaque color raises an exception.
}, showAlpha: false);
// Setting the primary color to a non-opaque color raises an exception.
}, showAlpha: false);
}
}

Expand Down
13 changes: 9 additions & 4 deletions example/linux/flutter_embedder_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,15 @@ int main(int argc, char **argv) {
}

// Register any native plugins.
AddPlugin(window, std::make_unique<plugins_menubar::MenubarPlugin>());
AddPlugin(window, std::make_unique<plugins_color_panel::ColorPanelPlugin>());
AddPlugin(window,
std::make_unique<plugins_file_chooser::FileChooserPlugin>());
plugins_menubar::MenubarPlugin::RegisterWithRegistrar(
flutter_desktop_embedding::GetRegistrarForPlugin(
window, "plugins_menubar::MenubarPlugin"));
plugins_color_panel::ColorPanelPlugin::RegisterWithRegistrar(
flutter_desktop_embedding::GetRegistrarForPlugin(
window, "plugins_color_panel::ColorPanelPlugin"));
plugins_file_chooser::FileChooserPlugin::RegisterWithRegistrar(
flutter_desktop_embedding::GetRegistrarForPlugin(
window, "plugins_file_chooser::FileChooserPlugin"));

flutter_desktop_embedding::FlutterWindowLoop(window);
glfwTerminate();
Expand Down
9 changes: 6 additions & 3 deletions example/macos/ExampleWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ class ExampleWindow: NSWindow {
@IBOutlet weak var flutterViewController: FLEViewController!

override func awakeFromNib() {
flutterViewController.add(FLEColorPanelPlugin())
flutterViewController.add(FLEFileChooserPlugin())
flutterViewController.add(FLEMenubarPlugin())
FLEColorPanelPlugin.register(
with: flutterViewController.registrar(forPlugin: "FLEColorPanelPlugin"))
FLEFileChooserPlugin.register(
with: flutterViewController.registrar(forPlugin: "FLEFileChooserPlugin"))
FLEMenubarPlugin.register(
with: flutterViewController.registrar(forPlugin: "FLEMenubarPlugin"))

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