Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move ffi/gn to docs/tutorials/gn #4535

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,8 @@ jobs:
id: gn-third-party-tools-cache
with:
path: |
ffi/gn/third_party_tools
key: ${{ runner.os }}-${{ hashFiles('tools/make/gn.toml', 'ffi/gn/Cargo.lock') }}
docs/tutorials/gn/third_party_tools
key: ${{ runner.os }}-${{ hashFiles('tools/make/gn.toml', 'docs/tutorials/gn/Cargo.lock') }}
- name: Install GN Third-Party Tools
if: steps.gn-third-party-tools-cache.outputs.cache-hit != 'true'
run: cargo make gn-install
Expand Down
4 changes: 2 additions & 2 deletions .gn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this file for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It defines the root, which must be an ancestor of code being built

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
buildconfig = "//ffi/gn/BUILDCONFIG.gn"
root = "//ffi/gn:default"
buildconfig = "//docs/tutorials/gn/BUILDCONFIG.gn"
root = "//docs/tutorials/gn:default"
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ components/normalizer/ @hsivonen @echeran
components/plurals/ @zbraniecki @sffc
components/segmenter/ @aethanyc @makotokato @sffc
components/timezone/ @nordzilla
docs/tutorials/gn/ @sffc
experimental/bies/ @sffc
experimental/compactdecimal/ @eggrobin
experimental/displaynames/ @sffc @snktd
experimental/ecma402/ @filmil
experimental/harfbuzz/ @hsivonen
experimental/relativetime/ @pdogr
ffi/capi/ @Manishearth
ffi/gn/ @sffc
provider/blob/ @sffc @Manishearth
provider/core/ @sffc @Manishearth
provider/datagen/ @sffc @robertbastian @Manishearth
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ members = [
# implicitly excluded from the main workspace.
exclude = [
# GNaw needs to be run from outside the workspace for features to work
"ffi/gn",
"docs/tutorials/gn",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: docs is already excluded

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Testdata will still be published in the 1.x stream, but is deprecated
# and we don't use it anymore. As we don't want to keep the actual data
# in the repo it doesn't build without running `cargo make testdata-legacy`
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions ffi/gn/BUILD.gn → docs/tutorials/gn/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

group("default") {
deps = [
"//ffi/gn/hello_world:print_hello",
"//ffi/gn/icu4x:icu_capi"
"//docs/tutorials/gn/hello_world:print_hello",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to define the root as docs/tutorials/gn?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either this or using a symlink; prefer making the GN root the repo root. Clients vendoring ICU4X don't need this part of the setup

"//docs/tutorials/gn/icu4x:icu_capi"
]
}
8 changes: 4 additions & 4 deletions ffi/gn/BUILDCONFIG.gn → docs/tutorials/gn/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if (current_os == "") {
current_os = target_os
}

_configs = [ "//ffi/gn/build:rust_defaults" ]
_configs = [ "//docs/tutorials/gn/build:rust_defaults" ]

set_defaults("executable") {
configs = _configs
Expand All @@ -39,12 +39,12 @@ set_defaults("rust_library") {
# doing cross-compiles. When not cross-compiling, this will be the same as the
# default toolchain.

host_toolchain = "//ffi/gn/build/rust_host"
host_toolchain = "//docs/tutorials/gn/build/rust_host"

if (target_cpu == host_cpu && target_os == host_os) {
set_default_toolchain("//ffi/gn/build/rust_host")
set_default_toolchain("//docs/tutorials/gn/build/rust_host")
} else if (current_cpu == "wasm32" && current_os == "wasi") {
set_default_toolchain("//ffi/gn/build/rust_wasi")
set_default_toolchain("//docs/tutorials/gn/build/rust_wasi")
} else {
assert(false, "Don't know how to build for target $target_cpu / $target_os")
}
6 changes: 3 additions & 3 deletions ffi/gn/Cargo.toml → docs/tutorials/gn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ edition = "2021"

[dependencies]
# Note: Only dependencies that are explicitly listed here are given public GN build targets.
icu_capi = { version = "1.0", path = "../../ffi/capi", default-features = false, features = ["default_components"] }
icu = { version = "1.0", path = "../../components/icu", default-features = false }
icu_provider = { version = "1.0", path = "../../provider/core" }
icu_capi = { version = "1.0", default-features = false, features = ["default_components"] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to double check: the explicit paths are being replaced by the tutorial patch file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

icu = { version = "1.0", default-features = false }
icu_provider = { version = "1.0" }

[gn.package.proc-macro2."1.0.75"]
rustflags = ["--cfg=use_proc_macro", "--cfg=wrap_proc_macro", "--cfg=proc_macro_span"]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# called LICENSE at the top level of the ICU4X source tree
# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

import("//ffi/gn/build/rust_toolchain.gni")
import("//docs/tutorials/gn/build/rust_toolchain.gni")

rust_toolchain("rust_host") {
rust_target = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# called LICENSE at the top level of the ICU4X source tree
# (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

import("//ffi/gn/build/rust_toolchain.gni")
import("//docs/tutorials/gn/build/rust_toolchain.gni")

rust_toolchain("rust_wasi") {
rust_target = "wasm32-wasi"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
executable("print_hello") {
sources = [ "print_hello.rs" ]
deps = [
"//ffi/gn/icu4x:icu",
"//ffi/gn/icu4x:icu_provider",
"//docs/tutorials/gn/icu4x:icu",
"//docs/tutorials/gn/icu4x:icu_provider",
]
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ffi/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions tools/make/gn.toml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we move this file into docs/tutorials/gn? there's significant logic here that needs to be discoverable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ script_runner = "@duckscript"
script = '''
exit_on_error true

mkdir ffi/gn/third_party_tools
cd ffi/gn/third_party_tools
mkdir docs/tutorials/gn/third_party_tools
cd docs/tutorials/gn/third_party_tools

# depot_tools contains the following things we need:
# 1. A cross-platform ninja wrapper script
Expand Down Expand Up @@ -57,7 +57,7 @@ script_runner = "@duckscript"
script = '''
exit_on_error true

cd ffi/gn
cd docs/tutorials/gn

rm -rf vendor
rm -f .cargo/config
Expand Down Expand Up @@ -91,14 +91,14 @@ script_runner = "@duckscript"
script = '''
exit_on_error true

third_party_tools = is_path_exists ffi/gn/third_party_tools
third_party_tools = is_path_exists docs/tutorials/gn/third_party_tools
assert ${third_party_tools} "The GN third-party tools are not installed.\n*** Please run 'cargo make gn-install' ***"

icu4x_root = pwd

cd ffi/gn
cd docs/tutorials/gn

exec --fail-on-error ./third_party_tools/bin/gnaw --manifest-path "${icu4x_root}/ffi/gn/Cargo.toml" --project-root ${icu4x_root} --output ${icu4x_root}/ffi/gn/icu4x/BUILD.gn --skip-root --gn-bin ${icu4x_root}/ffi/gn/third_party_tools/bin/gn
exec --fail-on-error ./third_party_tools/bin/gnaw --manifest-path "${icu4x_root}/docs/tutorials/gn/Cargo.toml" --project-root ${icu4x_root} --output ${icu4x_root}/docs/tutorials/gn/icu4x/BUILD.gn --skip-root --gn-bin ${icu4x_root}/docs/tutorials/gn/third_party_tools/bin/gn
exec --fail-on-error cargo rdme --force
'''

Expand All @@ -111,7 +111,7 @@ dependencies = [
script_runner = "@duckscript"
script = '''
exit_on_error true
code = exec --get-exit-code git diff --exit-code -- ffi/gn
code = exec --get-exit-code git diff --exit-code -- docs/tutorials/gn
if ${code}
trigger_error "GN rules need to be regenerated. Please run `cargo make gn-install`, then `cargo make gn-gen`, and commit."
end
Expand All @@ -129,12 +129,12 @@ script_runner = "@duckscript"
script = '''
exit_on_error true

third_party_tools = is_path_exists ffi/gn/third_party_tools
third_party_tools = is_path_exists docs/tutorials/gn/third_party_tools
assert ${third_party_tools} "The GN third-party tools are not installed.\n*** Please run 'cargo make gn-install' ***"

cd ffi/gn
cd docs/tutorials/gn

exec --fail-on-error ./third_party_tools/bin/gn gen --root=../.. out/host
exec --fail-on-error ./third_party_tools/bin/gn gen --root=../../.. out/host
exec --fail-on-error rustup run ${ICU4X_NIGHTLY_TOOLCHAIN} ./third_party_tools/depot_tools/ninja -C out/host
'''

Expand All @@ -150,14 +150,14 @@ script_runner = "@duckscript"
script = '''
exit_on_error true

third_party_tools = is_path_exists ffi/gn/third_party_tools
third_party_tools = is_path_exists docs/tutorials/gn/third_party_tools
assert ${third_party_tools} "The GN third-party tools are not installed.\n*** Please run 'cargo make gn-install' ***"

cd ffi/gn
cd docs/tutorials/gn

exec --fail-on-error rustup target add wasm32-wasi --toolchain ${ICU4X_NIGHTLY_TOOLCHAIN}

exec --fail-on-error ./third_party_tools/bin/gn gen --root=../.. --args=target_os="wasi" out/wasi
exec --fail-on-error ./third_party_tools/bin/gn gen --root=../../.. --args=target_os="wasi" out/wasi
exec --fail-on-error rustup run ${ICU4X_NIGHTLY_TOOLCHAIN} ./third_party_tools/depot_tools/ninja -C out/wasi
'''

Expand All @@ -173,7 +173,7 @@ dependencies = [
script_runner = "@duckscript"
script = '''
exit_on_error true
cd ffi/gn
exec --fail-on-error ./out/host/obj/ffi/gn/hello_world/print_hello
exec --fail-on-error wasmer run ./out/wasi/obj/ffi/gn/hello_world/print_hello
cd docs/tutorials/gn
exec --fail-on-error ./out/host/obj/docs/tutorials/gn/hello_world/print_hello
exec --fail-on-error wasmer run ./out/wasi/obj/docs/tutorials/gn/hello_world/print_hello
'''
8 changes: 4 additions & 4 deletions tools/make/tidy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ glob_pattern_array = array "./**/*.rs" "./**/*.yml" "./**/*.toml" "./**/*.rst" "
files = exec --fail-on-error git ls-files --cached --others --exclude-standard

# Skip the files matching these patterns.
glob_skip_pattern_array = array "**/target/**/*" "**/node_modules/**/*" "**/data/**/*" "ffi/gn/vendor/**/*" "ffi/gn/third_party_tools/**/*" "ffi/capi/tests/tinyc/*/baked_data/**/*"
glob_skip_pattern_array = array "**/target/**/*" "**/node_modules/**/*" "**/data/**/*" "docs/tutorials/gn/vendor/**/*" "docs/tutorials/gn/third_party_tools/**/*" "ffi/capi/tests/tinyc/*/baked_data/**/*"

blank_line = set ""

Expand Down Expand Up @@ -138,7 +138,7 @@ script = '''
exit_on_error true

glob_pattern = set "./**/Cargo.toml"
glob_skip_pattern = array "ffi/gn/**/*" "ffi/capi/tests/**/*" "tools/**/*" "**/fuzz/*" "**/target/**/*" "docs/**/*" "provider/baked/_template_/Cargo.toml"
glob_skip_pattern = array "docs/tutorials/gn/**/*" "ffi/capi/tests/**/*" "tools/**/*" "**/fuzz/*" "**/target/**/*" "docs/**/*" "provider/baked/_template_/Cargo.toml"

cargo_list = exec cargo --list
if not contains ${cargo_list.stdout} "rdme"
Expand Down Expand Up @@ -208,7 +208,7 @@ exit_on_error true

glob_pattern = set "./**/Cargo.toml"
license = canonicalize LICENSE
skip_path_prefixes = array "ffi/gn/vendor/" "ffi/gn/third_party_tools/" "ffi/capi/tests/c/" "docs/" "utils/calendrical_calculations"
skip_path_prefixes = array "docs/tutorials/gn/vendor/" "docs/tutorials/gn/third_party_tools/" "ffi/capi/tests/c/" "docs/" "utils/calendrical_calculations"

handle = glob_array ${glob_pattern}
for path in ${handle}
Expand Down Expand Up @@ -236,7 +236,7 @@ exit_on_error true
glob_pattern = set "./**/Cargo.toml"
license = canonicalize LICENSE
license_text = readfile ${license}
skip_path_prefixes = array "ffi/gn/vendor/" "ffi/gn/third_party_tools/" "ffi/capi/tests/" "docs/" "utils/calendrical_calculations"
skip_path_prefixes = array "docs/tutorials/gn/vendor/" "docs/tutorials/gn/third_party_tools/" "ffi/capi/tests/" "docs/" "utils/calendrical_calculations"

handle = glob_array ${glob_pattern}
for path in ${handle}
Expand Down