diff --git a/engine/src/flutter/impeller/host/BUILD.gn b/engine/src/flutter/impeller/host/BUILD.gn index ae7b48e403..87c6992c5e 100644 --- a/engine/src/flutter/impeller/host/BUILD.gn +++ b/engine/src/flutter/impeller/host/BUILD.gn @@ -3,6 +3,12 @@ # found in the LICENSE file. import("//flutter/common/config.gni") +import("//flutter/impeller/tools/metal/metal_library.gni") + +metal_library("impeller_host_shaders") { + name = "impeller_host" + sources = [ "shaders.metal" ] +} executable("host") { cflags_objc = flutter_cflags_objc_arc @@ -26,5 +32,8 @@ executable("host") { "ModelIO.framework", ] - deps = [ "//flutter/impeller/impeller" ] + deps = [ + ":impeller_host_shaders", + "//flutter/impeller/impeller", + ] } diff --git a/engine/src/flutter/impeller/host/Info.plist b/engine/src/flutter/impeller/host/Info.plist deleted file mode 100644 index cfbbdb70c4..0000000000 --- a/engine/src/flutter/impeller/host/Info.plist +++ /dev/null @@ -1,30 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIconFile - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - $(PRODUCT_BUNDLE_PACKAGE_TYPE) - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - NSMainStoryboardFile - Main - NSPrincipalClass - NSApplication - - diff --git a/engine/src/flutter/impeller/tools/metal/build_metal_library.py b/engine/src/flutter/impeller/tools/metal/build_metal_library.py new file mode 100644 index 0000000000..4ef75a4ee0 --- /dev/null +++ b/engine/src/flutter/impeller/tools/metal/build_metal_library.py @@ -0,0 +1,55 @@ +# 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. + +import sys + +import argparse +import errno +import os +import subprocess + +def MakeDirectories(path): + try: + os.makedirs(path) + except OSError as exc: + if exc.errno == errno.EEXIST and os.path.isdir(path): + pass + else: + raise + +def Main(): + parser = argparse.ArgumentParser() + parser.add_argument("--output", + type=str, required=True, + help="The location to generate the Metal library to.") + parser.add_argument("--depfile", + type=str, required=True, + help="The location of the depfile.") + parser.add_argument("--source", + type=str, action="append", required=True, + help="The source file to compile. Can be specified multiple times.") + + args = parser.parse_args() + + MakeDirectories(os.path.dirname(args.depfile)) + + command = [ + "xcrun", + "metal", + # Both user and system header will be tracked. + "-MMD", + "-MF", + args.depfile, + "-o", + args.output + ] + + command += args.source + + subprocess.check_call(command) + +if __name__ == '__main__': + if sys.platform != 'darwin': + raise Exception("This script only runs on Mac") + Main() diff --git a/engine/src/flutter/impeller/tools/metal/metal_library.gni b/engine/src/flutter/impeller/tools/metal/metal_library.gni new file mode 100644 index 0000000000..2b70e56bc9 --- /dev/null +++ b/engine/src/flutter/impeller/tools/metal/metal_library.gni @@ -0,0 +1,36 @@ +# 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. + +template("metal_library") { + assert(defined(invoker.name), "Metal library name must be specified.") + assert(defined(invoker.sources), "Metal source files must be specified.") + + metal_library_name = invoker.name + + action("$target_name") { + inputs = invoker.sources + + metal_library_path = "$target_out_dir/shaders/$metal_library_name.metallib" + + outputs = [ metal_library_path ] + + script = "//flutter/impeller/tools/metal/build_metal_library.py" + + depfile = "$target_gen_dir/shader_deps/$metal_library_name.depfile" + + args = [ + "--output", + rebase_path(metal_library_path, root_out_dir), + "--depfile", + rebase_path(depfile), + ] + + foreach(source, invoker.sources) { + args += [ + "--source", + rebase_path(source, root_out_dir), + ] + } + } +}