From 41058789cbf3d48e3b206a609ee3fe8e0e4808d4 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Tue, 11 Dec 2018 15:33:02 +1300 Subject: [PATCH 01/17] Initial Windows GN build --- BUILD.gn | 10 +- build/BUILD.gn | 31 ++++--- build/BUILDCONFIG.gn | 4 +- build/packaging.gni | 50 +++++----- build/win/config/BUILD.gn | 32 +++++++ build/win/toolchain/BUILD.gn | 91 +++++++++++++++++++ example/windows/GLFW Example.vcxproj | 10 +- example/windows/flutter_embedder_example.cpp | 2 +- library/BUILD.gn | 54 ++++++++--- library/GN.md | 32 ++++++- library/engine.gni | 10 ++ library/windows/BUILD.gn | 60 ++++++++++++ library/windows/GLFW Library.vcxproj | 16 ++-- library/windows/GLFW Library.vcxproj.filters | 14 +-- library/windows/glfw.gni | 20 ++++ .../flutter_desktop_embedding}/embedder.h | 1 + library/windows/{ => src}/embedder.cpp | 2 +- tools/dart_tools/bin/fetch_glfw.dart | 64 +++++++++++++ tools/gn_dart.bat | 26 ++++++ 19 files changed, 448 insertions(+), 81 deletions(-) create mode 100644 build/win/config/BUILD.gn create mode 100644 build/win/toolchain/BUILD.gn create mode 100644 library/windows/BUILD.gn create mode 100644 library/windows/glfw.gni rename library/windows/{ => include/flutter_desktop_embedding}/embedder.h (99%) rename library/windows/{ => src}/embedder.cpp (99%) create mode 100644 tools/dart_tools/bin/fetch_glfw.dart create mode 100644 tools/gn_dart.bat diff --git a/BUILD.gn b/BUILD.gn index 380d3007b..e8c5ef6b5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -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", + ] + } } diff --git a/build/BUILD.gn b/build/BUILD.gn index afb87c94b..97264e417 100644 --- a/build/BUILD.gn +++ b/build/BUILD.gn @@ -13,20 +13,29 @@ # 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", + ] + } include_dirs = [ - "//" + "//", ] } config("shared_library_defaults") { - cflags = [ - "-shared", - "-fPIC", - ] + if(is_linux) { + cflags = [ + "-shared", + "-fPIC", + ] + } } diff --git a/build/BUILDCONFIG.gn b/build/BUILDCONFIG.gn index 09cbb879a..a87e2dff4 100644 --- a/build/BUILDCONFIG.gn +++ b/build/BUILDCONFIG.gn @@ -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" ] } @@ -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 @@ -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 diff --git a/build/packaging.gni b/build/packaging.gni index 9c06f5407..56b647b67 100644 --- a/build/packaging.gni +++ b/build/packaging.gni @@ -16,45 +16,41 @@ # 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) { - copy_includes("_publish_${template_target_name}_headers") { - sources = invoker.public - subdir = invoker.public_header_subdir - } + copy_includes("_publish_${template_target_name}_headers") { + sources = invoker.public + subdir = invoker.public_header_subdir + } - shared_library(template_target_name) { - forward_variables_from(invoker, "*") - assert(defined(public), - "|public| must be provided for published_shared_library.") + shared_library(template_target_name) { + forward_variables_from(invoker, "*") + assert(defined(public), + "|public| must be provided for published_shared_library.") - if (!defined(deps)) { - deps = [] - } - deps += [ ":_publish_${template_target_name}_headers" ] + if (!defined(deps)) { + deps = [] } + deps += [ ":_publish_${template_target_name}_headers" ] } } diff --git a/build/win/config/BUILD.gn b/build/win/config/BUILD.gn new file mode 100644 index 000000000..6ebed7890 --- /dev/null +++ b/build/win/config/BUILD.gn @@ -0,0 +1,32 @@ +# 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. + +config("glfw3") { + libs = [ + "glfw3.lib", + "opengl32.lib", + + "user32.lib", + "gdi32.lib", + "winspool.lib", + "comdlg32.lib", + "advapi32.lib", + "shell32.lib", + "ole32.lib", + "oleaut32.lib", + "uuid.lib", + "odbc32.lib", + "odbccp32.lib", + ] +} \ No newline at end of file diff --git a/build/win/toolchain/BUILD.gn b/build/win/toolchain/BUILD.gn new file mode 100644 index 000000000..c2b59feec --- /dev/null +++ b/build/win/toolchain/BUILD.gn @@ -0,0 +1,91 @@ +toolchain("msvc") { + env_setup = "vcvars64.bat &&" + + tool("cc") { + pdbfile = "{{target_out_dir}}/{{label_name}}_c.pdb" + command = "$env_setup cl /nologo /showIncludes /MD /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 /MD /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}}" + } +} \ No newline at end of file diff --git a/example/windows/GLFW Example.vcxproj b/example/windows/GLFW Example.vcxproj index 1da8b14ed..2da23f07f 100644 --- a/example/windows/GLFW Example.vcxproj +++ b/example/windows/GLFW Example.vcxproj @@ -72,25 +72,25 @@ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\include\;$(IncludePath) $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\include\;$(IncludePath) $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\include\;$(IncludePath) $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\include\;$(IncludePath) $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) @@ -227,4 +227,4 @@ $(SolutionDir) - + \ No newline at end of file diff --git a/example/windows/flutter_embedder_example.cpp b/example/windows/flutter_embedder_example.cpp index d8485e70f..94c2ff8fa 100644 --- a/example/windows/flutter_embedder_example.cpp +++ b/example/windows/flutter_embedder_example.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include int main(int argc, char **argv) { if (!FlutterInit()) { diff --git a/library/BUILD.gn b/library/BUILD.gn index 6a08b7663..65cef2e25 100644 --- a/library/BUILD.gn +++ b/library/BUILD.gn @@ -54,22 +54,31 @@ published_shared_library("flutter_embedder") { ] } + if (is_win) { + sources = [ + "windows/src/embedder.cpp", + ] + public = [ + "windows/include/flutter_desktop_embedding/embedder.h", + ] + } + deps = [ ":fetch_flutter_engine", ] - if (is_linux) { - public_header_subdir = "flutter_desktop_embedding" - - deps += [ - "//library/linux:publish_flutter_engine", - ] + public_header_subdir = "flutter_desktop_embedding" + if (is_linux) { libs = [ "glfw", "GL", ] + deps += [ + "//library/linux:publish_flutter_engine", + ] + configs += [ "//build/linux/config:epoxy", "//build/linux/config:gtk3", @@ -81,6 +90,31 @@ published_shared_library("flutter_embedder") { "//library/linux:relative_public_headers", ] } + + if (is_win) { + dll_exports = rebase_path("windows/exports.def") + ldflags = [ + "/DEF:$dll_exports", + ] + + deps += [ + "//library/windows:publish_flutter_engine", + "//library/windows:fetch_glfw", + ] + + libs = [ + engine_files[2], + ] + + configs += [ + "//build/win/config:glfw3" + ] + + public_configs = [ + "//library/windows:relative_public_headers", + "//library/windows:relative_dependency_headers", + ] + } } # Allows targets depending on the engine library to use library-style @@ -99,9 +133,7 @@ action("fetch_flutter_engine") { "--flutter_root=$flutter_tree_path", rebase_path(engine_download_dir, root_build_dir), ] - if (is_linux) { - public_configs = [ - ":relative_engine_headers", - ] - } + public_configs = [ + ":relative_engine_headers", + ] } diff --git a/library/GN.md b/library/GN.md index 32cb98977..d63ebc3ab 100644 --- a/library/GN.md +++ b/library/GN.md @@ -1,6 +1,7 @@ # Using GN -If you are building on Linux, you can use GN instead of Make. +If you are building on Linux or Windows, you can use GN instead of Make or +Visual Studio. This is currently optional and is under evaluation, but in the future it may become the build system used on all platforms. @@ -9,10 +10,23 @@ become the build system used on all platforms. In addition to the normal dependencies, you will need to install: * [ninja](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages) -* [gn](https://gn.googlesource.com/gn/) +* [gn](https://gn.googlesource.com/gn/) Ensure that both binaries are in your path. +Windows also requires the 64 bit compiler, linker and setup scripts to be in +your path. They are found under: + +``` +Visual Studio Install Path\VC\bin\amd64 +``` + +e.g.: + +``` +C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64 +``` + ## Building ### Library @@ -41,13 +55,21 @@ $ ninja -C out ### Example +#### Linux + To use the GN build for the depedencies of the example application, when running `make` for the example add `USE_GN=1` to the end of the command. The resulting binary will be in `out/example/` rather than `example/linux/out/`. +#### Windows + +Building the example with GN is not currently supported. Follow the [Visual +Studio example build instructions](../example/README.md) to build the example +app. + ## Feedback -If you encounter issues with the GN build, please test with Make before filing -a bug so that the report can include whether the issue is specific to GN, or -a general build issue. +If you encounter issues with the GN build, please test with Make or Visual +Studio before filing a bug so that the report can include whether the issue is +specific to GN, or a general build issue. diff --git a/library/engine.gni b/library/engine.gni index 92018bf21..12892316b 100644 --- a/library/engine.gni +++ b/library/engine.gni @@ -22,3 +22,13 @@ if (is_linux) { "$engine_download_dir/flutter_embedder.h", ] } + +if(is_win) { + engine_files = [ + "$engine_download_dir/flutter_engine.dll", + "$engine_download_dir/flutter_embedder.h", + "$engine_download_dir/flutter_engine.dll.lib", + "$engine_download_dir/flutter_engine.dll.exp", + "$engine_download_dir/flutter_engine.dll.pdb", + ] +} diff --git a/library/windows/BUILD.gn b/library/windows/BUILD.gn new file mode 100644 index 000000000..bfdcbf25f --- /dev/null +++ b/library/windows/BUILD.gn @@ -0,0 +1,60 @@ +# 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("//build/packaging.gni") +import("//library/engine.gni") +import("//library/windows/glfw.gni") + +# Allows targets depending on this library to use library-style +# inculdes for its header rather than project-relative. +config("relative_public_headers") { + include_dirs = [ + "include", + ] +} + +action("fetch_glfw") { + script = "//tools/dart_tools/bin/fetch_glfw.dart" + outputs = glfw_files + args = [ + rebase_path(glfw_download_dir, root_build_dir) + ] +} + +config("relative_dependency_headers") { + include_dirs = [ glfw_download_dir ] + lib_dirs = [ glfw_download_dir ] +} + +copy_includes("_publish_engine_headers") { + sources = [ engine_files[1] ] + deps = [ "//library:fetch_flutter_engine" ] +} + +# Places the downloaded Flutter engine library at the top level of the +# output directory where built libraries go, so that it doesn't require +# special link handling, and publishes its header. +copy("publish_flutter_engine") { + sources = [ + engine_files[0], + engine_files[2], + engine_files[3], + engine_files[4], + ] + outputs = [ "$root_out_dir/{{source_file_part}}" ] + deps = [ + ":_publish_engine_headers", + "//library:fetch_flutter_engine", + ] +} diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index 2df1af2eb..4cad50ef0 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -75,7 +75,7 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) + $(ProjectDir)include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) @@ -83,7 +83,7 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .lib - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) + $(ProjectDir)include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) @@ -91,7 +91,7 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) + $(ProjectDir)include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) @@ -99,7 +99,7 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .lib - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) + $(ProjectDir)include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) @@ -259,15 +259,15 @@ - + - + - + - + \ No newline at end of file diff --git a/library/windows/GLFW Library.vcxproj.filters b/library/windows/GLFW Library.vcxproj.filters index 58963352d..41584ddd8 100644 --- a/library/windows/GLFW Library.vcxproj.filters +++ b/library/windows/GLFW Library.vcxproj.filters @@ -15,18 +15,18 @@ - + + Source Files + + + + Source Files - + Header Files - - - Source Files - - \ No newline at end of file diff --git a/library/windows/glfw.gni b/library/windows/glfw.gni new file mode 100644 index 000000000..413e9896a --- /dev/null +++ b/library/windows/glfw.gni @@ -0,0 +1,20 @@ +# 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. + +glfw_download_dir = "$root_gen_dir/glfw" + +glfw_files = [ + "$glfw_download_dir/glfw3.lib", + "$glfw_download_dir/glfw3.h", +] \ No newline at end of file diff --git a/library/windows/embedder.h b/library/windows/include/flutter_desktop_embedding/embedder.h similarity index 99% rename from library/windows/embedder.h rename to library/windows/include/flutter_desktop_embedding/embedder.h index 5d52c1c18..a99d7a188 100644 --- a/library/windows/embedder.h +++ b/library/windows/include/flutter_desktop_embedding/embedder.h @@ -15,6 +15,7 @@ #ifndef WINDOWS_LIBRARY_EMBEDDER_H_ #define WINDOWS_LIBRARY_EMBEDDER_H_ +#include #include #include diff --git a/library/windows/embedder.cpp b/library/windows/src/embedder.cpp similarity index 99% rename from library/windows/embedder.cpp rename to library/windows/src/embedder.cpp index a601c9c73..7906ef79b 100644 --- a/library/windows/embedder.cpp +++ b/library/windows/src/embedder.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "embedder.h" +#include #include #include diff --git a/tools/dart_tools/bin/fetch_glfw.dart b/tools/dart_tools/bin/fetch_glfw.dart new file mode 100644 index 000000000..ab5552cbb --- /dev/null +++ b/tools/dart_tools/bin/fetch_glfw.dart @@ -0,0 +1,64 @@ +// 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 'dart:io'; + +import 'package:path/path.dart' as path; +import 'package:archive/archive.dart'; + +const String glfwArchiveUrlString = + 'http://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.bin.WIN64.zip'; + +Future main(List arguments) async { + if (!Platform.isWindows) { + throw new Exception('Prebuilt glfw3 libraries are only available on ' + 'windows.'); + } + + if (arguments.length != 1) { + throw new Exception('Only one argument should be passed, the directory to ' + 'download glfw to.'); + } + + final outputDirectory = arguments[0]; + + final archiveUri = Uri.parse(glfwArchiveUrlString); + + final httpClient = new HttpClient(); + final response = + await httpClient.getUrl(archiveUri).then((request) => request.close()); + final archiveData = []; + await for (final data in response) { + archiveData.addAll(data); + } + httpClient.close(); + + await new Directory(outputDirectory).create(recursive: true); + + const Map requiredFiles = { + 'glfw-3.2.1.bin.WIN64/include/GLFW/glfw3.h': 'glfw3.h', + 'glfw-3.2.1.bin.WIN64/lib-vc2015/glfw3.lib': 'glfw3.lib', + }; + + final archive = new ZipDecoder().decodeBytes(archiveData); + for (final file in archive) { + if (!requiredFiles.containsKey(file.name)) { + continue; + } + + final extractedFile = + new File(path.join(outputDirectory, requiredFiles[file.name])); + extractedFile.writeAsBytes(file.content); + } +} diff --git a/tools/gn_dart.bat b/tools/gn_dart.bat new file mode 100644 index 000000000..e7be3cc2f --- /dev/null +++ b/tools/gn_dart.bat @@ -0,0 +1,26 @@ +:: 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. +@echo off + +:: This script wraps GN with a --script-executable pointing at the Dart binary +:: packaged with the Flutter tree. +set BASE_DIR=%~dp0 +for /f "delims=" %%i in ('%~dp0flutter_location') do set FLUTTER_DIR=%%i +set FLUTTER_BIN_DIR=%FLUTTER_DIR%\bin +set DART_BIN_DIR=%FLUTTER_BIN_DIR%\cache\dart-sdk\bin + +:: Ensure that the Dart SDK has been downloaded. +if not exist %DART_BIN_DIR%\ call %FLUTTER_BIN_DIR%\flutter precache + +call gn --script-executable=%DART_BIN_DIR%\dart %* \ No newline at end of file From 722211444eae977614b066261a7595131a8ba2a0 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Wed, 12 Dec 2018 17:06:13 +1300 Subject: [PATCH 02/17] Add flutter_desktop_embedding namespace --- .../include/flutter_desktop_embedding/embedder.h | 4 ++++ library/windows/src/embedder.cpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/library/windows/include/flutter_desktop_embedding/embedder.h b/library/windows/include/flutter_desktop_embedding/embedder.h index a99d7a188..bd5dd13a8 100644 --- a/library/windows/include/flutter_desktop_embedding/embedder.h +++ b/library/windows/include/flutter_desktop_embedding/embedder.h @@ -21,6 +21,8 @@ #include +namespace flutter_desktop_embedding { + // Calls glfwInit() // // glfwInit() must be called in the same library as glfwCreateWindow() @@ -76,3 +78,5 @@ GLFWwindow *CreateFlutterWindowInSnapshotMode( void FlutterWindowLoop(GLFWwindow *flutter_window); #endif // WINDOWS_LIBRARY_EMBEDDER_H_ + +} // namespace flutter_desktop_embedding diff --git a/library/windows/src/embedder.cpp b/library/windows/src/embedder.cpp index 7906ef79b..28c54ecdf 100644 --- a/library/windows/src/embedder.cpp +++ b/library/windows/src/embedder.cpp @@ -25,10 +25,6 @@ static_assert(FLUTTER_ENGINE_VERSION == 1, ""); static constexpr char kDefaultWindowTitle[] = "Flutter"; -bool FlutterInit() { return glfwInit(); } - -void FlutterTerminate() { glfwTerminate(); } - static void GLFWcursorPositionCallbackAtPhase(GLFWwindow *window, FlutterPointerPhase phase, double x, double y) { @@ -161,6 +157,12 @@ static FlutterEngine RunFlutterEngine( return engine; } +namespace flutter_desktop_embedding { + +bool FlutterInit() { return glfwInit(); } + +void FlutterTerminate() { glfwTerminate(); } + GLFWwindow *CreateFlutterWindow(size_t initial_width, size_t initial_height, const std::string &main_path, const std::string &assets_path, @@ -205,3 +207,5 @@ void FlutterWindowLoop(GLFWwindow *flutter_window) { glfwGetWindowUserPointer(flutter_window))); glfwDestroyWindow(flutter_window); } + +} // namespace flutter_desktop_embedder From 70710726cb04e894e85130db058a03e511b03101 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Wed, 12 Dec 2018 17:12:40 +1300 Subject: [PATCH 03/17] [windows] [gn] Add namespaces to example embedder --- example/windows/flutter_embedder_example.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/example/windows/flutter_embedder_example.cpp b/example/windows/flutter_embedder_example.cpp index 94c2ff8fa..d8b77fa61 100644 --- a/example/windows/flutter_embedder_example.cpp +++ b/example/windows/flutter_embedder_example.cpp @@ -18,7 +18,7 @@ #include int main(int argc, char **argv) { - if (!FlutterInit()) { + if (!flutter_desktop_embedding::FlutterInit()) { std::cout << "Couldn't init GLFW" << std::endl; } // Arguments for the Flutter Engine. @@ -31,15 +31,15 @@ int main(int argc, char **argv) { #endif // Start the engine. // TODO: Make paths relative to the executable so it can be run from anywhere. - auto window = CreateFlutterWindowInSnapshotMode( + auto window = flutter_desktop_embedding::CreateFlutterWindowInSnapshotMode( 640, 480, "..\\..\\example\\flutter_app\\build\\flutter_assets", "..\\..\\library\\windows\\dependencies\\engine\\icudtl.dat", arguments); if (window == nullptr) { - FlutterTerminate(); + flutter_desktop_embedding::FlutterTerminate(); return EXIT_FAILURE; } - FlutterWindowLoop(window); - FlutterTerminate(); + flutter_desktop_embedding::FlutterWindowLoop(window); + flutter_desktop_embedding::FlutterTerminate(); return EXIT_SUCCESS; } From ff7c6bbd845acf9d4a70d542071cf05f20a09933 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Sun, 30 Dec 2018 22:49:02 +1300 Subject: [PATCH 04/17] Update to master --- build/win/toolchain/BUILD.gn | 14 +++++++++ example/windows/GLFW Example.vcxproj | 2 +- example/windows/flutter_embedder_example.cpp | 2 +- library/BUILD.gn | 29 ++++++++++--------- .../windows}/embedder.h | 2 +- library/windows/BUILD.gn | 4 +-- library/windows/GLFW Library.vcxproj | 4 +-- library/windows/GLFW Library.vcxproj.filters | 2 +- library/windows/glfw.gni | 3 +- library/windows/scripts/get_GLFW.bat | 25 ++-------------- library/windows/src/embedder.cpp | 2 +- 11 files changed, 42 insertions(+), 47 deletions(-) rename library/{windows/include/flutter_desktop_embedding => include/flutter_desktop_embedding/windows}/embedder.h (99%) diff --git a/build/win/toolchain/BUILD.gn b/build/win/toolchain/BUILD.gn index c2b59feec..01de72ace 100644 --- a/build/win/toolchain/BUILD.gn +++ b/build/win/toolchain/BUILD.gn @@ -1,3 +1,17 @@ +# 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 &&" diff --git a/example/windows/GLFW Example.vcxproj b/example/windows/GLFW Example.vcxproj index 2da23f07f..25a831fd8 100644 --- a/example/windows/GLFW Example.vcxproj +++ b/example/windows/GLFW Example.vcxproj @@ -72,7 +72,7 @@ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\include\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\library\include\;$(IncludePath) $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) diff --git a/example/windows/flutter_embedder_example.cpp b/example/windows/flutter_embedder_example.cpp index d8b77fa61..1cddb46e5 100644 --- a/example/windows/flutter_embedder_example.cpp +++ b/example/windows/flutter_embedder_example.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include int main(int argc, char **argv) { if (!flutter_desktop_embedding::FlutterInit()) { diff --git a/library/BUILD.gn b/library/BUILD.gn index 24aecf3c3..dca1582bf 100644 --- a/library/BUILD.gn +++ b/library/BUILD.gn @@ -25,7 +25,16 @@ published_shared_library("flutter_embedder") { "include/flutter_desktop_embedding/linux/embedder.h", ] } - if (is_linux || is_win) { + if (is_win) { + sources = [ + "windows/src/embedder.cpp", + ] + public = [ + "include/flutter_desktop_embedding/windows/embedder.h", + ] + } + # TODO: Add add common files to Windows build. Requires jsoncpp. Waiting on #161 + if (is_linux) { sources += [ "common/internal/engine_method_result.cc", "common/internal/engine_method_result.h", @@ -57,7 +66,8 @@ published_shared_library("flutter_embedder") { ] } # GLFW-specific code. - if (is_linux || is_win) { + # TODO: Add add glfw files to Windows build. Requires jsoncpp. Waiting on #161 + if (is_linux) { sources += [ "common/glfw/key_event_handler.cc", "common/glfw/key_event_handler.h", @@ -67,15 +77,6 @@ published_shared_library("flutter_embedder") { ] } - if (is_win) { - sources = [ - "windows/src/embedder.cpp", - ] - public = [ - "windows/include/flutter_desktop_embedding/embedder.h", - ] - } - deps = [ ":fetch_flutter_engine", ] @@ -91,7 +92,7 @@ published_shared_library("flutter_embedder") { deps += [ "//library/linux:publish_flutter_engine", ] - + configs += [ "//build/linux/config:epoxy", "//build/linux/config:gtk3", @@ -120,9 +121,9 @@ published_shared_library("flutter_embedder") { ] configs += [ - "//build/win/config:glfw3" + "//build/win/config:glfw3", ] - + public_configs = [ "//library/windows:relative_public_headers", "//library/windows:relative_dependency_headers", diff --git a/library/windows/include/flutter_desktop_embedding/embedder.h b/library/include/flutter_desktop_embedding/windows/embedder.h similarity index 99% rename from library/windows/include/flutter_desktop_embedding/embedder.h rename to library/include/flutter_desktop_embedding/windows/embedder.h index bd5dd13a8..2f086028f 100644 --- a/library/windows/include/flutter_desktop_embedding/embedder.h +++ b/library/include/flutter_desktop_embedding/windows/embedder.h @@ -19,7 +19,7 @@ #include #include -#include +#include namespace flutter_desktop_embedding { diff --git a/library/windows/BUILD.gn b/library/windows/BUILD.gn index bfdcbf25f..1c4186a56 100644 --- a/library/windows/BUILD.gn +++ b/library/windows/BUILD.gn @@ -20,7 +20,7 @@ import("//library/windows/glfw.gni") # inculdes for its header rather than project-relative. config("relative_public_headers") { include_dirs = [ - "include", + "../include", ] } @@ -33,7 +33,7 @@ action("fetch_glfw") { } config("relative_dependency_headers") { - include_dirs = [ glfw_download_dir ] + include_dirs = [ glfw_include_dir ] lib_dirs = [ glfw_download_dir ] } diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index 4cad50ef0..6e32e97b8 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -75,7 +75,7 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) + $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) @@ -265,7 +265,7 @@ - + diff --git a/library/windows/GLFW Library.vcxproj.filters b/library/windows/GLFW Library.vcxproj.filters index 41584ddd8..b2833c540 100644 --- a/library/windows/GLFW Library.vcxproj.filters +++ b/library/windows/GLFW Library.vcxproj.filters @@ -25,7 +25,7 @@ - + Header Files diff --git a/library/windows/glfw.gni b/library/windows/glfw.gni index 413e9896a..1d5ec0968 100644 --- a/library/windows/glfw.gni +++ b/library/windows/glfw.gni @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -glfw_download_dir = "$root_gen_dir/glfw" +glfw_include_dir = "$root_gen_dir/glfw" +glfw_download_dir = "$glfw_include_dir/GLFW" glfw_files = [ "$glfw_download_dir/glfw3.lib", diff --git a/library/windows/scripts/get_GLFW.bat b/library/windows/scripts/get_GLFW.bat index 0ac0f8925..13e7079ea 100644 --- a/library/windows/scripts/get_GLFW.bat +++ b/library/windows/scripts/get_GLFW.bat @@ -12,26 +12,5 @@ :: See the License for the specific language governing permissions and :: limitations under the License. @echo off - -cd %~dp0..\dependencies\GLFW\ - -:: Check that GLFW isn't already setup. -set EXISTS=true -if not exist glfw3.h set EXISTS=false -if not exist glfw3.lib set EXISTS=false - -if %EXISTS%==false ( - :: Download zip folder with correct TLS version. - PowerShell -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri http://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.bin.WIN64.zip -OutFile GLFW.zip" - - :: Expand folder. - PowerShell -NoProfile -ExecutionPolicy Bypass -Command "Expand-Archive GLFW.zip -DestinationPath GLFW" - - :: Copy required files into GLFW directory. - COPY GLFW\glfw-3.2.1.bin.WIN64\include\GLFW\glfw3.h >NUL - COPY GLFW\glfw-3.2.1.bin.WIN64\lib-vc2015\glfw3.lib >NUL - - :: Cleanup. - DEL GLFW.zip - RD /S /Q GLFW -) \ No newline at end of file +for /f "delims=" %%i in ('%~dp0..\..\..\tools\flutter_location') do set FLUTTER_DIR=%%i +%FLUTTER_DIR%\bin\cache\dart-sdk\bin\dart %~dp0..\..\..\tools\dart_tools\bin\fetch_glfw.dart %~dp0..\dependencies\GLFW \ No newline at end of file diff --git a/library/windows/src/embedder.cpp b/library/windows/src/embedder.cpp index 28c54ecdf..4245547e1 100644 --- a/library/windows/src/embedder.cpp +++ b/library/windows/src/embedder.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include #include #include From 01edbecfde5f336f5ae26e10c469946f12fc7e33 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Mon, 31 Dec 2018 19:13:01 +1300 Subject: [PATCH 05/17] Remove unnecessary libraries --- build/win/config/BUILD.gn | 8 -------- 1 file changed, 8 deletions(-) diff --git a/build/win/config/BUILD.gn b/build/win/config/BUILD.gn index 6ebed7890..f5512a322 100644 --- a/build/win/config/BUILD.gn +++ b/build/win/config/BUILD.gn @@ -19,14 +19,6 @@ config("glfw3") { "user32.lib", "gdi32.lib", - "winspool.lib", - "comdlg32.lib", - "advapi32.lib", "shell32.lib", - "ole32.lib", - "oleaut32.lib", - "uuid.lib", - "odbc32.lib", - "odbccp32.lib", ] } \ No newline at end of file From 34195794569fd74fed434991be5e0e0716d2ea2a Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Mon, 31 Dec 2018 19:32:45 +1300 Subject: [PATCH 06/17] Format fix --- build/BUILD.gn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/BUILD.gn b/build/BUILD.gn index 97264e417..683b23e80 100644 --- a/build/BUILD.gn +++ b/build/BUILD.gn @@ -13,7 +13,7 @@ # limitations under the License. config("defaults") { - if(is_linux) { + if (is_linux) { cflags = [ "-std=c++14", "-Wall", @@ -21,7 +21,7 @@ config("defaults") { "-pthread", ] } - if(is_win) { + if (is_win) { cflags = [ "/EHsc", ] @@ -32,7 +32,7 @@ config("defaults") { } config("shared_library_defaults") { - if(is_linux) { + if (is_linux) { cflags = [ "-shared", "-fPIC", From 027eaf91a7cf4ee9be6412af2b5cc70d23aa0619 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Tue, 1 Jan 2019 11:50:10 +1300 Subject: [PATCH 07/17] PR Feedback --- build/packaging.gni | 24 +++++++++++++----------- library/BUILD.gn | 19 +++++++++++++------ library/engine.gni | 4 ++-- library/linux/BUILD.gn | 12 ++---------- library/windows/BUILD.gn | 12 ++---------- 5 files changed, 32 insertions(+), 39 deletions(-) diff --git a/build/packaging.gni b/build/packaging.gni index 56b647b67..ffb3984cf 100644 --- a/build/packaging.gni +++ b/build/packaging.gni @@ -38,19 +38,21 @@ template("copy_includes") { template("published_shared_library") { template_target_name = target_name - copy_includes("_publish_${template_target_name}_headers") { - sources = invoker.public - subdir = invoker.public_header_subdir - } + if (is_linux || is_win) { + copy_includes("_publish_${template_target_name}_headers") { + sources = invoker.public + subdir = invoker.public_header_subdir + } - shared_library(template_target_name) { - forward_variables_from(invoker, "*") - assert(defined(public), - "|public| must be provided for published_shared_library.") + shared_library(template_target_name) { + forward_variables_from(invoker, "*") + assert(defined(public), + "|public| must be provided for published_shared_library.") - if (!defined(deps)) { - deps = [] + if (!defined(deps)) { + deps = [] + } + deps += [ ":_publish_${template_target_name}_headers" ] } - deps += [ ":_publish_${template_target_name}_headers" ] } } diff --git a/library/BUILD.gn b/library/BUILD.gn index dca1582bf..73c3b8263 100644 --- a/library/BUILD.gn +++ b/library/BUILD.gn @@ -83,6 +83,10 @@ published_shared_library("flutter_embedder") { public_header_subdir = "flutter_desktop_embedding" + public_configs = [ + ":relative_public_headers", + ] + if (is_linux) { libs = [ "glfw", @@ -99,10 +103,6 @@ published_shared_library("flutter_embedder") { "//build/linux/config:jsoncpp", "//build/linux/config:x11", ] - - public_configs = [ - "//library/linux:relative_public_headers", - ] } if (is_win) { @@ -124,13 +124,20 @@ published_shared_library("flutter_embedder") { "//build/win/config:glfw3", ] - public_configs = [ - "//library/windows:relative_public_headers", + public_configs += [ "//library/windows:relative_dependency_headers", ] } } +# Allows targets depending on this library to use library-style +# inculdes for its header rather than project-relative. +config("relative_public_headers") { + include_dirs = [ + "include", + ] +} + # Allows targets depending on the engine library to use library-style # inculdes for its header rather than project-relative. config("relative_engine_headers") { diff --git a/library/engine.gni b/library/engine.gni index 12892316b..59ff17546 100644 --- a/library/engine.gni +++ b/library/engine.gni @@ -18,15 +18,15 @@ engine_download_dir = "$root_gen_dir/flutter_engine" # The files that make up the downloaded engine library on Linux. if (is_linux) { engine_files = [ - "$engine_download_dir/libflutter_engine.so", "$engine_download_dir/flutter_embedder.h", + "$engine_download_dir/libflutter_engine.so", ] } if(is_win) { engine_files = [ - "$engine_download_dir/flutter_engine.dll", "$engine_download_dir/flutter_embedder.h", + "$engine_download_dir/flutter_engine.dll", "$engine_download_dir/flutter_engine.dll.lib", "$engine_download_dir/flutter_engine.dll.exp", "$engine_download_dir/flutter_engine.dll.pdb", diff --git a/library/linux/BUILD.gn b/library/linux/BUILD.gn index 6b049638c..ee88df121 100644 --- a/library/linux/BUILD.gn +++ b/library/linux/BUILD.gn @@ -15,16 +15,8 @@ import("//build/packaging.gni") import("//library/engine.gni") -# Allows targets depending on this library to use library-style -# inculdes for its header rather than project-relative. -config("relative_public_headers") { - include_dirs = [ - "../include" - ] -} - copy_includes("_publish_engine_headers") { - sources = [ engine_files[1] ] + sources = [ engine_files[0] ] deps = [ "//library:fetch_flutter_engine" ] } @@ -32,7 +24,7 @@ copy_includes("_publish_engine_headers") { # output directory where built libraries go, so that it doesn't require # special link handling, and publishes its header. copy("publish_flutter_engine") { - sources = [ engine_files[0] ] + sources = [ engine_files[1] ] outputs = [ "$root_out_dir/{{source_file_part}}" ] deps = [ ":_publish_engine_headers", diff --git a/library/windows/BUILD.gn b/library/windows/BUILD.gn index 1c4186a56..954ed468d 100644 --- a/library/windows/BUILD.gn +++ b/library/windows/BUILD.gn @@ -16,14 +16,6 @@ import("//build/packaging.gni") import("//library/engine.gni") import("//library/windows/glfw.gni") -# Allows targets depending on this library to use library-style -# inculdes for its header rather than project-relative. -config("relative_public_headers") { - include_dirs = [ - "../include", - ] -} - action("fetch_glfw") { script = "//tools/dart_tools/bin/fetch_glfw.dart" outputs = glfw_files @@ -38,7 +30,7 @@ config("relative_dependency_headers") { } copy_includes("_publish_engine_headers") { - sources = [ engine_files[1] ] + sources = [ engine_files[0] ] deps = [ "//library:fetch_flutter_engine" ] } @@ -47,7 +39,7 @@ copy_includes("_publish_engine_headers") { # special link handling, and publishes its header. copy("publish_flutter_engine") { sources = [ - engine_files[0], + engine_files[1], engine_files[2], engine_files[3], engine_files[4], From 4eb657edd642be6407de8490f5ee964ee5f83b95 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Tue, 1 Jan 2019 11:53:17 +1300 Subject: [PATCH 08/17] Format fix --- library/engine.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/engine.gni b/library/engine.gni index 59ff17546..8db14add8 100644 --- a/library/engine.gni +++ b/library/engine.gni @@ -23,7 +23,7 @@ if (is_linux) { ] } -if(is_win) { +if (is_win) { engine_files = [ "$engine_download_dir/flutter_embedder.h", "$engine_download_dir/flutter_engine.dll", From 79408bb93203e2bf22cdf9d6d570dee7a43f1533 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Wed, 2 Jan 2019 10:42:49 +1300 Subject: [PATCH 09/17] [Windows] [GN] Post #161 --- build/win/config/BUILD.gn | 11 +- example/windows/Example Embedder.sln | 18 +-- example/windows/GLFW Example.vcxproj | 104 +------------- library/BUILD.gn | 8 +- library/GN.md | 4 +- .../windows/embedder.h | 13 +- library/windows/BUILD.gn | 19 ++- library/windows/Flutter Windows Embedder.sln | 6 - library/windows/GLFW Library.vcxproj | 136 +----------------- library/windows/GLFW Library.vcxproj.filters | 38 ++++- library/windows/dependencies/.gitignore | 9 +- library/windows/glfw.gni | 3 +- library/windows/jsoncpp.gni | 23 +++ library/windows/scripts/build_jsonlib.bat | 93 +----------- library/windows/src/embedder.cpp | 131 ++++++++++++++--- tools/dart_tools/bin/build_jsoncpp.dart | 77 ++++++++++ tools/dart_tools/bin/fetch_glfw.dart | 19 ++- 17 files changed, 324 insertions(+), 388 deletions(-) create mode 100644 library/windows/jsoncpp.gni create mode 100644 tools/dart_tools/bin/build_jsoncpp.dart diff --git a/build/win/config/BUILD.gn b/build/win/config/BUILD.gn index f5512a322..546e4d9a4 100644 --- a/build/win/config/BUILD.gn +++ b/build/win/config/BUILD.gn @@ -12,13 +12,22 @@ # 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 = [ - "glfw3.lib", + "$glfw_lib_name", "opengl32.lib", "user32.lib", "gdi32.lib", "shell32.lib", ] +} + +config("jsoncpp") { + libs = [ + "$jsoncpp_lib_name", + ] } \ No newline at end of file diff --git a/example/windows/Example Embedder.sln b/example/windows/Example Embedder.sln index b42884e01..82fba6fd0 100644 --- a/example/windows/Example Embedder.sln +++ b/example/windows/Example Embedder.sln @@ -13,27 +13,17 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Dynamic Library|x64 = Debug Dynamic Library|x64 - Debug Static Library|x64 = Debug Static Library|x64 Release Dynamic Library|x64 = Release Dynamic Library|x64 - Release Static Library|x64 = Release Static Library|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Dynamic Library|x64.ActiveCfg = Debug Dynamic Library|x64 - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Dynamic Library|x64.Build.0 = Debug Dynamic Library|x64 - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Static Library|x64.ActiveCfg = Debug Static Library|x64 - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Static Library|x64.Build.0 = Debug Static Library|x64 - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Dynamic Library|x64.ActiveCfg = Release Dynamic Library|x64 - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Dynamic Library|x64.Build.0 = Release Dynamic Library|x64 - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Static Library|x64.ActiveCfg = Release Static Library|x64 - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Static Library|x64.Build.0 = Release Static Library|x64 {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug Dynamic Library|x64.ActiveCfg = Debug Dynamic Library|x64 {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug Dynamic Library|x64.Build.0 = Debug Dynamic Library|x64 - {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug Static Library|x64.ActiveCfg = Debug Static Library|x64 - {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug Static Library|x64.Build.0 = Debug Static Library|x64 {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release Dynamic Library|x64.ActiveCfg = Release Dynamic Library|x64 {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release Dynamic Library|x64.Build.0 = Release Dynamic Library|x64 - {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release Static Library|x64.ActiveCfg = Release Static Library|x64 - {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release Static Library|x64.Build.0 = Release Static Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Dynamic Library|x64.ActiveCfg = Debug Dynamic Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Dynamic Library|x64.Build.0 = Debug Dynamic Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Dynamic Library|x64.ActiveCfg = Release Dynamic Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Dynamic Library|x64.Build.0 = Release Dynamic Library|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/example/windows/GLFW Example.vcxproj b/example/windows/GLFW Example.vcxproj index 25a831fd8..a6f2de880 100644 --- a/example/windows/GLFW Example.vcxproj +++ b/example/windows/GLFW Example.vcxproj @@ -1,18 +1,10 @@ - - Debug Static Library - x64 - Debug Dynamic Library x64 - - Release Static Library - x64 - Release Dynamic Library x64 @@ -31,12 +23,6 @@ v141 MultiByte - - Application - true - v141 - MultiByte - Application false @@ -44,13 +30,6 @@ true MultiByte - - Application - false - v141 - true - MultiByte - @@ -59,15 +38,9 @@ - - - - - - $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ @@ -75,22 +48,10 @@ $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\library\include\;$(IncludePath) $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) - - $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\include\;$(IncludePath) - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) - $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\include\;$(IncludePath) - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) - - - $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\include\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\library\include\;$(IncludePath) $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) @@ -101,6 +62,7 @@ true + _DEBUG;_MBCS;%(PreprocessorDefinitions) flutter_embedder.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) @@ -120,35 +82,6 @@ Copy flutter_embedder.dll from library out to example out dir - - - Level3 - Disabled - true - true - - - - - flutter_embedder.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) - - - $(ProjectDir)scripts\build_example_app - Build the example app - - - xcopy /y /d /q "$(OutputPath)..\GLFW Library\flutter_engine.dll" "$(OutputPath)" - Get the flutter_engine.dll file from GLFW Library bin folder - - - - - - - - - - Level3 @@ -180,39 +113,6 @@ Copy flutter_embedder.dll from library out to example out dir - - - Level3 - MaxSpeed - true - true - true - true - - - - - true - true - flutter_embedder.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) - - - $(ProjectDir)scripts\build_example_app - Build the example app - - - xcopy /y /d /q "$(OutputPath)..\GLFW Library\flutter_engine.dll" "$(OutputPath)" - Get the flutter_engine.dll file from GLFW Library bin folder - - - - - - - - - - diff --git a/library/BUILD.gn b/library/BUILD.gn index 73c3b8263..7b1f5bead 100644 --- a/library/BUILD.gn +++ b/library/BUILD.gn @@ -33,8 +33,7 @@ published_shared_library("flutter_embedder") { "include/flutter_desktop_embedding/windows/embedder.h", ] } - # TODO: Add add common files to Windows build. Requires jsoncpp. Waiting on #161 - if (is_linux) { + if (is_linux || is_win) { sources += [ "common/internal/engine_method_result.cc", "common/internal/engine_method_result.h", @@ -66,8 +65,7 @@ published_shared_library("flutter_embedder") { ] } # GLFW-specific code. - # TODO: Add add glfw files to Windows build. Requires jsoncpp. Waiting on #161 - if (is_linux) { + if (is_linux || is_win) { sources += [ "common/glfw/key_event_handler.cc", "common/glfw/key_event_handler.h", @@ -114,6 +112,7 @@ published_shared_library("flutter_embedder") { deps += [ "//library/windows:publish_flutter_engine", "//library/windows:fetch_glfw", + "//library/windows:build_jsoncpp", ] libs = [ @@ -122,6 +121,7 @@ published_shared_library("flutter_embedder") { configs += [ "//build/win/config:glfw3", + "//build/win/config:jsoncpp", ] public_configs += [ diff --git a/library/GN.md b/library/GN.md index fb6810048..626e931bb 100644 --- a/library/GN.md +++ b/library/GN.md @@ -18,13 +18,13 @@ Windows also requires the 64 bit compiler, linker and setup scripts to be in your path. They are found under: ``` -Visual Studio Install Path\VC\bin\amd64 +Visual Studio Install Path\2017\Version\VC\Auxiliary\Build ``` e.g.: ``` -C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64 +C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build ``` ## Building diff --git a/library/include/flutter_desktop_embedding/windows/embedder.h b/library/include/flutter_desktop_embedding/windows/embedder.h index 2f086028f..9d29190b3 100644 --- a/library/include/flutter_desktop_embedding/windows/embedder.h +++ b/library/include/flutter_desktop_embedding/windows/embedder.h @@ -15,12 +15,13 @@ #ifndef WINDOWS_LIBRARY_EMBEDDER_H_ #define WINDOWS_LIBRARY_EMBEDDER_H_ -#include #include #include #include +#include + namespace flutter_desktop_embedding { // Calls glfwInit() @@ -68,6 +69,12 @@ GLFWwindow *CreateFlutterWindowInSnapshotMode( const std::string &icu_data_path, const std::vector &arguments); +// Adds a plugin to the flutter_window. +// +// If a plugin already exists for this plugin's channel, returns false. +// Otherwise returns true. +bool AddPlugin(GLFWwindow *flutter_window, std::unique_ptr plugin); + // Loops on flutter window events until termination. // // Must be used instead of glfwWindowShouldClose as it cleans up engine state @@ -77,6 +84,6 @@ GLFWwindow *CreateFlutterWindowInSnapshotMode( // cleanup. void FlutterWindowLoop(GLFWwindow *flutter_window); -#endif // WINDOWS_LIBRARY_EMBEDDER_H_ - } // namespace flutter_desktop_embedding + +#endif // WINDOWS_LIBRARY_EMBEDDER_H_ diff --git a/library/windows/BUILD.gn b/library/windows/BUILD.gn index 954ed468d..5e221dd46 100644 --- a/library/windows/BUILD.gn +++ b/library/windows/BUILD.gn @@ -15,6 +15,7 @@ import("//build/packaging.gni") import("//library/engine.gni") import("//library/windows/glfw.gni") +import("//library/windows/jsoncpp.gni") action("fetch_glfw") { script = "//tools/dart_tools/bin/fetch_glfw.dart" @@ -24,9 +25,23 @@ action("fetch_glfw") { ] } +action("build_jsoncpp") { + script = "//tools/dart_tools/bin/build_jsoncpp.dart" + outputs = jsoncpp_files + args = [ + rebase_path(jsoncpp_download_dir, root_build_dir) + ] +} + config("relative_dependency_headers") { - include_dirs = [ glfw_include_dir ] - lib_dirs = [ glfw_download_dir ] + include_dirs = [ + glfw_include_dir, + jsoncpp_include_dir, + ] + lib_dirs = [ + glfw_download_dir, + jsoncpp_lib_dir, + ] } copy_includes("_publish_engine_headers") { diff --git a/library/windows/Flutter Windows Embedder.sln b/library/windows/Flutter Windows Embedder.sln index aadfddeb4..221531a1e 100644 --- a/library/windows/Flutter Windows Embedder.sln +++ b/library/windows/Flutter Windows Embedder.sln @@ -8,19 +8,13 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Dynamic Library|x64 = Debug Dynamic Library|x64 - Debug Static Library|x64 = Debug Static Library|x64 Release Dynamic Library|x64 = Release Dynamic Library|x64 - Release Static Library|x64 = Release Static Library|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Dynamic Library|x64.ActiveCfg = Debug Dynamic Library|x64 {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Dynamic Library|x64.Build.0 = Debug Dynamic Library|x64 - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Static Library|x64.ActiveCfg = Debug Static Library|x64 - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Static Library|x64.Build.0 = Debug Static Library|x64 {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Dynamic Library|x64.ActiveCfg = Release Dynamic Library|x64 {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Dynamic Library|x64.Build.0 = Release Dynamic Library|x64 - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Static Library|x64.ActiveCfg = Release Static Library|x64 - {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Static Library|x64.Build.0 = Release Static Library|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index 0086b0aa1..fa7850bcc 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -1,18 +1,10 @@ - - Debug Static Library - x64 - Debug Dynamic Library x64 - - Release Static Library - x64 - Release Dynamic Library x64 @@ -32,12 +24,6 @@ v141 MultiByte - - StaticLibrary - true - v141 - MultiByte - DynamicLibrary false @@ -45,13 +31,6 @@ true MultiByte - - StaticLibrary - false - v141 - true - MultiByte - @@ -60,15 +39,9 @@ - - - - - - $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ @@ -77,35 +50,19 @@ .dll $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)third_party\jsoncpp\include;$(ProjectDir)..\..\;$(IncludePath) - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\x64\debug;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) + $(ProjectDir)dependencies\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\include\;$(ProjectDir)..\..\;$(ProjectDir)..\include\;$(IncludePath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\makefiles\msvc2017\x64\debug;$(LibraryPath) $(ProjectDir)..\..\library\common\internal;$(SourcePath) - - $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - flutter_embedder - .lib - $(ProjectDir)include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) - $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)third_party\jsoncpp\include;$(ProjectDir)..\..\;$(IncludePath) - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\x64\release;;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) + $(ProjectDir)dependencies\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\include;$(ProjectDir)..\..\;$(ProjectDir)..\include\;$(IncludePath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\makefiles\msvc2017\x64\release;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) $(ProjectDir)..\..\library\common\internal;$(SourcePath) - - $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ - $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - flutter_embedder - .lib - $(ProjectDir)include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) - Level3 @@ -128,46 +85,8 @@ - $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW && $(ProjectDir)scripts\build_jsonlib - Get the flutter engine, engine artifacts and GLFW - - - - - - - - - flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) - - - xcopy /y /d /q "$(ProjectDir)dependencies\engine\flutter_engine.dll" "$(OutputPath)" - Add flutter_engine.dll to the out dir - - - - - Level3 - Disabled - true - true - - - flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) - - - exports.def - $(OutDir)$(TargetName)$(TargetExt) - $(OutDir)$(TargetName).dll.lib - $(OutDir)$(TargetName).dll.pdb - - - - - - - $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW - Get the flutter engine, engine artifacts and GLFW + $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW && $(ProjectDir)scripts\build_jsonlib --debug + Get the flutter engine, engine artifacts, GLFW and jsoncpp @@ -208,47 +127,7 @@ $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW && $(ProjectDir)scripts\build_jsonlib - Get the flutter engine, engine artifacts and GLFW - - - - - - - - - flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) - - - xcopy /y /d /q "$(ProjectDir)dependencies\engine\flutter_engine.dll" "$(OutputPath)" - Add flutter_engine.dll to the out dir - - - - - Level3 - MaxSpeed - true - true - true - true - - - true - true - flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) - exports.def - $(OutDir)$(TargetName)$(TargetExt) - $(OutDir)$(TargetName).dll.lib - $(OutDir)$(TargetName).dll.pdb - - - - - - - $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW - Get the flutter engine, engine artifacts and GLFW + Get the flutter engine, engine artifacts, GLFW and jsoncpp @@ -279,7 +158,6 @@ - diff --git a/library/windows/GLFW Library.vcxproj.filters b/library/windows/GLFW Library.vcxproj.filters index 3bc9a9c0f..cd2ce51a0 100644 --- a/library/windows/GLFW Library.vcxproj.filters +++ b/library/windows/GLFW Library.vcxproj.filters @@ -26,10 +26,46 @@ Source Files + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + Header Files - + \ No newline at end of file diff --git a/library/windows/dependencies/.gitignore b/library/windows/dependencies/.gitignore index 7f1435b47..eb7a86f0c 100644 --- a/library/windows/dependencies/.gitignore +++ b/library/windows/dependencies/.gitignore @@ -1,6 +1,3 @@ -flutter_embedder.h -flutter_engine.* -.last_engine_version -icudtl.dat -glfw3.* -json +engine +GLFW +JSON diff --git a/library/windows/glfw.gni b/library/windows/glfw.gni index 1d5ec0968..0a4f60f18 100644 --- a/library/windows/glfw.gni +++ b/library/windows/glfw.gni @@ -14,8 +14,9 @@ glfw_include_dir = "$root_gen_dir/glfw" glfw_download_dir = "$glfw_include_dir/GLFW" +glfw_lib_name = "glfw3.lib" glfw_files = [ - "$glfw_download_dir/glfw3.lib", "$glfw_download_dir/glfw3.h", + "$glfw_download_dir/$glfw_lib_name", ] \ No newline at end of file diff --git a/library/windows/jsoncpp.gni b/library/windows/jsoncpp.gni new file mode 100644 index 000000000..f34018a3f --- /dev/null +++ b/library/windows/jsoncpp.gni @@ -0,0 +1,23 @@ +# 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. + +jsoncpp_download_dir = "$root_gen_dir/json" +jsoncpp_include_dir = "$jsoncpp_download_dir/include" +jsoncpp_lib_dir = "$jsoncpp_download_dir/makefiles/msvc2017/x64/Release" +jsoncpp_lib_name = "json_vc71_libmt.lib" + +jsoncpp_files = [ + "$jsoncpp_include_dir/json/json.h", + "$jsoncpp_lib_dir/$jsoncpp_lib_name", +] \ No newline at end of file diff --git a/library/windows/scripts/build_jsonlib.bat b/library/windows/scripts/build_jsonlib.bat index 17f663456..29f53d8dd 100644 --- a/library/windows/scripts/build_jsonlib.bat +++ b/library/windows/scripts/build_jsonlib.bat @@ -12,94 +12,5 @@ :: See the License for the specific language governing permissions and :: limitations under the License. @echo off - -:: Find where VS lives and start a VC command prompt -set pre=Microsoft.VisualStudio.Product. -set ids=%pre%Community %pre%Professional %pre%Enterprise %pre%BuildTools - -pushd "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" -for /f "usebackq tokens=1* delims=: " %%i in (`vswhere -latest -products *`) do (if /i "%%i"=="installationPath" set InstallDir=%%j) -popd - -pushd %InstallDir%\VC\Auxiliary\Build -call vcvarsall.bat x86_amd64 -popd - -set JSONDEBUGLIBEXISTS=true -if not exist %~dp0..\dependencies\json\x64\debug\json_vc71_libmtd.lib set JSONDEBUGLIBEXISTS=false - -set JSONRELEASELIBEXISTS=true -if not exist %~dp0..\dependencies\json\x64\release\json_vc71_libmt.lib set JSONRELEASELIBEXISTS=false - -if %JSONDEBUGLIBEXISTS% == true ( - if %JSONRELEASELIBEXISTS% == true ( - echo jsoncpp found. - goto DONE - ) -) - -set THIRDPARTYDIREXISTS=true -if not exist %~dp0..\third_party set THIRDPARTYDIREXISTS=false - -if %THIRDPARTYDIREXISTS% == false ( - mkdir %~dp0..\third_party -) - -set JSONDIREXISTS=true -if not exist %~dp0..\third_party\jsoncpp set JSONDIREXISTS=false - -if %JSONDIREXISTS% == false ( - mkdir %~dp0..\third_party\jsoncpp -) - -set JSONEXISTS=true -if not exist %~dp0..\third_party\jsoncpp\README.md set JSONEXISTS=false - -:: Clone source -if %JSONEXISTS% == false ( - :: PR opened on json cpp for VS2017 support: https://github.com/open-source-parsers/jsoncpp/pull/853 - echo Cloning via git clone --branch supportvs2017 https://github.com/clarkezone/jsoncpp.git %~dp0..\third_party\jsoncpp - call git clone --branch supportvs2017 https://github.com/clarkezone/jsoncpp.git %~dp0..\third_party\jsoncpp - - pushd %~dp0..\third_party\jsoncpp - - call git checkout 3ae7e8073a425c93329c8577a3c813c206322ca4 - - popd -) - -:: Build debug lib -echo Building debug lib: msbuild %~dp0..\third_party\jsoncpp\makefiles\msvc2017\lib_json.vcxproj -msbuild %~dp0..\third_party\jsoncpp\makefiles\msvc2017\lib_json.vcxproj - -set DEPBINDIREXISTS=true -if not exist %~dp0..\dependencies\json\x64 set DEPBINDIREXISTS=false - -if %DEPBINDIREXISTS% == false ( - mkdir %~dp0..\dependencies\json\x64 -) - -set DEPBINDBGDIREXISTS=true -if not exist %~dp0..\dependencies\json\x64\debug set DEPBINDBGDIREXISTS=false - -if %DEPBINDBGDIREXISTS% == false ( - mkdir %~dp0..\dependencies\json\x64\debug -) - -copy %~dp0..\third_party\jsoncpp\makefiles\msvc2017\x64\debug\json_vc71_libmtd.lib %~dp0..\dependencies\json\x64\debug\. - -:: Build release lib -echo Building release lib: msbuild %~dp0..\third_party\jsoncpp\makefiles\msvc2017\lib_json.vcxproj /p:Configuration=Release -msbuild %~dp0..\third_party\jsoncpp\makefiles\msvc2017\lib_json.vcxproj /p:Configuration=Release - -set DEPBINRELDIREXISTS=true -if not exist %~dp0..\dependencies\json\x64\release set DEPBINRELDIREXISTS=false - -if %DEPBINRELDIREXISTS% == false ( - mkdir %~dp0..\dependencies\json\x64\release -) - -copy %~dp0..\third_party\jsoncpp\makefiles\msvc2017\x64\release\json_vc71_libmt.lib %~dp0..\dependencies\json\x64\release\. - -:DONE -echo jsoncpplib complete. \ No newline at end of file +for /f "delims=" %%i in ('%~dp0..\..\..\tools\flutter_location') do set FLUTTER_DIR=%%i +%FLUTTER_DIR%\bin\cache\dart-sdk\bin\dart %~dp0..\..\..\tools\dart_tools\bin\build_jsoncpp.dart %~dp0..\dependencies\JSON %* \ No newline at end of file diff --git a/library/windows/src/embedder.cpp b/library/windows/src/embedder.cpp index 4245547e1..58b811441 100644 --- a/library/windows/src/embedder.cpp +++ b/library/windows/src/embedder.cpp @@ -21,10 +21,33 @@ #include +#include "library/common/glfw/keyboard_hook_handler.h" +#include "library/common/glfw/text_input_plugin.h" +#include "library/common/internal/plugin_handler.h" + static_assert(FLUTTER_ENGINE_VERSION == 1, ""); +// Struct for storing state within an instance of the GLFW Window. +struct FlutterEmbedderState { + FlutterEngine engine; + std::unique_ptr plugin_handler; + + // plugin_handler owns these pointers. Destruction happens when this struct is + // deleted from the heap. + std::vector + keyboard_hook_handlers; +}; + static constexpr char kDefaultWindowTitle[] = "Flutter"; +// Retreaves state bag for the window in question from the GLFWWindow +static FlutterEmbedderState *GetSavedEmbedderState(GLFWwindow *window) { + return reinterpret_cast( + glfwGetWindowUserPointer(window)); +} + +// When GLFW calls back to the window with a cursor position move, forward to +// FlutterEngine as a pointer event with appropriate phase static void GLFWcursorPositionCallbackAtPhase(GLFWwindow *window, FlutterPointerPhase phase, double x, double y) { @@ -37,11 +60,11 @@ static void GLFWcursorPositionCallbackAtPhase(GLFWwindow *window, std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch()) .count(); - FlutterEngineSendPointerEvent( - reinterpret_cast(glfwGetWindowUserPointer(window)), &event, - 1); + FlutterEngineSendPointerEvent(GetSavedEmbedderState(window)->engine, &event, + 1); } +// Report cursor move to engine static void GLFWcursorPositionCallback(GLFWwindow *window, double x, double y) { GLFWcursorPositionCallbackAtPhase(window, FlutterPointerPhase::kMove, x, y); } @@ -61,8 +84,19 @@ static void GLFWmouseButtonCallback(GLFWwindow *window, int key, int action, } } +static void GLFWCharCallback(GLFWwindow *window, unsigned int code_point) { + for (flutter_desktop_embedding::KeyboardHookHandler *handler : + GetSavedEmbedderState(window)->keyboard_hook_handlers) { + handler->CharHook(window, code_point); + } +} + static void GLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { + for (flutter_desktop_embedding::KeyboardHookHandler *handler : + GetSavedEmbedderState(window)->keyboard_hook_handlers) { + handler->KeyboardHook(window, key, scancode, action, mods); + } if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) { glfwSetWindowShouldClose(window, GLFW_TRUE); } @@ -75,9 +109,41 @@ static void GLFWwindowSizeCallback(GLFWwindow *window, int width, int height) { event.height = height; // TODO: Handle pixel ratio for different DPI monitors. event.pixel_ratio = 1.0; - FlutterEngineSendWindowMetricsEvent( - reinterpret_cast(glfwGetWindowUserPointer(window)), - &event); + FlutterEngineSendWindowMetricsEvent(GetSavedEmbedderState(window)->engine, + &event); +} + +// Flushes event queue and then assigns default window callbacks. +static void GLFWAssignEventCallbacks(GLFWwindow *window) { + glfwPollEvents(); + glfwSetKeyCallback(window, GLFWKeyCallback); + glfwSetCharCallback(window, GLFWCharCallback); + glfwSetMouseButtonCallback(window, GLFWmouseButtonCallback); +} + +// Clears default window events. +static void GLFWClearEventCallbacks(GLFWwindow *window) { + glfwSetKeyCallback(window, nullptr); + glfwSetCharCallback(window, nullptr); + glfwSetMouseButtonCallback(window, nullptr); +} + +// The Flutter Engine calls out to this function when new platform messages are +// available +static void GLFWOnFlutterPlatformMessage(const FlutterPlatformMessage *message, + void *user_data) { + if (message->struct_size != sizeof(FlutterPlatformMessage)) { + std::cerr << "Invalid message size received. Expected: " + << sizeof(FlutterPlatformMessage) << " but received " + << message->struct_size << std::endl; + return; + } + + GLFWwindow *window = reinterpret_cast(user_data); + auto state = GetSavedEmbedderState(window); + state->plugin_handler->HandleMethodCallMessage( + message, [window] { GLFWClearEventCallbacks(window); }, + [window] { GLFWAssignEventCallbacks(window); }); } static bool GLFWMakeContextCurrent(void *user_data) { @@ -148,6 +214,7 @@ static FlutterEngine RunFlutterEngine( args.icu_data_path = icu_data_path.c_str(); args.command_line_argc = argv.size(); args.command_line_argv = &argv[0]; + args.platform_message_callback = GLFWOnFlutterPlatformMessage; FlutterEngine engine = nullptr; auto result = FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, &args, window, &engine); @@ -159,10 +226,26 @@ static FlutterEngine RunFlutterEngine( namespace flutter_desktop_embedding { +// Initialize glfw bool FlutterInit() { return glfwInit(); } +// Tear down glfw void FlutterTerminate() { glfwTerminate(); } +// set up embedder state and add the plugin to the plugin_handler +bool AddPlugin(GLFWwindow *flutter_window, std::unique_ptr plugin) { + auto state = GetSavedEmbedderState(flutter_window); + return state->plugin_handler->AddPlugin(std::move(plugin)); +} + +GLFWwindow *CreateFlutterWindowInSnapshotMode( + size_t initial_width, size_t initial_height, const std::string &assets_path, + const std::string &icu_data_path, + const std::vector &arguments) { + return CreateFlutterWindow(initial_width, initial_height, "", assets_path, "", + icu_data_path, arguments); +} + GLFWwindow *CreateFlutterWindow(size_t initial_width, size_t initial_height, const std::string &main_path, const std::string &assets_path, @@ -175,37 +258,43 @@ GLFWwindow *CreateFlutterWindow(size_t initial_width, size_t initial_height, return nullptr; } GLFWClearCanvas(window); - auto flutter_engine_run_result = RunFlutterEngine( - window, main_path, assets_path, packages_path, icu_data_path, arguments); - if (flutter_engine_run_result == nullptr) { + auto engine = RunFlutterEngine(window, main_path, assets_path, packages_path, + icu_data_path, arguments); + if (engine == nullptr) { glfwDestroyWindow(window); return nullptr; } - glfwSetWindowUserPointer(window, flutter_engine_run_result); + + FlutterEmbedderState *state = new FlutterEmbedderState(); + state->plugin_handler = std::make_unique(engine); + state->engine = engine; + auto input_plugin = std::make_unique(); + state->keyboard_hook_handlers.push_back(input_plugin.get()); + + glfwSetWindowUserPointer(window, state); + + AddPlugin(window, std::move(input_plugin)); + int width, height; glfwGetWindowSize(window, &width, &height); GLFWwindowSizeCallback(window, width, height); glfwSetKeyCallback(window, GLFWKeyCallback); glfwSetWindowSizeCallback(window, GLFWwindowSizeCallback); glfwSetMouseButtonCallback(window, GLFWmouseButtonCallback); + GLFWAssignEventCallbacks(window); return window; } -GLFWwindow *CreateFlutterWindowInSnapshotMode( - size_t initial_width, size_t initial_height, const std::string &assets_path, - const std::string &icu_data_path, - const std::vector &arguments) { - return CreateFlutterWindow(initial_width, initial_height, "", assets_path, "", - icu_data_path, arguments); -} - void FlutterWindowLoop(GLFWwindow *flutter_window) { while (!glfwWindowShouldClose(flutter_window)) { glfwWaitEvents(); + // TODO(awdavies): This will be deprecated soon. + __FlutterEngineFlushPendingTasksNow(); } - FlutterEngineShutdown(reinterpret_cast( - glfwGetWindowUserPointer(flutter_window))); + auto state = GetSavedEmbedderState(flutter_window); + FlutterEngineShutdown(state->engine); + delete state; glfwDestroyWindow(flutter_window); } -} // namespace flutter_desktop_embedder +} // namespace flutter_desktop_embedding diff --git a/tools/dart_tools/bin/build_jsoncpp.dart b/tools/dart_tools/bin/build_jsoncpp.dart new file mode 100644 index 000000000..db9ed6b0f --- /dev/null +++ b/tools/dart_tools/bin/build_jsoncpp.dart @@ -0,0 +1,77 @@ +// 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 'dart:io'; + +import 'package:args/args.dart'; + +Future main(List arguments) async { + if (!Platform.isWindows) { + throw new Exception('Building jsoncpp libraries is only available on ' + 'windows.'); + } + + final parser = new ArgParser() + ..addFlag('debug', abbr: 'd', negatable: false); + final args = parser.parse(arguments); + + final downloadDirectory = arguments[0]; + final debug = args['debug']; + + await Process.run('git', [ + 'init', + downloadDirectory, + ]); + + await Process.run( + 'git', + [ + 'remote', + 'add', + 'origin', + 'https://github.com/clarkezone/jsoncpp.git', + ], + workingDirectory: downloadDirectory); + + await Process.run( + 'git', + [ + 'fetch', + ], + workingDirectory: downloadDirectory); + + await Process.run( + 'git', + [ + 'checkout', + '3ae7e8073a425c93329c8577a3c813c206322ca4', + ], + workingDirectory: downloadDirectory); + + final jsoncppBuildProcess = await Process.run( + 'vcvars64.bat &&', + [ + 'msbuild', + 'lib_json.vcxproj', + !debug ? '/p:Configuration=Release' : '', + ], + workingDirectory: '$downloadDirectory/makefiles/msvc2017', + runInShell: true); + + if (jsoncppBuildProcess.exitCode != 0) { + print(jsoncppBuildProcess.stdout); + print(jsoncppBuildProcess.stderr); + throw new Exception('jsoncpp Build Failed'); + } +} diff --git a/tools/dart_tools/bin/fetch_glfw.dart b/tools/dart_tools/bin/fetch_glfw.dart index ab5552cbb..735f1ba06 100644 --- a/tools/dart_tools/bin/fetch_glfw.dart +++ b/tools/dart_tools/bin/fetch_glfw.dart @@ -33,6 +33,20 @@ Future main(List arguments) async { final outputDirectory = arguments[0]; + const Map requiredFiles = { + 'glfw-3.2.1.bin.WIN64/include/GLFW/glfw3.h': 'glfw3.h', + 'glfw-3.2.1.bin.WIN64/lib-vc2015/glfw3.lib': 'glfw3.lib', + }; + + int existingFiles = 0; + for (final file in requiredFiles.values) { + if (await File("$outputDirectory/$file").exists()) { + existingFiles++; + } + } + + if (existingFiles == requiredFiles.length) exit(0); + final archiveUri = Uri.parse(glfwArchiveUrlString); final httpClient = new HttpClient(); @@ -46,11 +60,6 @@ Future main(List arguments) async { await new Directory(outputDirectory).create(recursive: true); - const Map requiredFiles = { - 'glfw-3.2.1.bin.WIN64/include/GLFW/glfw3.h': 'glfw3.h', - 'glfw-3.2.1.bin.WIN64/lib-vc2015/glfw3.lib': 'glfw3.lib', - }; - final archive = new ZipDecoder().decodeBytes(archiveData); for (final file in archive) { if (!requiredFiles.containsKey(file.name)) { From 7c103088f4f09c99b528f64023b325af8457409c Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Wed, 2 Jan 2019 13:28:34 +1300 Subject: [PATCH 10/17] [Windows] [GN] Force debug build As per #192 --- build/win/toolchain/BUILD.gn | 4 ++-- library/windows/BUILD.gn | 5 +++-- library/windows/jsoncpp.gni | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/build/win/toolchain/BUILD.gn b/build/win/toolchain/BUILD.gn index 01de72ace..53469f00f 100644 --- a/build/win/toolchain/BUILD.gn +++ b/build/win/toolchain/BUILD.gn @@ -17,7 +17,7 @@ toolchain("msvc") { tool("cc") { pdbfile = "{{target_out_dir}}/{{label_name}}_c.pdb" - command = "$env_setup cl /nologo /showIncludes /MD /FC {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} /c {{source}} /Fo{{output}} /Fd$pdbfile" + 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 = [ @@ -27,7 +27,7 @@ toolchain("msvc") { tool("cxx") { pdbfile = "{{target_out_dir}}/{{label_name}}_c.pdb" - command = "$env_setup cl /nologo /showIncludes /MD /FC {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} /c {{source}} /Fo{{output}} /Fd$pdbfile" + 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 = [ diff --git a/library/windows/BUILD.gn b/library/windows/BUILD.gn index 5e221dd46..095006e80 100644 --- a/library/windows/BUILD.gn +++ b/library/windows/BUILD.gn @@ -21,7 +21,7 @@ action("fetch_glfw") { script = "//tools/dart_tools/bin/fetch_glfw.dart" outputs = glfw_files args = [ - rebase_path(glfw_download_dir, root_build_dir) + rebase_path(glfw_download_dir, root_build_dir), ] } @@ -29,7 +29,8 @@ action("build_jsoncpp") { script = "//tools/dart_tools/bin/build_jsoncpp.dart" outputs = jsoncpp_files args = [ - rebase_path(jsoncpp_download_dir, root_build_dir) + rebase_path(jsoncpp_download_dir, root_build_dir), + "--debug", ] } diff --git a/library/windows/jsoncpp.gni b/library/windows/jsoncpp.gni index f34018a3f..0a25c8886 100644 --- a/library/windows/jsoncpp.gni +++ b/library/windows/jsoncpp.gni @@ -14,8 +14,8 @@ jsoncpp_download_dir = "$root_gen_dir/json" jsoncpp_include_dir = "$jsoncpp_download_dir/include" -jsoncpp_lib_dir = "$jsoncpp_download_dir/makefiles/msvc2017/x64/Release" -jsoncpp_lib_name = "json_vc71_libmt.lib" +jsoncpp_lib_dir = "$jsoncpp_download_dir/makefiles/msvc2017/x64/Debug" +jsoncpp_lib_name = "json_vc71_libmtd.lib" jsoncpp_files = [ "$jsoncpp_include_dir/json/json.h", From 532ad74b9199c0e1663f4f98aa1db15e2678356c Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Wed, 2 Jan 2019 14:26:48 +1300 Subject: [PATCH 11/17] Revert Removal of VS Static Library Builds --- example/windows/Example Embedder.sln | 18 ++- example/windows/GLFW Example.vcxproj | 106 ++++++++++++++- library/windows/Flutter Windows Embedder.sln | 8 +- library/windows/GLFW Library.vcxproj | 132 ++++++++++++++++++- library/windows/GLFW Library.vcxproj.filters | 50 +------ 5 files changed, 258 insertions(+), 56 deletions(-) diff --git a/example/windows/Example Embedder.sln b/example/windows/Example Embedder.sln index 82fba6fd0..b42884e01 100644 --- a/example/windows/Example Embedder.sln +++ b/example/windows/Example Embedder.sln @@ -13,17 +13,27 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Dynamic Library|x64 = Debug Dynamic Library|x64 + Debug Static Library|x64 = Debug Static Library|x64 Release Dynamic Library|x64 = Release Dynamic Library|x64 + Release Static Library|x64 = Release Static Library|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug Dynamic Library|x64.ActiveCfg = Debug Dynamic Library|x64 - {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug Dynamic Library|x64.Build.0 = Debug Dynamic Library|x64 - {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release Dynamic Library|x64.ActiveCfg = Release Dynamic Library|x64 - {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release Dynamic Library|x64.Build.0 = Release Dynamic Library|x64 {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Dynamic Library|x64.ActiveCfg = Debug Dynamic Library|x64 {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Dynamic Library|x64.Build.0 = Debug Dynamic Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Static Library|x64.ActiveCfg = Debug Static Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Static Library|x64.Build.0 = Debug Static Library|x64 {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Dynamic Library|x64.ActiveCfg = Release Dynamic Library|x64 {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Dynamic Library|x64.Build.0 = Release Dynamic Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Static Library|x64.ActiveCfg = Release Static Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Static Library|x64.Build.0 = Release Static Library|x64 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug Dynamic Library|x64.ActiveCfg = Debug Dynamic Library|x64 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug Dynamic Library|x64.Build.0 = Debug Dynamic Library|x64 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug Static Library|x64.ActiveCfg = Debug Static Library|x64 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug Static Library|x64.Build.0 = Debug Static Library|x64 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release Dynamic Library|x64.ActiveCfg = Release Dynamic Library|x64 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release Dynamic Library|x64.Build.0 = Release Dynamic Library|x64 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release Static Library|x64.ActiveCfg = Release Static Library|x64 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release Static Library|x64.Build.0 = Release Static Library|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/example/windows/GLFW Example.vcxproj b/example/windows/GLFW Example.vcxproj index a6f2de880..cbabd717a 100644 --- a/example/windows/GLFW Example.vcxproj +++ b/example/windows/GLFW Example.vcxproj @@ -1,10 +1,18 @@ + + Debug Static Library + x64 + Debug Dynamic Library x64 + + Release Static Library + x64 + Release Dynamic Library x64 @@ -23,6 +31,12 @@ v141 MultiByte + + Application + true + v141 + MultiByte + Application false @@ -30,6 +44,13 @@ true MultiByte + + Application + false + v141 + true + MultiByte + @@ -38,20 +59,38 @@ + + + + + + $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\library\include\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\library\include\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) + + + $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ + $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath) $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\library\include\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\library\include\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) + + + $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ + $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath) $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) @@ -62,7 +101,6 @@ true - _DEBUG;_MBCS;%(PreprocessorDefinitions) flutter_embedder.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) @@ -82,6 +120,35 @@ Copy flutter_embedder.dll from library out to example out dir + + + Level3 + Disabled + true + true + + + + + flutter_embedder.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) + + + $(ProjectDir)scripts\build_example_app + Build the example app + + + xcopy /y /d /q "$(OutputPath)..\GLFW Library\flutter_engine.dll" "$(OutputPath)" + Get the flutter_engine.dll file from GLFW Library bin folder + + + + + + + + + + Level3 @@ -113,6 +180,39 @@ Copy flutter_embedder.dll from library out to example out dir + + + Level3 + MaxSpeed + true + true + true + true + + + + + true + true + flutter_embedder.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) + + + $(ProjectDir)scripts\build_example_app + Build the example app + + + xcopy /y /d /q "$(OutputPath)..\GLFW Library\flutter_engine.dll" "$(OutputPath)" + Get the flutter_engine.dll file from GLFW Library bin folder + + + + + + + + + + diff --git a/library/windows/Flutter Windows Embedder.sln b/library/windows/Flutter Windows Embedder.sln index 221531a1e..ea834c276 100644 --- a/library/windows/Flutter Windows Embedder.sln +++ b/library/windows/Flutter Windows Embedder.sln @@ -8,13 +8,19 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Dynamic Library|x64 = Debug Dynamic Library|x64 + Debug Static Library|x64 = Debug Static Library|x64 Release Dynamic Library|x64 = Release Dynamic Library|x64 + Release Static Library|x64 = Release Static Library|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Dynamic Library|x64.ActiveCfg = Debug Dynamic Library|x64 {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Dynamic Library|x64.Build.0 = Debug Dynamic Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Static Library|x64.ActiveCfg = Debug Static Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Debug Static Library|x64.Build.0 = Debug Static Library|x64 {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Dynamic Library|x64.ActiveCfg = Release Dynamic Library|x64 {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Dynamic Library|x64.Build.0 = Release Dynamic Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Static Library|x64.ActiveCfg = Release Static Library|x64 + {90057FD8-9460-43A6-8CDF-3AAC1C4255E5}.Release Static Library|x64.Build.0 = Release Static Library|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -22,4 +28,4 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9DA7C025-192F-4D21-8553-E795B4B60A1F} EndGlobalSection -EndGlobal +EndGlobal \ No newline at end of file diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index fa7850bcc..7b38df6fe 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -1,10 +1,18 @@ + + Debug Static Library + x64 + Debug Dynamic Library x64 + + Release Static Library + x64 + Release Dynamic Library x64 @@ -24,6 +32,12 @@ v141 MultiByte + + StaticLibrary + true + v141 + MultiByte + DynamicLibrary false @@ -31,6 +45,13 @@ true MultiByte + + StaticLibrary + false + v141 + true + MultiByte + @@ -39,16 +60,31 @@ + + + + + + $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(IncludePath) + $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(ProjectDir)dependencies\json\include;$(ProjectDir)..\..\;$(IncludePath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\makefiles\msvc2017\x64\debug;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) + $(ProjectDir)..\..\library\common\internal;$(SourcePath) + + + $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ + flutter_embedder + .lib + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) $(ProjectDir)dependencies\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\include\;$(ProjectDir)..\..\;$(ProjectDir)..\include\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\makefiles\msvc2017\x64\debug;$(LibraryPath) @@ -59,10 +95,18 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)dependencies\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\include;$(ProjectDir)..\..\;$(ProjectDir)..\include\;$(IncludePath) + $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(ProjectDir)dependencies\json\include;$(ProjectDir)..\..\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\makefiles\msvc2017\x64\release;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) $(ProjectDir)..\..\library\common\internal;$(SourcePath) + + $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ + $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ + flutter_embedder + .lib + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) + Level3 @@ -102,6 +146,44 @@ Add flutter_engine.dll to the out dir + + + Level3 + Disabled + true + true + + + flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) + + + exports.def + $(OutDir)$(TargetName)$(TargetExt) + $(OutDir)$(TargetName).dll.lib + $(OutDir)$(TargetName).dll.pdb + + + + + + + $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW + Get the flutter engine, engine artifacts and GLFW + + + + + + + + + flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) + + + xcopy /y /d /q "$(ProjectDir)dependencies\engine\flutter_engine.dll" "$(OutputPath)" + Add flutter_engine.dll to the out dir + + Level3 @@ -143,8 +225,47 @@ Add flutter_engine.dll to the out dir + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) + exports.def + $(OutDir)$(TargetName)$(TargetExt) + $(OutDir)$(TargetName).dll.lib + $(OutDir)$(TargetName).dll.pdb + + + + + + + $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW + Get the flutter engine, engine artifacts and GLFW + + + + + + + + + flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) + + + xcopy /y /d /q "$(ProjectDir)dependencies\engine\flutter_engine.dll" "$(OutputPath)" + Add flutter_engine.dll to the out dir + + - @@ -158,13 +279,14 @@ - - + + + diff --git a/library/windows/GLFW Library.vcxproj.filters b/library/windows/GLFW Library.vcxproj.filters index cd2ce51a0..c627263fa 100644 --- a/library/windows/GLFW Library.vcxproj.filters +++ b/library/windows/GLFW Library.vcxproj.filters @@ -15,57 +15,21 @@ - - Source Files - - - - + Source Files Source Files - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - + Header Files + + + Source Files + + \ No newline at end of file From eb44258f89c0c8b1a3031e5578b33f924e944256 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Wed, 2 Jan 2019 18:44:31 +1300 Subject: [PATCH 12/17] Fix VS Filters --- library/windows/GLFW Library.vcxproj.filters | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/windows/GLFW Library.vcxproj.filters b/library/windows/GLFW Library.vcxproj.filters index c627263fa..19d2bc369 100644 --- a/library/windows/GLFW Library.vcxproj.filters +++ b/library/windows/GLFW Library.vcxproj.filters @@ -15,21 +15,21 @@ - + Source Files - + Source Files - - - Header Files - - Source Files + + + Header Files + + \ No newline at end of file From 8f45a31e8c107d2da0b3013b2d7bdb5e7fd09736 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Fri, 4 Jan 2019 20:45:04 +1300 Subject: [PATCH 13/17] index on windows-gn: 4b904d8 Merge branch 'master' into windows-gn --- build/BUILD.gn | 2 + build/win/toolchain/BUILD.gn | 2 +- library/BUILD.gn | 8 +-- library/GN.md | 13 ++++- library/windows/BUILD.gn | 22 ++++++-- library/windows/jsoncpp.gni | 4 +- tools/dart_tools/bin/build_jsoncpp.dart | 70 ++++++++++--------------- tools/dart_tools/bin/fetch_glfw.dart | 44 ++++++++++++---- tools/dart_tools/bin/fetch_jsoncpp.dart | 70 +++++++++++++++++++++++++ tools/dart_tools/lib/runCommand.dart | 18 +++++++ 10 files changed, 186 insertions(+), 67 deletions(-) create mode 100644 tools/dart_tools/bin/fetch_jsoncpp.dart create mode 100644 tools/dart_tools/lib/runCommand.dart diff --git a/build/BUILD.gn b/build/BUILD.gn index 683b23e80..2c37ee9fb 100644 --- a/build/BUILD.gn +++ b/build/BUILD.gn @@ -24,6 +24,8 @@ config("defaults") { if (is_win) { cflags = [ "/EHsc", + "/W3", + "/Od", ] } include_dirs = [ diff --git a/build/win/toolchain/BUILD.gn b/build/win/toolchain/BUILD.gn index 53469f00f..c8ccd960a 100644 --- a/build/win/toolchain/BUILD.gn +++ b/build/win/toolchain/BUILD.gn @@ -13,7 +13,7 @@ # limitations under the License. toolchain("msvc") { - env_setup = "vcvars64.bat &&" + env_setup = "vcvars64.bat 1> nul &&" tool("cc") { pdbfile = "{{target_out_dir}}/{{label_name}}_c.pdb" diff --git a/library/BUILD.gn b/library/BUILD.gn index e0b02bb1e..69e14093a 100644 --- a/library/BUILD.gn +++ b/library/BUILD.gn @@ -109,13 +109,9 @@ published_shared_library("flutter_embedder") { engine_files[2], ] - configs += [ - "//build/win/config:glfw3", - "//build/win/config:jsoncpp", - ] - public_configs += [ - "//library/windows:relative_dependency_headers", + "//library/windows:relative_glfw_dependencies", + "//library/windows:relative_jsoncpp_dependencies", ] } } diff --git a/library/GN.md b/library/GN.md index 626e931bb..ea9e613d1 100644 --- a/library/GN.md +++ b/library/GN.md @@ -18,13 +18,22 @@ Windows also requires the 64 bit compiler, linker and setup scripts to be in your path. They are found under: ``` -Visual Studio Install Path\2017\Version\VC\Auxiliary\Build +> Visual Studio Install Path\2017\Version\VC\Auxiliary\Build ``` e.g.: ``` -C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build +> C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build +``` + +Windows requires jsoncpp to be downloaded to +`library/windows/third_party/jsoncpp`. Use +`tools/dart_tools/bin/fetch_jsoncpp.dart` to automatically download `jsoncpp` +with Visual Studio 2017 support as shown below: + +``` +> tools\run_dart_tool.bat tools\dart_tools\bin\fetch_jsoncpp.dart library\windows\third_party\jsoncpp ``` ## Building diff --git a/library/windows/BUILD.gn b/library/windows/BUILD.gn index 095006e80..000873a10 100644 --- a/library/windows/BUILD.gn +++ b/library/windows/BUILD.gn @@ -23,24 +23,38 @@ action("fetch_glfw") { args = [ rebase_path(glfw_download_dir, root_build_dir), ] + public_configs = [ + "//build/win/config:glfw3", + ] +} + +config("relative_glfw_dependencies") { + include_dirs = [ + glfw_include_dir, + ] + lib_dirs = [ + glfw_download_dir, + ] } action("build_jsoncpp") { script = "//tools/dart_tools/bin/build_jsoncpp.dart" - outputs = jsoncpp_files + outputs = [ jsoncpp_files[1] ] args = [ rebase_path(jsoncpp_download_dir, root_build_dir), + rebase_path(jsoncpp_lib_dir, root_build_dir), "--debug", ] + public_configs = [ + "//build/win/config:jsoncpp", + ] } -config("relative_dependency_headers") { +config("relative_jsoncpp_dependencies") { include_dirs = [ - glfw_include_dir, jsoncpp_include_dir, ] lib_dirs = [ - glfw_download_dir, jsoncpp_lib_dir, ] } diff --git a/library/windows/jsoncpp.gni b/library/windows/jsoncpp.gni index 0a25c8886..c45d9389c 100644 --- a/library/windows/jsoncpp.gni +++ b/library/windows/jsoncpp.gni @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -jsoncpp_download_dir = "$root_gen_dir/json" +jsoncpp_download_dir = rebase_path("third_party/jsoncpp") jsoncpp_include_dir = "$jsoncpp_download_dir/include" -jsoncpp_lib_dir = "$jsoncpp_download_dir/makefiles/msvc2017/x64/Debug" +jsoncpp_lib_dir = "$root_gen_dir/JSON" jsoncpp_lib_name = "json_vc71_libmtd.lib" jsoncpp_files = [ diff --git a/tools/dart_tools/bin/build_jsoncpp.dart b/tools/dart_tools/bin/build_jsoncpp.dart index db9ed6b0f..96d5c43f1 100644 --- a/tools/dart_tools/bin/build_jsoncpp.dart +++ b/tools/dart_tools/bin/build_jsoncpp.dart @@ -12,9 +12,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +// This script builds jsoncpp using Visual Studio 2017 in a provided directory. +// An additional directory can be provided which will have to built library +// copied to it. Optionally using the --debug flag will build in debug mode. + import 'dart:io'; import 'package:args/args.dart'; +import 'package:path/path.dart' as path; + +import '../lib/runCommand.dart'; Future main(List arguments) async { if (!Platform.isWindows) { @@ -22,56 +29,37 @@ Future main(List arguments) async { 'windows.'); } - final parser = new ArgParser() - ..addFlag('debug', abbr: 'd', negatable: false); + final parser = new ArgParser()..addFlag('debug', abbr: 'd', negatable: false); final args = parser.parse(arguments); - final downloadDirectory = arguments[0]; - final debug = args['debug']; - - await Process.run('git', [ - 'init', - downloadDirectory, - ]); - - await Process.run( - 'git', - [ - 'remote', - 'add', - 'origin', - 'https://github.com/clarkezone/jsoncpp.git', - ], - workingDirectory: downloadDirectory); - - await Process.run( - 'git', - [ - 'fetch', - ], - workingDirectory: downloadDirectory); + if (args.rest.length == 0) { + throw new Exception('One argument must be provided, the directory where ' + 'jsoncpp is downloaded.'); + } - await Process.run( - 'git', - [ - 'checkout', - '3ae7e8073a425c93329c8577a3c813c206322ca4', - ], - workingDirectory: downloadDirectory); + final downloadDirectory = args.rest[0]; + final debug = args['debug']; - final jsoncppBuildProcess = await Process.run( - 'vcvars64.bat &&', + await runCommand( + 'vcvars64.bat 1> nul &&', [ 'msbuild', 'lib_json.vcxproj', !debug ? '/p:Configuration=Release' : '', ], - workingDirectory: '$downloadDirectory/makefiles/msvc2017', - runInShell: true); + workingDirectory: '$downloadDirectory/makefiles/msvc2017'); - if (jsoncppBuildProcess.exitCode != 0) { - print(jsoncppBuildProcess.stdout); - print(jsoncppBuildProcess.stderr); - throw new Exception('jsoncpp Build Failed'); + if (args.rest.length != 2) { + print('Copy directory not provided.'); + exit(0); } + + final outputDirectory = + "$downloadDirectory/makefiles/msvc2017/x64/${debug ? "Debug" : "Release"}"; + final outputLibrary = + "$outputDirectory/json_vc71_libmt${debug ? "d" : ""}.lib"; + final copyDirectory = args.rest[1]; + + await File(outputLibrary) + .copy(path.join(copyDirectory, path.basename(outputLibrary))); } diff --git a/tools/dart_tools/bin/fetch_glfw.dart b/tools/dart_tools/bin/fetch_glfw.dart index 735f1ba06..293d4bf4e 100644 --- a/tools/dart_tools/bin/fetch_glfw.dart +++ b/tools/dart_tools/bin/fetch_glfw.dart @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// This script downloads a prebuilt glfw library into a provided directory. + import 'dart:io'; import 'package:path/path.dart' as path; @@ -20,6 +22,11 @@ import 'package:archive/archive.dart'; const String glfwArchiveUrlString = 'http://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.bin.WIN64.zip'; +const List requiredFiles = [ + 'glfw-3.2.1.bin.WIN64/include/GLFW/glfw3.h', + 'glfw-3.2.1.bin.WIN64/lib-vc2015/glfw3.lib', +]; + Future main(List arguments) async { if (!Platform.isWindows) { throw new Exception('Prebuilt glfw3 libraries are only available on ' @@ -33,20 +40,33 @@ Future main(List arguments) async { final outputDirectory = arguments[0]; - const Map requiredFiles = { - 'glfw-3.2.1.bin.WIN64/include/GLFW/glfw3.h': 'glfw3.h', - 'glfw-3.2.1.bin.WIN64/lib-vc2015/glfw3.lib': 'glfw3.lib', - }; + if (await downloadExists(outputDirectory)) { + print('GLFW files already exist.'); + exit(0); + } + + final archiveData = await downloadLibrary(); + await new Directory(outputDirectory).create(recursive: true); + + await extractRequiredFiles(archiveData, outputDirectory); +} + +Future downloadExists(String outputDirectory) async { int existingFiles = 0; - for (final file in requiredFiles.values) { - if (await File("$outputDirectory/$file").exists()) { + for (final file in requiredFiles) { + if (await File("$outputDirectory/${path.basename(file)}").exists()) { existingFiles++; } } - if (existingFiles == requiredFiles.length) exit(0); + if (existingFiles == requiredFiles.length) { + return true; + } + return false; +} +Future> downloadLibrary() async { final archiveUri = Uri.parse(glfwArchiveUrlString); final httpClient = new HttpClient(); @@ -57,17 +77,19 @@ Future main(List arguments) async { archiveData.addAll(data); } httpClient.close(); + return archiveData; +} - await new Directory(outputDirectory).create(recursive: true); - +Future extractRequiredFiles( + List archiveData, String outputDirectory) async { final archive = new ZipDecoder().decodeBytes(archiveData); for (final file in archive) { - if (!requiredFiles.containsKey(file.name)) { + if (!requiredFiles.contains(file.name)) { continue; } final extractedFile = - new File(path.join(outputDirectory, requiredFiles[file.name])); + new File(path.join(outputDirectory, path.basename(file.name))); extractedFile.writeAsBytes(file.content); } } diff --git a/tools/dart_tools/bin/fetch_jsoncpp.dart b/tools/dart_tools/bin/fetch_jsoncpp.dart new file mode 100644 index 000000000..b0ad9d8d2 --- /dev/null +++ b/tools/dart_tools/bin/fetch_jsoncpp.dart @@ -0,0 +1,70 @@ +// 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. + +// This script downloads a specific version of jsoncpp with Visual Studio 2017 +// support into a provided directory. + +import 'dart:io'; + +import '../lib/runCommand.dart'; + +// For the fork containing V2017 support. Once +// https://github.com/open-source-parsers/jsoncpp/pull/853 +// has landed, this should use the jsoncpp repository. +const String gitRepo = 'https://github.com/clarkezone/jsoncpp.git'; +const String pinnedVersion = '3ae7e8073a425c93329c8577a3c813c206322ca4'; + +Future main(List arguments) async { + if (!Platform.isWindows) { + throw new Exception('Fetching jsoncpp libraries is only available on ' + 'windows.'); + } + + if (arguments.length != 1) { + throw new Exception('One argument should be passed, the directory to ' + 'download jsoncpp to.'); + } + + final downloadDirectory = arguments[0]; + + await runCommand('git', [ + 'init', + downloadDirectory, + ]); + + await runCommand( + 'git', + [ + 'remote', + 'add', + 'origin', + gitRepo, + ], + workingDirectory: downloadDirectory, allowFail: true); + + await runCommand( + 'git', + [ + 'fetch', + ], + workingDirectory: downloadDirectory); + + await runCommand( + 'git', + [ + 'checkout', + pinnedVersion, + ], + workingDirectory: downloadDirectory); +} diff --git a/tools/dart_tools/lib/runCommand.dart b/tools/dart_tools/lib/runCommand.dart new file mode 100644 index 000000000..0ce5107c0 --- /dev/null +++ b/tools/dart_tools/lib/runCommand.dart @@ -0,0 +1,18 @@ +import 'dart:io'; + +Future runCommand(String exe, List arguments, + {String workingDirectory, bool allowFail = false}) async { + final fullCommand = '$exe ${arguments.join(" ")}'; + print('Running $fullCommand'); + + final process = await Process.start(exe, arguments, + workingDirectory: workingDirectory, runInShell: true); + stdout.addStream(process.stdout); + stderr.addStream(process.stderr); + + final exitCode = await process.exitCode; + if (!allowFail && exitCode != 0) { + throw new Exception('$fullCommand failed with exit code $exitCode'); + } + return exitCode; +} \ No newline at end of file From f0b13fb0be31d6efc297c7cd9109be57c10279f7 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Fri, 4 Jan 2019 21:08:51 +1300 Subject: [PATCH 14/17] Fix Visual Studio Build --- library/windows/GLFW Library.vcxproj | 10 +++++----- library/windows/GLFW Library.vcxproj.filters | 3 +++ library/windows/scripts/build_jsonlib.bat | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index 025eb83fa..b9aeec9cd 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -75,8 +75,8 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(ProjectDir)dependencies\json\include;$(ProjectDir)..\..\;$(IncludePath) - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\makefiles\msvc2017\x64\debug;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) + $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(ProjectDir)third_party\jsoncpp\include\;$(ProjectDir)..\..\;$(IncludePath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\JSON\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) $(ProjectDir)..\..\library\common\internal;$(SourcePath) @@ -95,8 +95,8 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(ProjectDir)dependencies\json\include;$(ProjectDir)..\..\;$(IncludePath) - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\makefiles\msvc2017\x64\release;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) + $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(ProjectDir)third_party\jsoncpp\include\;$(ProjectDir)..\..\;$(IncludePath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\JSON\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) $(ProjectDir)..\..\library\common\internal;$(SourcePath) @@ -291,4 +291,4 @@ - + \ No newline at end of file diff --git a/library/windows/GLFW Library.vcxproj.filters b/library/windows/GLFW Library.vcxproj.filters index 4caa77f1a..c7eff2ff6 100644 --- a/library/windows/GLFW Library.vcxproj.filters +++ b/library/windows/GLFW Library.vcxproj.filters @@ -60,6 +60,9 @@ Source Files + + Source Files + diff --git a/library/windows/scripts/build_jsonlib.bat b/library/windows/scripts/build_jsonlib.bat index 29f53d8dd..4aa0afdc5 100644 --- a/library/windows/scripts/build_jsonlib.bat +++ b/library/windows/scripts/build_jsonlib.bat @@ -13,4 +13,4 @@ :: limitations under the License. @echo off for /f "delims=" %%i in ('%~dp0..\..\..\tools\flutter_location') do set FLUTTER_DIR=%%i -%FLUTTER_DIR%\bin\cache\dart-sdk\bin\dart %~dp0..\..\..\tools\dart_tools\bin\build_jsoncpp.dart %~dp0..\dependencies\JSON %* \ No newline at end of file +%FLUTTER_DIR%\bin\cache\dart-sdk\bin\dart %~dp0..\..\..\tools\dart_tools\bin\build_jsoncpp.dart %~dp0..\third_party\jsoncpp %~dp0..\dependencies\JSON %* \ No newline at end of file From b51bd0e9008be924ddaad7279d30bb7f42942e34 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Tue, 8 Jan 2019 14:08:32 +1300 Subject: [PATCH 15/17] PR Feedback --- library/GN.md | 8 +++++- library/windows/BUILD.gn | 3 +++ library/windows/scripts/build_jsonlib.bat | 3 +-- library/windows/scripts/get_GLFW.bat | 3 +-- tools/dart_tools/bin/build_jsoncpp.dart | 32 +++++++++++++++-------- tools/dart_tools/bin/fetch_jsoncpp.dart | 20 ++------------ tools/dart_tools/lib/runCommand.dart | 29 +++++++++++++++++--- tools/gn_dart.bat | 2 +- 8 files changed, 61 insertions(+), 39 deletions(-) diff --git a/library/GN.md b/library/GN.md index ea9e613d1..416fb19e2 100644 --- a/library/GN.md +++ b/library/GN.md @@ -14,6 +14,8 @@ In addition to the normal dependencies, you will need to install: Ensure that both binaries are in your path. +### Windows + Windows also requires the 64 bit compiler, linker and setup scripts to be in your path. They are found under: @@ -33,9 +35,13 @@ Windows requires jsoncpp to be downloaded to with Visual Studio 2017 support as shown below: ``` -> tools\run_dart_tool.bat tools\dart_tools\bin\fetch_jsoncpp.dart library\windows\third_party\jsoncpp +> tools\run_dart_tool.bat fetch_jsoncpp library\windows\third_party\jsoncpp ``` +Currently the GN build rule for `jsoncpp` if a placeholder that will eventually +be replaced with full GN build capabilities. Currently if you modify the source +of `jsoncpp`, `out/gen/JSON` will need to be deleted for GN to rebuild it. + ## Building ### Library diff --git a/library/windows/BUILD.gn b/library/windows/BUILD.gn index 000873a10..c688977d1 100644 --- a/library/windows/BUILD.gn +++ b/library/windows/BUILD.gn @@ -37,6 +37,9 @@ config("relative_glfw_dependencies") { ] } +# TODO: Replace this with actual GN build rules for jsoncpp. +# This target is a placeholder, and will not actually rebuild jsoncpp if any of its +# source changes. action("build_jsoncpp") { script = "//tools/dart_tools/bin/build_jsoncpp.dart" outputs = [ jsoncpp_files[1] ] diff --git a/library/windows/scripts/build_jsonlib.bat b/library/windows/scripts/build_jsonlib.bat index 4aa0afdc5..78d4e623c 100644 --- a/library/windows/scripts/build_jsonlib.bat +++ b/library/windows/scripts/build_jsonlib.bat @@ -12,5 +12,4 @@ :: See the License for the specific language governing permissions and :: limitations under the License. @echo off -for /f "delims=" %%i in ('%~dp0..\..\..\tools\flutter_location') do set FLUTTER_DIR=%%i -%FLUTTER_DIR%\bin\cache\dart-sdk\bin\dart %~dp0..\..\..\tools\dart_tools\bin\build_jsoncpp.dart %~dp0..\third_party\jsoncpp %~dp0..\dependencies\JSON %* \ No newline at end of file +%~dp0..\..\..\tools\run_dart_tool.bat build_jsoncpp %~dp0..\third_party\jsoncpp %~dp0..\dependencies\JSON %* \ No newline at end of file diff --git a/library/windows/scripts/get_GLFW.bat b/library/windows/scripts/get_GLFW.bat index 13e7079ea..48be07526 100644 --- a/library/windows/scripts/get_GLFW.bat +++ b/library/windows/scripts/get_GLFW.bat @@ -12,5 +12,4 @@ :: See the License for the specific language governing permissions and :: limitations under the License. @echo off -for /f "delims=" %%i in ('%~dp0..\..\..\tools\flutter_location') do set FLUTTER_DIR=%%i -%FLUTTER_DIR%\bin\cache\dart-sdk\bin\dart %~dp0..\..\..\tools\dart_tools\bin\fetch_glfw.dart %~dp0..\dependencies\GLFW \ No newline at end of file +%~dp0..\..\..\tools\run_dart_tool.bat fetch_glfw %~dp0..\dependencies\GLFW \ No newline at end of file diff --git a/tools/dart_tools/bin/build_jsoncpp.dart b/tools/dart_tools/bin/build_jsoncpp.dart index 96d5c43f1..7c924f45a 100644 --- a/tools/dart_tools/bin/build_jsoncpp.dart +++ b/tools/dart_tools/bin/build_jsoncpp.dart @@ -40,25 +40,35 @@ Future main(List arguments) async { final downloadDirectory = args.rest[0]; final debug = args['debug']; - await runCommand( - 'vcvars64.bat 1> nul &&', - [ - 'msbuild', - 'lib_json.vcxproj', - !debug ? '/p:Configuration=Release' : '', - ], - workingDirectory: '$downloadDirectory/makefiles/msvc2017'); + final buildDirectory = '$downloadDirectory/makefiles/msvc2017'; + await buildLibrary(buildDirectory, debug); if (args.rest.length != 2) { print('Copy directory not provided.'); exit(0); } - final outputDirectory = - "$downloadDirectory/makefiles/msvc2017/x64/${debug ? "Debug" : "Release"}"; + final copyDirectory = args.rest[1]; + await copyLibraryToOutputDirectory(buildDirectory, copyDirectory, debug); +} + +void buildLibrary(String buildDirectory, bool debug) async { + var arguments = [ + 'msbuild', + 'lib_json.vcxproj', + ]; + if (!debug) { + arguments.add('/p:Configuration=Release'); + } + await runCommand('vcvars64.bat 1> nul &&', arguments, + workingDirectory: buildDirectory); +} + +void copyLibraryToOutputDirectory( + String buildDirectory, String copyDirectory, bool debug) async { + final outputDirectory = "$buildDirectory/x64/${debug ? "Debug" : "Release"}"; final outputLibrary = "$outputDirectory/json_vc71_libmt${debug ? "d" : ""}.lib"; - final copyDirectory = args.rest[1]; await File(outputLibrary) .copy(path.join(copyDirectory, path.basename(outputLibrary))); diff --git a/tools/dart_tools/bin/fetch_jsoncpp.dart b/tools/dart_tools/bin/fetch_jsoncpp.dart index b0ad9d8d2..b5df870d1 100644 --- a/tools/dart_tools/bin/fetch_jsoncpp.dart +++ b/tools/dart_tools/bin/fetch_jsoncpp.dart @@ -39,27 +39,11 @@ Future main(List arguments) async { final downloadDirectory = arguments[0]; await runCommand('git', [ - 'init', + 'clone', + gitRepo, downloadDirectory, ]); - await runCommand( - 'git', - [ - 'remote', - 'add', - 'origin', - gitRepo, - ], - workingDirectory: downloadDirectory, allowFail: true); - - await runCommand( - 'git', - [ - 'fetch', - ], - workingDirectory: downloadDirectory); - await runCommand( 'git', [ diff --git a/tools/dart_tools/lib/runCommand.dart b/tools/dart_tools/lib/runCommand.dart index 0ce5107c0..92ee0f3bb 100644 --- a/tools/dart_tools/lib/runCommand.dart +++ b/tools/dart_tools/lib/runCommand.dart @@ -1,11 +1,32 @@ +// 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 'dart:io'; -Future runCommand(String exe, List arguments, +/// Runs a [command] on the command line with some logging and error handling +/// +/// Takes a [command] and [arguments] to pass to the [command] that will be run +/// on the command line. Stdout and stderr will be printed and an exception +/// thrown if the exit code is not 0 and [allowFail] is true. An optional +/// [workingDirectory] can be passed for the directory of the [command] to be +/// executed in. +Future runCommand(String command, List arguments, {String workingDirectory, bool allowFail = false}) async { - final fullCommand = '$exe ${arguments.join(" ")}'; + final fullCommand = '$command ${arguments.join(" ")}'; print('Running $fullCommand'); - final process = await Process.start(exe, arguments, + final process = await Process.start(command, arguments, workingDirectory: workingDirectory, runInShell: true); stdout.addStream(process.stdout); stderr.addStream(process.stderr); @@ -15,4 +36,4 @@ Future runCommand(String exe, List arguments, throw new Exception('$fullCommand failed with exit code $exitCode'); } return exitCode; -} \ No newline at end of file +} diff --git a/tools/gn_dart.bat b/tools/gn_dart.bat index e7be3cc2f..e6323d56e 100644 --- a/tools/gn_dart.bat +++ b/tools/gn_dart.bat @@ -23,4 +23,4 @@ set DART_BIN_DIR=%FLUTTER_BIN_DIR%\cache\dart-sdk\bin :: Ensure that the Dart SDK has been downloaded. if not exist %DART_BIN_DIR%\ call %FLUTTER_BIN_DIR%\flutter precache -call gn --script-executable=%DART_BIN_DIR%\dart %* \ No newline at end of file +call gn --script-executable=%DART_BIN_DIR%\dart %* From 5fde142b0eca4873afc44a2c1922e35803564065 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Tue, 8 Jan 2019 18:20:05 +1300 Subject: [PATCH 16/17] Comply with Dart Analyzer --- analysis_options.yaml | 3 ++- tools/dart_tools/bin/build_jsoncpp.dart | 14 +++++++------- tools/dart_tools/bin/fetch_glfw.dart | 6 +++--- tools/dart_tools/lib/runCommand.dart | 4 ++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 966fd5318..c4f7cab6f 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -29,7 +29,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 diff --git a/tools/dart_tools/bin/build_jsoncpp.dart b/tools/dart_tools/bin/build_jsoncpp.dart index 7c924f45a..0876b132a 100644 --- a/tools/dart_tools/bin/build_jsoncpp.dart +++ b/tools/dart_tools/bin/build_jsoncpp.dart @@ -32,7 +32,7 @@ Future main(List arguments) async { final parser = new ArgParser()..addFlag('debug', abbr: 'd', negatable: false); final args = parser.parse(arguments); - if (args.rest.length == 0) { + if (args.rest.isEmpty) { throw new Exception('One argument must be provided, the directory where ' 'jsoncpp is downloaded.'); } @@ -41,7 +41,7 @@ Future main(List arguments) async { final debug = args['debug']; final buildDirectory = '$downloadDirectory/makefiles/msvc2017'; - await buildLibrary(buildDirectory, debug); + await buildLibrary(buildDirectory, debug: debug); if (args.rest.length != 2) { print('Copy directory not provided.'); @@ -49,11 +49,11 @@ Future main(List arguments) async { } final copyDirectory = args.rest[1]; - await copyLibraryToOutputDirectory(buildDirectory, copyDirectory, debug); + await copyLibraryToOutputDirectory(buildDirectory, copyDirectory, debug: debug); } -void buildLibrary(String buildDirectory, bool debug) async { - var arguments = [ +Future buildLibrary(String buildDirectory, {bool debug}) async { + final arguments = [ 'msbuild', 'lib_json.vcxproj', ]; @@ -64,8 +64,8 @@ void buildLibrary(String buildDirectory, bool debug) async { workingDirectory: buildDirectory); } -void copyLibraryToOutputDirectory( - String buildDirectory, String copyDirectory, bool debug) async { +Future copyLibraryToOutputDirectory( + String buildDirectory, String copyDirectory, {bool debug}) async { final outputDirectory = "$buildDirectory/x64/${debug ? "Debug" : "Release"}"; final outputLibrary = "$outputDirectory/json_vc71_libmt${debug ? "d" : ""}.lib"; diff --git a/tools/dart_tools/bin/fetch_glfw.dart b/tools/dart_tools/bin/fetch_glfw.dart index 293d4bf4e..3dee53783 100644 --- a/tools/dart_tools/bin/fetch_glfw.dart +++ b/tools/dart_tools/bin/fetch_glfw.dart @@ -53,9 +53,9 @@ Future main(List arguments) async { } Future downloadExists(String outputDirectory) async { - int existingFiles = 0; + var existingFiles = 0; for (final file in requiredFiles) { - if (await File("$outputDirectory/${path.basename(file)}").exists()) { + if (File('$outputDirectory/${path.basename(file)}').existsSync()) { existingFiles++; } } @@ -90,6 +90,6 @@ Future extractRequiredFiles( final extractedFile = new File(path.join(outputDirectory, path.basename(file.name))); - extractedFile.writeAsBytes(file.content); + await extractedFile.writeAsBytes(file.content); } } diff --git a/tools/dart_tools/lib/runCommand.dart b/tools/dart_tools/lib/runCommand.dart index 92ee0f3bb..5e6dd074f 100644 --- a/tools/dart_tools/lib/runCommand.dart +++ b/tools/dart_tools/lib/runCommand.dart @@ -28,8 +28,8 @@ Future runCommand(String command, List arguments, final process = await Process.start(command, arguments, workingDirectory: workingDirectory, runInShell: true); - stdout.addStream(process.stdout); - stderr.addStream(process.stderr); + await stdout.addStream(process.stdout); + await stderr.addStream(process.stderr); final exitCode = await process.exitCode; if (!allowFail && exitCode != 0) { From e8e632e4a20dd960ef3ad56debaa807d9bdca9f9 Mon Sep 17 00:00:00 2001 From: Callum Iddon Date: Tue, 8 Jan 2019 18:24:42 +1300 Subject: [PATCH 17/17] Format Fix --- tools/dart_tools/bin/build_jsoncpp.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/dart_tools/bin/build_jsoncpp.dart b/tools/dart_tools/bin/build_jsoncpp.dart index 0876b132a..0efb7b8d4 100644 --- a/tools/dart_tools/bin/build_jsoncpp.dart +++ b/tools/dart_tools/bin/build_jsoncpp.dart @@ -49,7 +49,8 @@ Future main(List arguments) async { } final copyDirectory = args.rest[1]; - await copyLibraryToOutputDirectory(buildDirectory, copyDirectory, debug: debug); + await copyLibraryToOutputDirectory(buildDirectory, copyDirectory, + debug: debug); } Future buildLibrary(String buildDirectory, {bool debug}) async { @@ -65,7 +66,8 @@ Future buildLibrary(String buildDirectory, {bool debug}) async { } Future copyLibraryToOutputDirectory( - String buildDirectory, String copyDirectory, {bool debug}) async { + String buildDirectory, String copyDirectory, + {bool debug}) async { final outputDirectory = "$buildDirectory/x64/${debug ? "Debug" : "Release"}"; final outputLibrary = "$outputDirectory/json_vc71_libmt${debug ? "d" : ""}.lib";