)]}'
{
  "commit": "46f94b5a7f5527b5d7ef57271d3e9447a65e22ac",
  "tree": "8e4efa88c7ccb332a57d188c83bb83b721ddba56",
  "parents": [
    "bc4407c605a60c1f78b3b48b2fbca44bc45af2da"
  ],
  "author": {
    "name": "danakj",
    "email": "danakj@chromium.org",
    "time": "Mon Mar 07 09:30:14 2022 -0500"
  },
  "committer": {
    "name": "Commit Bot",
    "email": "commit-bot@chromium.org",
    "time": "Wed Mar 09 18:37:17 2022 +0000"
  },
  "message": "All accessible crates should be specified by a public --extern\n\nCurrently direct dependencies are added to the rustc command line as\n`--extern cratename:path/to/rlib/file` which tells rustc how to resolve\nany references to the crate. In compiler terms, it adds the dependency\ncrate to the currently-being-compiled crate\u0027s \"extern prelude\", making\nit available throughout the crate.\n\nGN uses public_deps to express that a dependency should be available\nnot just in the current crate but in anything that depends on it. That\nmeans a crate that is reachable from the currently-compiling-crate\nfrom a direct dependency + a chain-of-public_deps should also be\naccessible to be used. To do so, it needs to appear in the extern\nprelude by passing it to --extern.\n\nCurrently all transitive dependencies are represented on the command-\nline via `-Ldependency\u003dpath/to/rlib/dir` in order for rustc to find\nthe crates, but this does not allow the currently-compiling-crate to\nuse them itself.\n\nTo resolve this issue, we add any crates publicly-accessible to the\nlist of externs, to be listed with the `--extern` flag. We also continue\nto list them with `-Ldependency` in order for rustc to also find them\nwhen used inside a dependency.\n\nThis is of special interest for dynamic libraries. If a rust dylib\ndepends on crate A via public_deps and crate B via deps, then a\ntarget that makes use of the dylib should also gain access to crate\nA without linking A into its own link target. This is now supported\nas depending on the dylib would gain `--extern thedylib:path` as\nwell as `--extern A:path` on the rustc command line.\n\nAlong the way, we ensure that rust crate aliases written in the\ncurrently-compiling-crate will apply not just to direct dependencies\nbut also to transitive public dependencies, and we add a unit test\nfor this case.\n\nAn example BUILD.gn that works after this change, but not without it:\n\nrust_library(\"rust_repro_inner_lib\") {\n  sources \u003d [\"rust_repro_inner_lib.rs\"]\n  crate_root \u003d \"rust_repro_inner_lib.rs\"\n}\n\nrust_library(\"rust_repro_dylib\") {\n  sources \u003d [\"rust_repro_dylib.rs\"]\n  crate_root \u003d \"rust_repro_dylib.rs\"\n  public_deps \u003d [\":rust_repro_inner_lib\"]\n}\n\nshared_library(\"rust_repro_dylib_so\") {\n  public_deps \u003d [\":rust_repro_dylib\"]\n}\n\nrust_library(\"rust_repro_lib\") {\n  sources \u003d [\"rust_repro_lib.rs\"]\n  crate_root \u003d \"rust_repro_lib.rs\"\n  public_deps \u003d [\":rust_repro_dylib_so\"]\n}\n\nexecutable(\"rust_repro_bin\") {\n  sources \u003d [\"rust_repro_bin.rs\"]\n  crate_root \u003d \"rust_repro_bin.rs\"\n  deps \u003d [ \":rust_repro_lib\" ]\n}\n\nWithout this change, rust_repro_bin.rs is unable to call functions in\nrust_repro_dylib or rust_repro_inner_lib, though they are in the set of\naccessible dependencies.\n\nBug: 276\nChange-Id: I772b4728a848d9e54ffc876383990df2bf66bd42\nReviewed-on: https://gn-review.googlesource.com/c/gn/+/13060\nReviewed-by: Brett Wilson \u003cbrettw@chromium.org\u003e\nCommit-Queue: Brett Wilson \u003cbrettw@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "5b518b3edd198b1cb14ee7ca9d3c57e031d4eb07",
      "old_mode": 33188,
      "old_path": "src/gn/ninja_c_binary_target_writer.cc",
      "new_id": "3321191f045a8c6abb57738154390e37e3b520a6",
      "new_mode": 33188,
      "new_path": "src/gn/ninja_c_binary_target_writer.cc"
    },
    {
      "type": "modify",
      "old_id": "d894681608d14fd7fd6df6cfc4e4e0be93b9c8c4",
      "old_mode": 33188,
      "old_path": "src/gn/ninja_rust_binary_target_writer.cc",
      "new_id": "0fd26c0bf4754ea4f0e24b3c4afdb1cadbbde425",
      "new_mode": 33188,
      "new_path": "src/gn/ninja_rust_binary_target_writer.cc"
    },
    {
      "type": "modify",
      "old_id": "0319c86292a34246ccbc31a7f1e0b76b7790c3c8",
      "old_mode": 33188,
      "old_path": "src/gn/ninja_rust_binary_target_writer.h",
      "new_id": "69ec916454b47651955ad800cc9d6975def93743",
      "new_mode": 33188,
      "new_path": "src/gn/ninja_rust_binary_target_writer.h"
    },
    {
      "type": "modify",
      "old_id": "b4b71d64ee25e2a47baee48c1214f4642b7cd327",
      "old_mode": 33188,
      "old_path": "src/gn/ninja_rust_binary_target_writer_unittest.cc",
      "new_id": "29f9756e332981cd6afc2fb4dab9c2857e587ec8",
      "new_mode": 33188,
      "new_path": "src/gn/ninja_rust_binary_target_writer_unittest.cc"
    },
    {
      "type": "modify",
      "old_id": "508ad7e11e635a4a8e4a6a1ef1b756c76d18eda5",
      "old_mode": 33188,
      "old_path": "src/gn/target.cc",
      "new_id": "c491897440557ed6d7ff1d74e9acba0293609a55",
      "new_mode": 33188,
      "new_path": "src/gn/target.cc"
    },
    {
      "type": "modify",
      "old_id": "d88f0a57a7a02571dd1cf31f05a8ffea7a16f461",
      "old_mode": 33188,
      "old_path": "src/gn/target.h",
      "new_id": "de076a84dbfb10ffee51c588018d76816afa2ff1",
      "new_mode": 33188,
      "new_path": "src/gn/target.h"
    }
  ]
}
