Skip to content

Commit

Permalink
Add an option to use a prebuilt impellerc (flutter#33139)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanderso authored May 6, 2022
1 parent f53c06d commit 1aa7ac7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
8 changes: 6 additions & 2 deletions fml/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ source_set("fml") {
"wakeable.h",
]

if (is_mac || is_ios || is_linux) {
if (is_mac || is_linux || (is_ios && is_debug)) {
sources += [ "backtrace.cc" ]
} else {
sources += [ "backtrace_stub.cc" ]
Expand All @@ -109,13 +109,17 @@ source_set("fml") {
]

deps = [
"//third_party/abseil-cpp/absl/debugging:symbolize",
"//third_party/dart/runtime:dart_api",

# These need to be in sync with the Fuchsia buildroot.
"//third_party/icu",
]

if (is_mac || is_linux || (is_ios && is_debug)) {
# This abseil dependency is only used by backtrace.cc.
deps += [ "//third_party/abseil-cpp/absl/debugging:symbolize" ]
}

configs += [ "//third_party/icu:icu_config" ]

public_configs = [
Expand Down
29 changes: 26 additions & 3 deletions impeller/tools/impeller.gni
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ declare_args() {

# Whether the OpenGLES backend is enabled.
impeller_enable_opengles = is_mac || is_linux

# Whether to use a prebuilt impellerc.
# If this is the empty string, impellerc will be built.
# If it is non-empty, it should be the absolute path to impellerc.
impeller_use_prebuilt_impellerc = ""
}

declare_args() {
Expand Down Expand Up @@ -195,6 +200,26 @@ template("embed_blob") {
}
}

# Dispatches to the build or prebuilt impellerc depending on the value of
# the impeller_use_prebuilt_impellerc argument. Forwards all variables to
# compiled_action_foreach or action_foreach as appropriate.
template("_impellerc") {
if (impeller_use_prebuilt_impellerc == "") {
compiled_action_foreach(target_name) {
forward_variables_from(invoker, "*")
tool = "//flutter/impeller/compiler:impellerc"
}
} else {
action_foreach(target_name) {
forward_variables_from(invoker, "*", [ "args" ])
script = "//build/gn_run_binary.py"
impellerc_path =
rebase_path(impeller_use_prebuilt_impellerc, root_build_dir)
args = [ impellerc_path ] + invoker.args
}
}
}

template("impellerc") {
assert(defined(invoker.shaders), "Impeller shaders must be specified.")
assert(defined(invoker.sl_file_extension),
Expand All @@ -208,9 +233,7 @@ template("impellerc") {

sl_file_extension = invoker.sl_file_extension

compiled_action_foreach(target_name) {
tool = "//flutter/impeller/compiler:impellerc"

_impellerc(target_name) {
sources = invoker.shaders
if (defined(invoker.intermediates_subdir)) {
subdir = invoker.intermediates_subdir
Expand Down
6 changes: 6 additions & 0 deletions tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ def to_gn_args(args):
elif os.getenv('FLUTTER_IMPELLER_ENABLE_PLAYGROUND', '0') == '1':
gn_args['impeller_enable_playground'] = True

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

return gn_args

def parse_args(args):
Expand Down Expand Up @@ -561,6 +564,9 @@ def parse_args(args):
# Impeller flags.
parser.add_argument('--enable-impeller-playground', default=False, action='store_true',
help='Whether impeller unit tests run in playground mode.')
parser.add_argument('--prebuilt-impellerc', default=None, type=str,
help='Absolute path to a prebuilt impellerc. ' +
'Do not use this outside of CI or with impellerc from a different engine version.')

# Sanitizers.
parser.add_argument('--asan', default=False, action='store_true')
Expand Down

0 comments on commit 1aa7ac7

Please sign in to comment.