[fidlc] Hack to rename fuchsia.io to fuchsia.io1

In order to make room for the new fuchsia.io library (dubbed fuchsia.io2
currently), we are piggybacking the rename of the currently named
`fuchsia.io` library to `fuchsia.io1` with the migration to 64b ordinals.
In short, from an ABI standpoint, both `fuchsia.io` and `fuchsia.io1` are
the same in the soon to be 64b ordinal world.

This will only take effect once we use 64b ordinals. It has no
impact today.

Test: ordinals_tests.cc
Change-Id: Ib7282e4162d16eea059c9b5eb2e2b712e775d6a8
diff --git a/zircon/system/utest/fidl-compiler/ordinals_tests.cc b/zircon/system/utest/fidl-compiler/ordinals_tests.cc
index f9d4b77..9dc8bc3 100644
--- a/zircon/system/utest/fidl-compiler/ordinals_tests.cc
+++ b/zircon/system/utest/fidl-compiler/ordinals_tests.cc
@@ -291,6 +291,38 @@
   END_TEST;
 }
 
+bool hack_to_rename_fuchsia_io_to_fuchsia_io_one() {
+  BEGIN_TEST;
+
+  TestLibrary library_io(R"FIDL(
+library fuchsia.io;
+
+protocol SomeProtocol {
+    SomeMethod();
+};
+)FIDL");
+  ASSERT_TRUE(library_io.Compile());
+
+  TestLibrary library_io_one(R"FIDL(
+library fuchsia.io1;
+
+protocol SomeProtocol {
+    SomeMethod();
+};
+)FIDL");
+  ASSERT_TRUE(library_io_one.Compile());
+
+  const fidl::flat::Protocol* io_protocol = library_io.LookupProtocol("SomeProtocol");
+  uint64_t io_hash64 = io_protocol->methods[0].generated_ordinal64->value;
+
+  const fidl::flat::Protocol* io_one_protocol = library_io_one.LookupProtocol("SomeProtocol");
+  uint64_t io_one_hash64 = io_one_protocol->methods[0].generated_ordinal64->value;
+
+  ASSERT_EQ(io_hash64, io_one_hash64);
+
+  END_TEST;
+}
+
 }  // namespace
 
 BEGIN_TEST_CASE(ordinals_test)
@@ -300,4 +332,5 @@
 RUN_TEST(attribute_resolves_clashes)
 RUN_TEST(ordinal_value_is_sha256)
 RUN_TEST(ordinal_value_is_first64bits_of_sha256)
+RUN_TEST(hack_to_rename_fuchsia_io_to_fuchsia_io_one)
 END_TEST_CASE(ordinals_test)
diff --git a/zircon/tools/fidl/lib/ordinals.cc b/zircon/tools/fidl/lib/ordinals.cc
index af0c03a..28749bf 100644
--- a/zircon/tools/fidl/lib/ordinals.cc
+++ b/zircon/tools/fidl/lib/ordinals.cc
@@ -102,6 +102,16 @@
     }
     full_name.append(id.data(), id.size());
   }
+  // TODO(pascallouis/yifeit): Remove this once fuchsia.io has been renamed to
+  // fuchsia.io1.
+  //
+  // In order to make room for the new fuchsia.io library (dubbed fuchsia.io2
+  // currently), we are piggybacking the rename of the currently named
+  // `fuchsia.io` library to `fuchsia.io1`. In short, from an ABI standpoint,
+  // both `fuchsia.io` and `fuchsia.io1` are the same.
+  if (full_name == "fuchsia.io") {
+    full_name = "fuchsia.io1";
+  }
   full_name.append("/");
   full_name.append(container_name.data(), container_name.size());
   full_name.append(".");