Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit db06032

Browse files
authored
Allow builder to skip building examples. (#30917)
1 parent fcf2754 commit db06032

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

BUILD.gn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# found in the LICENSE file.
44

55
import("//flutter/common/config.gni")
6+
import("//flutter/examples/examples.gni")
67
import("//flutter/shell/platform/config.gni")
78
import("//flutter/shell/platform/glfw/config.gni")
89
import("//flutter/testing/testing.gni")
@@ -80,7 +81,7 @@ group("flutter") {
8081
]
8182

8283
# Ensure the example for a sample embedder compiles.
83-
if (is_mac || is_linux) {
84+
if (build_embedder_examples) {
8485
public_deps += [ "//flutter/examples/glfw" ]
8586
}
8687

examples/examples.gni

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
declare_args() {
6+
# The example embedders may use dependencies not suitable on all platforms.
7+
# Use this GN arg to disable building the examples.
8+
build_embedder_examples = is_mac || is_linux
9+
}

examples/glfw/BUILD.gn

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
# Use of this source code is governed by a BSD-style license that can be
33
# found in the LICENSE file.
44

5-
executable("glfw") {
6-
output_name = "embedder_example"
5+
import("//flutter/examples/examples.gni")
76

8-
sources = [ "FlutterEmbedderGLFW.cc" ]
7+
if (build_embedder_examples) {
8+
executable("glfw") {
9+
output_name = "embedder_example"
910

10-
deps = [
11-
"//flutter/shell/platform/embedder:embedder",
12-
"//third_party/glfw",
13-
]
11+
sources = [ "FlutterEmbedderGLFW.cc" ]
12+
13+
deps = [
14+
"//flutter/shell/platform/embedder:embedder",
15+
"//third_party/glfw",
16+
]
17+
}
1418
}

tools/gn

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ def to_gn_args(args):
371371
if args.build_glfw_shell is not None:
372372
gn_args['build_glfw_shell'] = args.build_glfw_shell
373373

374+
if args.build_embedder_examples is not None:
375+
gn_args['build_embedder_examples'] = args.build_embedder_examples
376+
374377
gn_args['stripped_symbols'] = args.stripped
375378

376379
if args.msan:
@@ -503,6 +506,10 @@ def parse_args(args):
503506
help='Build the GLFW shell on supported platforms where it is not built by default.')
504507
parser.add_argument('--no-build-glfw-shell', dest='build_glfw_shell', action='store_const', const=False,
505508
help='Do not build the GLFW shell on platforms where it is built by default.')
509+
parser.add_argument('--build-embedder-examples', action='store_const', const=True,
510+
help='Build the example embedders using the Embedder API.')
511+
parser.add_argument('--no-build-embedder-examples', dest='build_embedder_examples', action='store_const', const=False,
512+
help='Do not build the example embedders using the Embedder API.')
506513

507514
parser.add_argument('--bitcode', default=False, action='store_true',
508515
help='Enable bitcode for iOS targets. On debug runtime modes, this will be a marker only.')

0 commit comments

Comments
 (0)