Revert "[fuchsia] Reland "Generate BUILD.gn from SDK metadata...""

This reverts commit 386fa9a70028f97ce511bc7bf84e5ce96e47f926.

Reason for revert:
Broke the fuchsia_sdk update step, see bug.

Original change's description:
> [fuchsia] Reland "Generate BUILD.gn from SDK metadata..."
> 
> Reland of CL https://chromium-review.googlesource.com/c/chromium/src/+/1241842.
> (Confirmed that the code builds on Cast builders, and manually examined
> all references to targets under //third_party/fuchsia-sdk to verify
> that all FIDL targets have been modified to reference the new sdk/
> subdir.)
> 
> This script uses the metadata JSON files in the SDK to generate a
> BUILD.gn in //third_party/fuchsia-sdk/sdk. The build file is
> regenerated whenever a new SDK is downloaded using "gclient sync".
> 
> Only FIDL libraries are migrated for now. Additional metadata types can
> be migrated in followup CLs.
> 
> TBR=scottmg@chromium.org
> TBR=sky@chromium.org
> 
> Bug: 888753
> Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
> Change-Id: I7ec714982cdfbb6f6ccd8fad3cd7cbb48af4eb1c
> Reviewed-on: https://chromium-review.googlesource.com/1246681
> Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
> Reviewed-by: Kevin Marshall <kmarshall@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#594419}

TBR=kmarshall@chromium.org

Change-Id: I1a89a1c3d8223e6dd58e2a4b23f251eb96a7bba8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 888753, 889839
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Reviewed-on: https://chromium-review.googlesource.com/1249203
Reviewed-by: Hans Wennborg <hans@chromium.org>
Commit-Queue: Hans Wennborg <hans@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#594671}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 712b34569c5dad99d67ad7ade9e4c456f61a3de0
diff --git a/BUILD.gn b/BUILD.gn
index 19b0fa5..704e8f4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -153,6 +153,157 @@
   ]
 }
 
