Wire up metal library generation.

This commit is contained in:
Chinmay Garde
2021-05-01 20:02:30 -07:00
committed by Dan Field
parent c73b643cce
commit 8182721179
4 changed files with 101 additions and 31 deletions

View File

@@ -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",
]
}

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@@ -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()

View File

@@ -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),
]
}
}
}