Skip to content

Commit

Permalink
GN file generation
Browse files Browse the repository at this point in the history
Add logic for writing GN files from descriptions.

Bug: 1291994
Change-Id: Icc243953aa2ac6c18d5ecec854ca9d6ae1d99d76

Cq-Include-Trybots: luci.chromium.try:android-rust-arm-dbg,android-rust-arm-rel,linux-rust-x64-dbg,linux-rust-x64-rel
Change-Id: Icc243953aa2ac6c18d5ecec854ca9d6ae1d99d76
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3820264
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Auto-Submit: Collin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1034727}
  • Loading branch information
chbaker0 authored and Chromium LUCI CQ committed Aug 12, 2022
1 parent 104bc21 commit a495419
Show file tree
Hide file tree
Showing 14 changed files with 779 additions and 18 deletions.
5 changes: 4 additions & 1 deletion tools/crates/gnrt/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2022 The Chromium Authors. All rights reserved.
# Copyright 2022 The Chromium Authors.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

Expand All @@ -19,6 +19,7 @@ rust_static_library("gnrt_lib") {
sources = [
"crates.rs",
"deps.rs",
"gn.rs",
"lib.rs",
"manifest.rs",
"paths.rs",
Expand All @@ -45,6 +46,7 @@ test("gnrt_unittests") {
rs_sources = [
"crates_unittest.rs",
"deps_unittest.rs",
"gn_unittest.rs",
"manifest_unittest.rs",
"platforms_unittest.rs",
]
Expand All @@ -61,6 +63,7 @@ test("gnrt_unittests") {
"//third_party/rust/semver/v1:lib",
"//third_party/rust/serde/v1:lib",
"//third_party/rust/serde_json/v1:lib",
"//third_party/rust/tempfile/v3:lib",
"//third_party/rust/toml/v0_5:test_support",
]

Expand Down
16 changes: 12 additions & 4 deletions tools/crates/gnrt/crates.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 The Chromium Authors. All rights reserved.
// Copyright 2022 The Chromium Authors.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down Expand Up @@ -210,12 +210,20 @@ pub struct ThirdPartyCrate {
}

impl ThirdPartyCrate {
/// The location of this crate relative to the third-party Rust crate
/// directory. Crates are laid out according to their name and epoch.
pub fn crate_path(&self) -> PathBuf {
/// The location of this crate's directory, including its source subdir and
/// build files, relative to the third-party Rust crate directory. Crates
/// are laid out according to their name and epoch.
pub fn build_path(&self) -> PathBuf {
let mut path = PathBuf::new();
path.push(NormalizedName::from_crate_name(&self.name).0);
path.push(self.epoch.to_string());
path
}

/// The location of this crate's source relative to the third-party Rust
/// crate directory.
pub fn crate_path(&self) -> PathBuf {
let mut path = self.build_path();
path.push("crate");
path
}
Expand Down
2 changes: 1 addition & 1 deletion tools/crates/gnrt/crates_unittest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 The Chromium Authors. All rights reserved.
// Copyright 2022 The Chromium Authors.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
2 changes: 1 addition & 1 deletion tools/crates/gnrt/deps.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 The Chromium Authors. All rights reserved.
// Copyright 2022 The Chromium Authors.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
2 changes: 1 addition & 1 deletion tools/crates/gnrt/deps_unittest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 The Chromium Authors. All rights reserved.
// Copyright 2022 The Chromium Authors.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand Down
Loading

0 comments on commit a495419

Please sign in to comment.