Skip to content
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

Allow builder to skip building examples. #30917

Merged
merged 1 commit into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# found in the LICENSE file.

import("//flutter/common/config.gni")
import("//flutter/examples/examples.gni")
import("//flutter/shell/platform/config.gni")
import("//flutter/shell/platform/glfw/config.gni")
import("//flutter/testing/testing.gni")
Expand Down Expand Up @@ -80,7 +81,7 @@ group("flutter") {
]

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

Expand Down
9 changes: 9 additions & 0 deletions examples/examples.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

declare_args() {
# The example embedders may use dependencies not suitable on all platforms.
# Use this GN arg to disable building the examples.
build_embedder_examples = is_mac || is_linux
}
18 changes: 11 additions & 7 deletions examples/glfw/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

executable("glfw") {
output_name = "embedder_example"
import("//flutter/examples/examples.gni")

sources = [ "FlutterEmbedderGLFW.cc" ]
if (build_embedder_examples) {
executable("glfw") {
output_name = "embedder_example"

deps = [
"//flutter/shell/platform/embedder:embedder",
"//third_party/glfw",
]
sources = [ "FlutterEmbedderGLFW.cc" ]

deps = [
"//flutter/shell/platform/embedder:embedder",
"//third_party/glfw",
]
}
}
7 changes: 7 additions & 0 deletions tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ def to_gn_args(args):
if args.build_glfw_shell is not None:
gn_args['build_glfw_shell'] = args.build_glfw_shell

if args.build_embedder_examples is not None:
gn_args['build_embedder_examples'] = args.build_embedder_examples

gn_args['stripped_symbols'] = args.stripped

if args.msan:
Expand Down Expand Up @@ -503,6 +506,10 @@ def parse_args(args):
help='Build the GLFW shell on supported platforms where it is not built by default.')
parser.add_argument('--no-build-glfw-shell', dest='build_glfw_shell', action='store_const', const=False,
help='Do not build the GLFW shell on platforms where it is built by default.')
parser.add_argument('--build-embedder-examples', action='store_const', const=True,
help='Build the example embedders using the Embedder API.')
parser.add_argument('--no-build-embedder-examples', dest='build_embedder_examples', action='store_const', const=False,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the no version of a flag created automatically when it's a boolean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I just followed the example of the --no-build-glfw-shell flag above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, it isn't: error: unrecognized arguments: --no-build-embedder-examples when I remove it. Apparently, it is possible in Python 3.9 according to the internet. Leaving it as is.

help='Do not build the example embedders using the Embedder API.')

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