+fuchsia_sdk_fidl_pkg("fonts") {
+  namespace = "fuchsia"
+  namespace_path = "fuchsia"
+  sources = [
+    "font_provider.fidl",
+  ]
+  deps = [
+    ":mem",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("gfx") {
+  namespace = "fuchsia.ui"
+  namespace_path = "fuchsia/ui"
+  sources = [
+    "commands.fidl",
+    "display_info.fidl",
+    "events.fidl",
+    "hit.fidl",
+    "nodes.fidl",
+    "renderer.fidl",
+    "resources.fidl",
+    "shapes.fidl",
+    "types.fidl",
+  ]
+  deps = [
+    ":images",
+    ":mem",
+    ":vectorial",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("images") {
+  namespace = "fuchsia"
+  namespace_path = "fuchsia"
+  sources = [
+    "encoded_image.fidl",
+    "image_info.fidl",
+    "image_pipe.fidl",
+    "memory_type.fidl",
+    "presentation_info.fidl",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("input") {
+  namespace = "fuchsia.ui"
+  namespace_path = "fuchsia/ui"
+  sources = [
+    "commands.fidl",
+    "ime_service.fidl",
+    "input_connection.fidl",
+    "input_device_registry.fidl",
+    "input_dispatcher.fidl",
+    "input_event_constants.fidl",
+    "input_events.fidl",
+    "input_reports.fidl",
+    "text_editing.fidl",
+    "text_input.fidl",
+    "usages.fidl",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("math") {
+  namespace = "fuchsia"
+  namespace_path = "fuchsia"
+  sources = [
+    "math.fidl",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("media") {
+  namespace = "fuchsia"
+  namespace_path = "fuchsia"
+
+  sources = [
+    "audio.fidl",
+    "audio_device_enumerator.fidl",
+    "audio_in.fidl",
+    "audio_out.fidl",
+    "gain_control.fidl",
+    "stream.fidl",
+    "stream_type.fidl",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("mem") {
+  namespace = "fuchsia"
+  namespace_path = "fuchsia"
+
+  sources = [
+    "buffer.fidl",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("netstack") {
+  namespace = "fuchsia"
+  namespace_path = "fuchsia"
+
+  sources = [
+    "net_address.fidl",
+    "netstack.fidl",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("oldhttp") {
+  namespace = "fuchsia.net"
+  namespace_path = "fuchsia/net"
+  sources = [
+    "http_error.fidl",
+    "http_header.fidl",
+    "http_service.fidl",
+    "url_body.fidl",
+    "url_loader.fidl",
+    "url_request.fidl",
+    "url_response.fidl",
+  ]
+  deps = [
+    ":mem",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("policy") {
+  namespace = "fuchsia.ui"
+  namespace_path = "fuchsia/ui"
+  sources = [
+    "display_usage.fidl",
+    "presentation.fidl",
+    "presenter.fidl",
+  ]
+  deps = [
+    ":viewsv1",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("scenic") {
+  namespace = "fuchsia.ui"
+  namespace_path = "fuchsia/ui"
+  sources = [
+    "commands.fidl",
+    "events.fidl",
+    "scenic.fidl",
+    "session.fidl",
+  ]
+  deps = [
+    ":gfx",
+    ":input",
+    ":sys",
+    ":views",
+  ]
+}
+
 fuchsia_sdk_pkg("svc") {
   sources = [
     "include/lib/svc/dir.h",
@@ -161,6 +312,79 @@
   libs = [ "svc" ]
 }
 
+fuchsia_sdk_fidl_pkg("sys") {
+  namespace = "fuchsia"
+  namespace_path = "fuchsia"
+
+  sources = [
+    "component_controller.fidl",
+    "environment.fidl",
+    "environment_controller.fidl",
+    "flat_namespace.fidl",
+    "launcher.fidl",
+    "loader.fidl",
+    "runner.fidl",
+    "service_provider.fidl",
+  ]
+  deps = [
+    ":mem",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("vectorial") {
+  namespace = "fuchsia.ui"
+  namespace_path = "fuchsia/ui"
+  sources = [
+    "commands.fidl",
+    "events.fidl",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("views") {
+  namespace = "fuchsia.ui"
+  namespace_path = "fuchsia/ui"
+
+  sources = [
+    "commands.fidl",
+    "events.fidl",
+  ]
+  deps = [
+    ":gfx",
+    ":images",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("viewsv1") {
+  namespace = "fuchsia.ui"
+  namespace_path = "fuchsia/ui"
+
+  sources = [
+    "view_containers.fidl",
+    "view_manager.fidl",
+    "view_properties.fidl",
+    "view_provider.fidl",
+    "view_tree_token.fidl",
+    "view_trees.fidl",
+    "views.fidl",
+  ]
+  deps = [
+    ":gfx",
+    ":images",
+    ":math",
+    ":scenic",
+    ":viewsv1token",
+  ]
+}
+
+fuchsia_sdk_fidl_pkg("viewsv1token") {
+  namespace = "fuchsia.ui"
+  namespace_path = "fuchsia/ui"
+
+  sources = [
+    "view_token.fidl",
+  ]
+}
+
 fuchsia_sdk_pkg("zx") {
   sources = [
     "channel.cpp",
diff --git a/fuchsia_sdk_pkg.gni b/fuchsia_sdk_pkg.gni
index 0ab4787..b9b1005 100644
--- a/fuchsia_sdk_pkg.gni
+++ b/fuchsia_sdk_pkg.gni
@@ -39,9 +39,16 @@
              "SDK packages with namespace must specify namespace_path")
       namespace = invoker.namespace
       namespace_path = invoker.namespace_path
+
+      _library_name = "${namespace}.${_package_name}"
+    } else {
+      _library_name = _package_name
     }
 
-    sources = invoker.sources
+    sources = []
+    foreach(file, invoker.sources) {
+      sources += [ "sdk/fidl/${_library_name}/${file}" ]
+    }
   }
 }
 
diff --git a/gen_build_defs.py b/gen_build_defs.py
deleted file mode 100755
index bc4abdf..0000000
--- a/gen_build_defs.py
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/usr/bin/env python
-# Copyright 2018 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-#
-# Generates a single BUILD.gn file with build targets generated using the
-# manifest files in the SDK.
-
-import json
-import os
-import subprocess
-import sys
-
-
-# Inserted at the top of the generated BUILD.gn file.
-_GENERATED_PREAMBLE = """# DO NOT EDIT! This file was generated by
-# //third_party/fuchsia-sdk/gen_build_defs.py.
-# Any changes made to this file will be discarded.
-
-import("//third_party/fuchsia-sdk/fuchsia_sdk_pkg.gni")
-
-"""
-
-
-def SerializeListOfStrings(strings):
-  """Outputs a list of strings in GN-friendly, double-quoted format."""
-
-  return '[' + ','.join(['"{}"'.format(s) for s in strings]) + ']'
-
-
-def ConvertFidlLibrary(json):
-  """Massages the manifest data to match the format required by the GN build
-  and outputs a GN target for the FIDL library
-
-  Arguments:
-    json: The parsed manifest JSON.
-  Returns:
-    The GN target definition, represented as a string."""
-
-  json['deps'] = SerializeListOfStrings(
-      [':' + dep.split('.')[-1] for dep in json['deps']])
-  json['sources'] = SerializeListOfStrings(json['sources'])
-
-  name_tokenized = json['name'].split('.')
-  json['shortname'] = name_tokenized[-1]
-  json['namespace'] = '.'.join(name_tokenized[:-1])
-  json['namespace_path'] = json['namespace'].replace('.', '/')
-
-  return """fuchsia_sdk_fidl_pkg("{shortname}") {{
-    namespace = "{namespace}"
-    namespace_path = "{namespace_path}"
-    public_deps = {deps}
-    sources = {sources}
-  }}""".format(**json)
-
-
-def ConvertNoOp(json):
-  """Null implementation of a conversion function. No output is generated."""
-
-  return ""
-
-
-"""Maps manifest type strings to relevant conversion functions."""
-_CONVERSION_FUNCTION_MAP = {
-  'fidl_library': ConvertFidlLibrary,
-
-  # TODO(888753): Add conversion routines for these manifest types and migrate
-  # existing dependents of //third_party/fuchsia_sdk/BUILD.gn to use the
-  # generated targets instead. The migration can be executed incrementally.
-  'cc_source_library': ConvertNoOp,
-  'cc_prebuilt_library': ConvertNoOp,
-  'host_tool': ConvertNoOp,
-  'image': ConvertNoOp,
-  'loadable_module': ConvertNoOp,
-  'sysroot': ConvertNoOp,
-}
-
-
-def ConvertSdkManifests():
-  sdk_base_dir = os.path.join(os.path.dirname(__file__), 'sdk')
-  toplevel_meta = json.load(open(os.path.join(sdk_base_dir, 'meta',
-                                              'manifest.json')))
-
-  build_output_path = os.path.join(sdk_base_dir, 'BUILD.gn')
-  with open(build_output_path, 'w') as buildfile:
-    buildfile.write(_GENERATED_PREAMBLE)
-
-    for next_part in toplevel_meta['parts']:
-      parsed = json.load(open(os.path.join(sdk_base_dir, next_part)))
-      if 'type' not in parsed:
-        raise Exception("Couldn't find 'type' node in %s." % next_part)
-
-      convert_function = _CONVERSION_FUNCTION_MAP.get(parsed['type'])
-      if convert_function is None:
-        raise Exception('Unexpected SDK artifact type %s in %s.' %
-                        (parsed['type'], next_part))
-      buildfile.write(convert_function(parsed))
-
-  # Use 'gn format' to make the buildfile readable.
-  gn_path = os.path.join(os.path.dirname(__file__), os.path.pardir,
-                         os.path.pardir, 'buildtools', 'linux64', 'gn')
-  subprocess.check_call([gn_path, 'format', build_output_path],
-                        stdout=open(os.devnull))
-
-
-if __name__ == '__main__':
-  sys.exit(ConvertSdkManifests())