[zircon][sdk] Generate SDK manifests for Zircon targets.
TO-562
TO-641
Change-Id: I10597ab9b6a19e1b7e7e15c662c001ff4160a0a4
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index 42dd8b6..4a7c94f 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -950,6 +950,13 @@
zircon_files =
exec_script("//build/zircon/list_source_files.py", [], "list lines")
+ supporting_templates = [
+ "//build/zircon/compiled_library.mako",
+ "//build/zircon/header.mako",
+ "//build/zircon/source_library.mako",
+ "//build/zircon/sysroot.mako",
+ ]
+
exec_script("//build/zircon/create_gn_rules.py",
[
"--out",
@@ -958,7 +965,7 @@
rebase_path("//out/build-zircon/build-user-${zircon_cpu}"),
],
"",
- zircon_files)
+ zircon_files + supporting_templates)
}
group("default") {
diff --git a/zircon/compiled_library.mako b/zircon/compiled_library.mako
index 52f35a1..bfda0a3 100644
--- a/zircon/compiled_library.mako
+++ b/zircon/compiled_library.mako
@@ -1,5 +1,7 @@
<%include file="header.mako" />
+import("//build/sdk/sdk_atom.gni")
+
% if data.is_shared:
_dest_dir = "root_out_dir"
% else:
@@ -29,12 +31,23 @@
}
% endif
+linked_lib = "$_out_dir/${data.lib_name}"
+% if data.is_shared:
+if (is_debug) {
+ linked_lib = "$_out_dir/lib.unstripped/${data.lib_name}"
+}
+% endif
+
config("${data.name}_config") {
include_dirs = [
% for include in sorted(data.include_dirs):
"${include}",
% endfor
]
+
+ libs = [
+ linked_lib,
+ ]
}
group("${data.name}") {
@@ -53,3 +66,31 @@
":${data.name}_config",
]
}
+
+sdk_atom("${data.name}_sdk") {
+ % if data.is_shared:
+ prefix = "shared"
+ % else:
+ prefix = "static"
+ % endif
+ name = "cpp:compiled_$prefix:${data.name}"
+
+ files = [
+ % for dest, source in sorted(data.includes.iteritems()):
+ {
+ source = "${source}"
+ dest = "${dest}"
+ },
+ % endfor
+ {
+ source = "${data.prebuilt}"
+ dest = "${data.lib_name}"
+ },
+ % if data.is_shared:
+ {
+ source = "${data.debug_prebuilt}"
+ dest = "debug/${data.lib_name}"
+ },
+ % endif
+ ]
+}
diff --git a/zircon/create_gn_rules.py b/zircon/create_gn_rules.py
index b820525..567358c 100755
--- a/zircon/create_gn_rules.py
+++ b/zircon/create_gn_rules.py
@@ -157,6 +157,7 @@
def __init__(self, name):
self.name = name
+ self.includes = {}
self.include_dirs = set()
self.deps = []
self.lib_name = ''
@@ -175,6 +176,7 @@
# Includes.
for name, path in package.get('includes', {}).iteritems():
(file, folder) = extract_file(name, path, context)
+ data.includes[name] = '//%s' % file
data.include_dirs.add('//%s' % folder)
# Lib.
diff --git a/zircon/source_library.mako b/zircon/source_library.mako
index faa9d3e..9b4885e 100644
--- a/zircon/source_library.mako
+++ b/zircon/source_library.mako
@@ -1,5 +1,7 @@
<%include file="header.mako" />
+import("//build/cpp/sdk_source_set.gni")
+
config("${data.name}_config") {
include_dirs = [
% for include in sorted(data.include_dirs):
@@ -8,7 +10,7 @@
]
}
-source_set("${data.name}") {
+sdk_source_set("${data.name}") {
sources = [
% for source in sorted(data.sources):
@@ -16,7 +18,7 @@
% endfor
]
- deps = [
+ public_deps = [
% for dep in sorted(data.deps):
"../${dep}",
% endfor
diff --git a/zircon/sysroot.mako b/zircon/sysroot.mako
index e1d9e10..95c0d38 100644
--- a/zircon/sysroot.mako
+++ b/zircon/sysroot.mako
@@ -1,5 +1,7 @@
<%include file="header.mako" />
+import("//build/sdk/sdk_atom.gni")
+
_out_dir = get_label_info(":bogus", "target_out_dir")
<%def name="copy_target(path)">${"copy_%s" % path.replace('/', '_').replace('.', '_')}</%def>
@@ -26,3 +28,15 @@
]
}
+sdk_atom("sysroot_sdk") {
+ name = "sysroot"
+
+ files = [
+ % for path, file in sorted(data.files.iteritems()):
+ {
+ source = "${file}"
+ dest = "${path}"
+ },
+ % endfor
+ ]
+}