Skip to content

Commit

Permalink
SKQP Build for Fuchsia SDK
Browse files Browse the repository at this point in the history
Change-Id: I2619784eca0f7a4dd66f2db0104cb746d9266b4e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244369
Commit-Queue: John Rosasco <[email protected]>
Reviewed-by: Brian Salomon <[email protected]>
Reviewed-by: Mike Klein <[email protected]>
  • Loading branch information
rosasco-wk authored and Skia Commit-Bot committed Nov 18, 2019
1 parent 83f76ac commit 24cbdab
Show file tree
Hide file tree
Showing 28 changed files with 1,186 additions and 44 deletions.
49 changes: 35 additions & 14 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import("gn/fuchsia_defines.gni")
import("gn/shared_sources.gni")
import("gn/skia.gni")

if (is_fuchsia) {
import("//build/fuchsia/sdk.gni")
import("build/fuchsia/fuchsia_download_sdk.gni")
}

if (skia_use_dawn) {
import("third_party/externals/dawn/scripts/dawn_features.gni")
}
Expand Down Expand Up @@ -316,9 +321,9 @@ optional("fontmgr_fuchsia") {
deps = []

if (is_fuchsia && using_fuchsia_sdk) {
deps += [ "$fuchsia_sdk_root/fidl:fuchsia.fonts" ]
deps += [ "//build/fuchsia/fidl:fuchsia.fonts" ]
} else {
deps += [ "//sdk/fidl/fuchsia.fonts" ]
deps = [ "//sdk/fidl/fuchsia.fonts" ]
}
sources = [
"src/ports/SkFontMgr_fuchsia.cpp",
Expand Down Expand Up @@ -1167,8 +1172,6 @@ if (skia_enable_tools) {
}

config("our_vulkan_headers") {
# We add this directory to simulate the client already have
# vulkan/vulkan_core.h on their path.
include_dirs = [ "include/third_party/vulkan" ]
}

Expand Down Expand Up @@ -1294,11 +1297,15 @@ if (skia_enable_tools) {
"tools/gpu/TestContext.cpp",
"tools/gpu/YUVUtils.cpp",
"tools/gpu/YUVUtils.h",
"tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp",
"tools/gpu/gl/GLTestContext.cpp",
"tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
"tools/gpu/mock/MockTestContext.cpp",
]
if (skia_use_gl) {
sources += [
"tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp",
"tools/gpu/gl/GLTestContext.cpp",
"tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
]
}

libs = []

Expand All @@ -1321,6 +1328,8 @@ if (skia_enable_tools) {
if (target_cpu != "arm64") {
libs += [ "OpenGL32.lib" ]
}
} else if (is_fuchsia && using_fuchsia_sdk) {
libs += [ "${fuchsia_sdk_path}/arch/${target_cpu}/sysroot/lib/libzircon.so" ]
}

cflags_objcc = [ "-fobjc-arc" ]
Expand All @@ -1341,7 +1350,7 @@ if (skia_enable_tools) {
public_deps += [ "//third_party/dawn:dawn_headers" ]
sources += [ "tools/gpu/dawn/DawnTestContext.cpp" ]
}
}
} # test_lib("gpu_tool_utils")

