Skip to content

[Windows] [GN] Windows GN Builds #191

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4105878
Initial Windows GN build
CallumIddon Dec 11, 2018
7276950
Merge remote-tracking branch 'origin/master' into windows-gn
CallumIddon Dec 11, 2018
7222114
Add flutter_desktop_embedding namespace
CallumIddon Dec 12, 2018
7071072
[windows] [gn] Add namespaces to example embedder
CallumIddon Dec 12, 2018
661d449
Merge branch 'master' into windows-gn
CallumIddon Dec 29, 2018
ff7c6bb
Update to master
CallumIddon Dec 30, 2018
01edbec
Remove unnecessary libraries
CallumIddon Dec 31, 2018
3419579
Format fix
CallumIddon Dec 31, 2018
027eaf9
PR Feedback
CallumIddon Dec 31, 2018
4eb657e
Format fix
CallumIddon Dec 31, 2018
a252f24
Merge branch 'master' into windows-gn
CallumIddon Jan 1, 2019
79408bb
[Windows] [GN] Post #161
CallumIddon Jan 1, 2019
7c10308
[Windows] [GN] Force debug build
CallumIddon Jan 2, 2019
532ad74
Revert Removal of VS Static Library Builds
CallumIddon Jan 2, 2019
eb44258
Fix VS Filters
CallumIddon Jan 2, 2019
4b904d8
Merge branch 'master' into windows-gn
CallumIddon Jan 3, 2019
8f45a31
index on windows-gn: 4b904d8 Merge branch 'master' into windows-gn
CallumIddon Jan 4, 2019
3313323
On windows-gn: Auto stash before merge of "windows-gn" and "master"
CallumIddon Jan 4, 2019
056867b
Merge branch 'master' into windows-gn
CallumIddon Jan 4, 2019
a5c47e4
Merge branch 'HEAD' into windows-gn
CallumIddon Jan 4, 2019
f0b13fb
Fix Visual Studio Build
CallumIddon Jan 4, 2019
1505106
Merge branch 'master' into windows-gn
CallumIddon Jan 8, 2019
b51bd0e
PR Feedback
CallumIddon Jan 8, 2019
5fde142
Comply with Dart Analyzer
CallumIddon Jan 8, 2019
e8e632e
Format Fix
CallumIddon Jan 8, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
group("gn_all") {
deps = [
"//library:flutter_embedder",
"//plugins/color_panel:color_panel",
"//plugins/file_chooser:file_chooser",
"//plugins/menubar:menubar",
]
if (is_linux) {
deps += [
"//plugins/color_panel:color_panel",
"//plugins/file_chooser:file_chooser",
"//plugins/menubar:menubar",
]
}
}
31 changes: 20 additions & 11 deletions build/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
}
}
4 changes: 2 additions & 2 deletions build/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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

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

if (host_os == "linux") {
set_default_toolchain("//third_party/chromium/build/toolchain:gcc")
is_linux = true
is_mac = false
is_win = false
Expand All @@ -36,6 +35,7 @@ if (host_os == "linux") {
is_mac = true
is_win = false
} else if (host_os == "win") {
set_default_toolchain("//build/win/toolchain:msvc")
is_linux = false
is_mac = false
is_win = true
Expand Down
50 changes: 23 additions & 27 deletions build/packaging.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
}
24 changes: 24 additions & 0 deletions build/win/config/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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",
"shell32.lib",
]
}
105 changes: 105 additions & 0 deletions build/win/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

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

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}}"
}
}
10 changes: 5 additions & 5 deletions example/windows/GLFW Example.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,25 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Dynamic Library|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<IncludePath>$(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath)</IncludePath>
<IncludePath>$(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\library\include\;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Static Library|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<IncludePath>$(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath)</IncludePath>
<IncludePath>$(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\include\;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Dynamic Library|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<IncludePath>$(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath)</IncludePath>
<IncludePath>$(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\include\;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Static Library|x64'">
<OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<IncludePath>$(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath)</IncludePath>
<IncludePath>$(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\include\;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Dynamic Library|x64'">
Expand Down Expand Up @@ -227,4 +227,4 @@
<PropertyGroup>
<LocalDebuggerWorkingDirectory>$(SolutionDir)</LocalDebuggerWorkingDirectory>
</PropertyGroup>
</Project>
</Project>
12 changes: 6 additions & 6 deletions example/windows/flutter_embedder_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#include <iostream>
#include <vector>

#include <embedder.h>
#include <flutter_desktop_embedding/windows/embedder.h>

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.
Expand All @@ -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;
}
Loading