Skip to content

Commit 35649c1

Browse files
authored
Consolidate GN rules (#268)
De-dups some common code between the Windows and Linux GN files, and consolidates some of the Windows-specific code into one location. Adjusts embedder library rule to be clearer about which portions are specific to the GLFW-based implementation.
1 parent 5b0044d commit 35649c1

File tree

4 files changed

+61
-120
lines changed

4 files changed

+61
-120
lines changed

build/win/config/BUILD.gn

Lines changed: 0 additions & 26 deletions
This file was deleted.

library/BUILD.gn

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ import("//build/flutter.gni")
1616
import("//build/packaging.gni")
1717
import("//library/engine.gni")
1818

19+
declare_args() {
20+
# Whether to use the GLFW embedding implementation. Currently overriding this
21+
# would not work since each platform only has one working implementation,
22+
# but in the future GLFW may be one of multiple supported implementations.
23+
use_glfw = is_linux || is_win
24+
}
25+
1926
published_shared_library("flutter_embedder") {
2027
# GLFW embedding implementation.
21-
if (is_linux || is_win) {
28+
if (use_glfw) {
2229
public = [
2330
"include/flutter_desktop_embedding/glfw/embedder.h",
2431
"include/flutter_desktop_embedding/glfw/flutter_window_controller.h",
@@ -64,7 +71,7 @@ published_shared_library("flutter_embedder") {
6471
}
6572

6673
deps = [
67-
":fetch_flutter_engine",
74+
":flutter_engine",
6875
]
6976

7077
defines = [ "FLUTTER_DESKTOP_EMBEDDING_IMPL" ]
@@ -74,31 +81,30 @@ published_shared_library("flutter_embedder") {
7481
public_configs = [ ":relative_public_headers" ]
7582

7683
if (is_linux) {
77-
libs = [ "GL" ]
78-
79-
deps += [ "//library/linux:publish_flutter_engine" ]
80-
81-
configs += [
82-
"//build/linux/config:epoxy",
83-
"//build/linux/config:glfw3",
84-
"//build/linux/config:gtk3",
85-
"//build/linux/config:jsoncpp",
86-
"//build/linux/config:x11",
87-
]
84+
configs += [ "//build/linux/config:jsoncpp" ]
8885
}
8986

9087
if (is_win) {
91-
deps += [
92-
"//library/windows:fetch_glfw",
93-
"//library/windows:publish_flutter_engine",
94-
"//third_party/jsoncpp:jsoncpp",
95-
]
88+
deps += [ "//third_party/jsoncpp:jsoncpp" ]
9689

9790
libs = [ engine_files[2] ]
91+
}
9892

99-
public_configs += [
100-
"//library/windows:relative_glfw_dependencies",
101-
]
93+
if (use_glfw) {
94+
if (is_linux) {
95+
libs = [ "GL" ]
96+
97+
configs += [
98+
"//build/linux/config:epoxy",
99+
"//build/linux/config:glfw3",
100+
"//build/linux/config:gtk3",
101+
"//build/linux/config:x11",
102+
]
103+
}
104+
105+
if (is_win) {
106+
deps += [ "//library/windows:fetch_glfw" ]
107+
}
102108
}
103109
}
104110

@@ -114,6 +120,13 @@ config("relative_engine_headers") {
114120
include_dirs = [ "$engine_download_dir" ]
115121
}
116122

123+
group("flutter_engine") {
124+
public_deps = [
125+
":fetch_flutter_engine",
126+
":publish_flutter_engine",
127+
]
128+
}
129+
117130
action("fetch_flutter_engine") {
118131
script = "//tools/dart_tools/bin/update_flutter_engine.dart"
119132
inputs = [
@@ -126,3 +139,20 @@ action("fetch_flutter_engine") {
126139
]
127140
public_configs = [ ":relative_engine_headers" ]
128141
}
142+
143+
# Places the downloaded Flutter engine library at the top level of the
144+
# output directory where built libraries go, so that it doesn't require
145+
# special link handling, and publishes its header.
146+
copy("publish_flutter_engine") {
147+
sources = engine_files
148+
149+
# Remove the header, since "SDK" clients don't need access to that.
150+
sources -= [ engine_files[0] ]
151+
152+
outputs = [
153+
"$root_out_dir/{{source_file_part}}",
154+
]
155+
deps = [
156+
":fetch_flutter_engine",
157+
]
158+
}

library/linux/BUILD.gn

Lines changed: 0 additions & 41 deletions
This file was deleted.

library/windows/BUILD.gn

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

15-
import("//build/packaging.gni")
16-
import("//library/engine.gni")
1715
import("//library/windows/glfw.gni")
1816

1917
action("fetch_glfw") {
2018
script = "//tools/dart_tools/bin/fetch_glfw.dart"
2119
outputs = glfw_files
2220
args = [ rebase_path(glfw_download_dir, root_build_dir) ]
23-
public_configs = [ "//build/win/config:glfw3" ]
21+
public_configs = [ ":glfw3" ]
2422
}
2523

26-
config("relative_glfw_dependencies") {
27-
include_dirs = [ glfw_include_dir ]
28-
lib_dirs = [ glfw_download_dir ]
29-
}
24+
config("glfw3") {
25+
libs = [
26+
"$glfw_lib_name",
27+
"opengl32.lib",
3028

31-
copy_includes("_publish_engine_headers") {
32-
sources = [
33-
engine_files[0],
34-
]
35-
deps = [
36-
"//library:fetch_flutter_engine",
37-
]
38-
}
39-
40-
# Places the downloaded Flutter engine library at the top level of the
41-
# output directory where built libraries go, so that it doesn't require
42-
# special link handling, and publishes its header.
43-
copy("publish_flutter_engine") {
44-
sources = [
45-
engine_files[1],
46-
engine_files[2],
47-
engine_files[3],
48-
engine_files[4],
49-
]
50-
outputs = [
51-
"$root_out_dir/{{source_file_part}}",
52-
]
53-
deps = [
54-
":_publish_engine_headers",
55-
"//library:fetch_flutter_engine",
29+
"user32.lib",
30+
"gdi32.lib",
31+
"shell32.lib",
5632
]
33+
lib_dirs = [ glfw_download_dir ]
34+
include_dirs = [ glfw_include_dir ]
5735
}

0 commit comments

Comments
 (0)