test_lib("flags") {
sources = [
Expand Down Expand Up @@ -1489,6 +1498,9 @@ if (skia_enable_tools) {
import("gn/gm.gni")
test_lib("gm") {
sources = gm_sources
if (skia_use_gl) {
sources += gl_gm_sources
}
deps = [
":etc1",
":flags",
Expand Down Expand Up @@ -1527,6 +1539,9 @@ if (skia_enable_tools) {
sources += metal_tests_sources
cflags_objcc = [ "-fobjc-arc" ]
}
if (skia_use_gl) {
sources += gl_tests_sources
}
if (!skia_enable_fontmgr_android) {
sources -= [ "//tests/FontMgrAndroidParserTest.cpp" ]
}
Expand Down Expand Up @@ -2028,7 +2043,6 @@ if (skia_enable_tools) {
]
deps = [
":gm",
":gpu_tool_utils",
":skia",
":tests",
":tool_utils",
Expand All @@ -2038,11 +2052,9 @@ if (skia_enable_tools) {
sources = [
"tools/skqp/src/skqp_main.cpp",
]
deps = [
":skia",
":skqp_lib",
":tool_utils",
]
include_dirs = [ "//" ]
lib_dirs = []
deps = [ ":skqp_lib", ]
}
test_app("jitter_gms") {
sources = [
Expand All @@ -2055,6 +2067,15 @@ if (skia_enable_tools) {
]
}
}
if (is_fuchsia) {
# Build a package repository for skqp on Fuchsia.
group("skqp_repo") {
testonly = true
deps = [
"//build/fuchsia/skqp:skqp_repo"
]
}
}
if (is_android) {
shared_library("libskqp_app") {
configs += [ ":skia_private" ]
Expand Down
32 changes: 32 additions & 0 deletions build/fuchsia/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2019 Google LLC.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_fuchsia)

import ("//build/fuchsia/sdk.gni")

fuchsia_sdk_manifest_exists = false
if (is_fuchsia && using_fuchsia_sdk) {
manifest_exists = exec_script("//build/fuchsia/file_exists",
[ "-file_name",
rebase_path(fuchsia_sdk_manifest_path) ],
"list lines",
[ "//build/fuchsia/file_exists" ])
if (manifest_exists == [ "true" ]) {
fuchsia_sdk_manifest_exists = true
}
}

group("fuchsia") {
if(fuchsia_sdk_manifest_exists == true) {
deps = [
"fidl",
"pkg",
"sysroot",
]
} else {
assert(false, "Fuchsia SDK not found. Set arg skia_update_fuchsia_sdk=True " +
"to initialize.")
}
}
14 changes: 14 additions & 0 deletions build/fuchsia/fidl/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2019 Google LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_fuchsia)
import("//build/fuchsia/sdk.gni")

#
# Generate gn targets for fidl libraries in the Fuchsia SDK.
#
fuchsia_sdk("fidl") {
meta = fuchsia_sdk_manifest_path
enabled_parts = [ "fidl_library" ]
}
92 changes: 92 additions & 0 deletions build/fuchsia/fidl_gen_cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/usr/bin/env python

# Copyright 2019 Google LLC.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""
Generate C/C++ headers and source files from the set of FIDL files
specified in the meta.json manifest.
"""

import argparse
import collections
import json
import os
import subprocess
import sys

def GetFIDLFilesRecursive(libraries, sdk_base, path):
with open(path) as json_file:
parsed = json.load(json_file)
result = []
deps = parsed['deps']
for dep in deps:
dep_meta_json = os.path.abspath('%s/fidl/%s/meta.json' % (sdk_base, dep))
GetFIDLFilesRecursive(libraries, sdk_base, dep_meta_json)
libraries[parsed['name']] = result + parsed['sources']

def GetFIDLFilesByLibraryName(sdk_base, root):
libraries = collections.OrderedDict()
GetFIDLFilesRecursive(libraries, sdk_base, root)
return libraries

def main():
parser = argparse.ArgumentParser()

parser.add_argument('--fidlc-bin', dest='fidlc_bin', action='store', required=True)
parser.add_argument('--fidlgen-bin', dest='fidlgen_bin', action='store', required=True)

parser.add_argument('--sdk-base', dest='sdk_base', action='store', required=True)
parser.add_argument('--root', dest='root', action='store', required=True)
parser.add_argument('--json', dest='json', action='store', required=True)
parser.add_argument('--include-base', dest='include_base', action='store', required=True)
parser.add_argument('--output-base-cc', dest='output_base_cc', action='store', required=True)
parser.add_argument('--output-c-header', dest='output_header_c', action='store', required=True)
parser.add_argument('--output-c-tables', dest='output_c_tables', action='store', required=True)

args = parser.parse_args()

assert os.path.exists(args.fidlc_bin)
assert os.path.exists(args.fidlgen_bin)

fidl_files_by_name = GetFIDLFilesByLibraryName(args.sdk_base, args.root)

fidlc_command = [
args.fidlc_bin,
'--c-header',
args.output_header_c,
'--tables',
args.output_c_tables,
'--json',
args.json
]

for _, fidl_files in fidl_files_by_name.iteritems():
fidlc_command.append('--files')
for fidl_file in fidl_files:
fidl_abspath = os.path.abspath('%s/%s' % (args.sdk_base, fidl_file))
fidlc_command.append(fidl_abspath)

subprocess.check_call(fidlc_command)

assert os.path.exists(args.json)

fidlgen_command = [
args.fidlgen_bin,
'-generators',
'cpp',
'-include-base',
args.include_base,
'-json',
args.json,
'-output-base',
args.output_base_cc
]

subprocess.check_call(fidlgen_command)

return 0

if __name__ == '__main__':
sys.exit(main())
19 changes: 19 additions & 0 deletions build/fuchsia/file_exists
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python

# Copyright 2019 Google LLC.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""
Prints "true" if the input |file_name| exists.
"""

import argparse
import os

parser = argparse.ArgumentParser()
parser.add_argument("-file_name", type=str,
help="File name for which to check existence for.")
args = parser.parse_args()
if os.path.exists(args.file_name):
print "true"
18 changes: 18 additions & 0 deletions build/fuchsia/fuchsia_download_sdk.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2019 Google LLC.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import ("../../gn/skia.gni")
import ("//build/fuchsia/sdk.gni")

if(is_fuchsia && skia_update_fuchsia_sdk &&
current_toolchain == default_toolchain) {
cipd_dir = "${fuchsia_sdk_path}/../cipd"
update_sdk_out = exec_script("//build/fuchsia/update_fuchsia_sdk",
[ "-sdk_dir=" + rebase_path(fuchsia_sdk_path),
"-clang_dir=" + rebase_path(fuchsia_toolchain_path),
"-cipd_cache_dir=" + rebase_path(cipd_dir),
"-cipd_clang_version=git_revision:a6e1de4afc51560df18c95cb616dec51248ed660" ],
"list lines",
[ "//build/fuchsia/update_fuchsia_sdk" ])
}
58 changes: 58 additions & 0 deletions build/fuchsia/gen_package
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python

# Copyright 2019 Google LLC. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""
Builds a Fuchsia FAR archive.
"""

import argparse
import os
import subprocess
import sys

def main():
parser = argparse.ArgumentParser()

parser.add_argument('--pm-bin', dest='pm_bin', action='store', required=True)
parser.add_argument(
'--pkg-dir', dest='pkg_dir', action='store', required=True)
parser.add_argument(
'--pkg-name', dest='pkg_name', action='store', required=True)
parser.add_argument(
'--pkg-version', dest='pkg_version', action='store', required=True)
parser.add_argument(
'--pkg-manifest', dest='pkg_manifest', action='store', required=True)

args = parser.parse_args()

assert os.path.exists(args.pm_bin)
assert os.path.exists(args.pkg_dir)

pkg_dir = args.pkg_dir
pkg_name = args.pkg_name
pkg_manifest = args.pkg_manifest
pkg_version = args.pkg_version

pm_command_base = [
args.pm_bin,
'-o',
pkg_dir,
]

# Create the package ID file.
subprocess.check_call(pm_command_base + ['-n'] + [pkg_name] + ['init'])

# Build the package.
subprocess.check_call(pm_command_base + ['-m'] + [pkg_manifest] + ['build'])

# Archive the package.
subprocess.check_call(pm_command_base + ['-m'] + [pkg_manifest] + ['-version'] + [pkg_version] + ['archive'])

return 0


if __name__ == '__main__':
sys.exit(main())
Loading

0 comments on commit 24cbdab

Please sign in to comment.