mirror of https://github.com/bazelbuild/rules_rust
Added Rust 1.71.0 (#2062)
https://blog.rust-lang.org/2023/07/13/Rust-1.71.0.html
This commit is contained in:
parent
e3cc007f07
commit
4bd44d03ec
|
@ -1,3 +1,4 @@
|
|||
---
|
||||
BasedOnStyle: Google
|
||||
IndentWidth: 4
|
||||
...
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
name: Formatting
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
clang-format-checking:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: DoozyX/clang-format-lint-action@v0.14
|
||||
with:
|
||||
source: '.'
|
||||
extensions: 'h,c,cc,proto'
|
||||
clangFormatVersion: 14
|
|
@ -21,15 +21,15 @@ pub fn resolve_cfg_platforms(
|
|||
attr.deps
|
||||
.configurations()
|
||||
.into_iter()
|
||||
.chain(attr.deps_dev.configurations().into_iter())
|
||||
.chain(attr.proc_macro_deps.configurations().into_iter())
|
||||
.chain(attr.proc_macro_deps_dev.configurations().into_iter())
|
||||
.chain(attr.deps_dev.configurations())
|
||||
.chain(attr.proc_macro_deps.configurations())
|
||||
.chain(attr.proc_macro_deps_dev.configurations())
|
||||
// Chain the build dependencies if some are defined
|
||||
.chain(if let Some(attr) = &ctx.build_script_attrs {
|
||||
attr.deps
|
||||
.configurations()
|
||||
.into_iter()
|
||||
.chain(attr.proc_macro_deps.configurations().into_iter())
|
||||
.chain(attr.proc_macro_deps.configurations())
|
||||
.collect::<BTreeSet<Option<&String>>>()
|
||||
.into_iter()
|
||||
} else {
|
||||
|
|
|
@ -171,7 +171,7 @@ mod test {
|
|||
let config = temp_dir.as_ref().join("config.toml");
|
||||
|
||||
fs::write(&config, textwrap::dedent(
|
||||
r##"
|
||||
r#"
|
||||
# Makes artifactory the default registry and saves passing --registry parameter
|
||||
[registry]
|
||||
default = "art-crates-remote"
|
||||
|
@ -185,7 +185,7 @@ mod test {
|
|||
|
||||
[net]
|
||||
git-fetch-with-cli = true
|
||||
"##,
|
||||
"#,
|
||||
)).unwrap();
|
||||
|
||||
let config = CargoConfig::try_from_path(&config).unwrap();
|
||||
|
@ -224,7 +224,7 @@ mod test {
|
|||
let config = temp_dir.as_ref().join("config.toml");
|
||||
|
||||
fs::write(&config, textwrap::dedent(
|
||||
r##"
|
||||
r#"
|
||||
[registries]
|
||||
art-crates-remote = { index = "https://artprod.mycompany/artifactory/git/cargo-remote.git" }
|
||||
|
||||
|
@ -233,7 +233,7 @@ mod test {
|
|||
|
||||
[source.some-mirror]
|
||||
registry = "https://artmirror.mycompany/artifactory/cargo-mirror.git"
|
||||
"##,
|
||||
"#,
|
||||
)).unwrap();
|
||||
|
||||
let config = CargoConfig::try_from_path(&config).unwrap();
|
||||
|
@ -249,13 +249,13 @@ mod test {
|
|||
let config = temp_dir.as_ref().join("config.toml");
|
||||
|
||||
fs::write(&config, textwrap::dedent(
|
||||
r##"
|
||||
r#"
|
||||
[registries]
|
||||
art-crates-remote = { index = "https://artprod.mycompany/artifactory/git/cargo-remote.git" }
|
||||
|
||||
[source.crates-io]
|
||||
replace-with = "art-crates-remote"
|
||||
"##,
|
||||
"#,
|
||||
)).unwrap();
|
||||
|
||||
let config = CargoConfig::try_from_path(&config).unwrap();
|
||||
|
@ -273,10 +273,10 @@ mod test {
|
|||
fs::write(
|
||||
&config,
|
||||
textwrap::dedent(
|
||||
r##"
|
||||
r#"
|
||||
[source.some-mirror]
|
||||
registry = "https://artmirror.mycompany/artifactory/cargo-mirror.git"
|
||||
"##,
|
||||
"#,
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
@ -319,7 +319,7 @@ mod test {
|
|||
let config = temp_dir.as_ref().join("config.toml");
|
||||
|
||||
fs::write(&config, textwrap::dedent(
|
||||
r##"
|
||||
r#"
|
||||
[registries]
|
||||
art-crates-remote = { index = "https://artprod.mycompany/artifactory/git/cargo-remote.git" }
|
||||
|
||||
|
@ -328,7 +328,7 @@ mod test {
|
|||
|
||||
[source.some-mirror]
|
||||
registry = "https://artmirror.mycompany/artifactory/cargo-mirror.git"
|
||||
"##,
|
||||
"#,
|
||||
)).unwrap();
|
||||
|
||||
let config = CargoConfig::try_from_path(&config).unwrap();
|
||||
|
@ -360,7 +360,7 @@ mod test {
|
|||
let config = temp_dir.as_ref().join("config.toml");
|
||||
|
||||
fs::write(&config, textwrap::dedent(
|
||||
r##"
|
||||
r#"
|
||||
[registries]
|
||||
art-crates-remote = { index = "https://artprod.mycompany/artifactory/git/cargo-remote.git" }
|
||||
|
||||
|
@ -369,7 +369,7 @@ mod test {
|
|||
|
||||
[source.some-mirror]
|
||||
registry = "https://artmirror.mycompany/artifactory/cargo-mirror.git"
|
||||
"##,
|
||||
"#,
|
||||
)).unwrap();
|
||||
|
||||
let config = CargoConfig::try_from_path(&config).unwrap();
|
||||
|
|
|
@ -347,7 +347,7 @@ impl<'a> SplicerKind<'a> {
|
|||
fs::create_dir(&dot_cargo_dir)?;
|
||||
symlink_roots(&real_path, &dot_cargo_dir, Some(&["config", "config.toml"]))?;
|
||||
} else {
|
||||
for config in vec![
|
||||
for config in [
|
||||
dot_cargo_dir.join("config"),
|
||||
dot_cargo_dir.join("config.toml"),
|
||||
] {
|
||||
|
@ -364,7 +364,7 @@ impl<'a> SplicerKind<'a> {
|
|||
}
|
||||
|
||||
// Make sure no other config files exist
|
||||
for config in vec![
|
||||
for config in [
|
||||
workspace_dir.join("config"),
|
||||
workspace_dir.join("config.toml"),
|
||||
dot_cargo_dir.join("config"),
|
||||
|
@ -384,7 +384,7 @@ impl<'a> SplicerKind<'a> {
|
|||
let mut current_parent = workspace_dir.parent();
|
||||
while let Some(parent) = current_parent {
|
||||
let dot_cargo_dir = parent.join(".cargo");
|
||||
for config in vec![
|
||||
for config in [
|
||||
dot_cargo_dir.join("config.toml"),
|
||||
dot_cargo_dir.join("config"),
|
||||
] {
|
||||
|
|
|
@ -36,7 +36,7 @@ A rule for bootstrapping a Rust binary using [Cargo](https://doc.rust-lang.org/c
|
|||
| <a id="cargo_bootstrap_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{channel}</code> (eg. 'stable'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | <code>"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</code> |
|
||||
| <a id="cargo_bootstrap_repository-srcs"></a>srcs | Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
|
||||
| <a id="cargo_bootstrap_repository-timeout"></a>timeout | Maximum duration of the Cargo build command in seconds | Integer | optional | <code>600</code> |
|
||||
| <a id="cargo_bootstrap_repository-version"></a>version | The version of cargo the resolver should use | String | optional | <code>"1.70.0"</code> |
|
||||
| <a id="cargo_bootstrap_repository-version"></a>version | The version of cargo the resolver should use | String | optional | <code>"1.71.0"</code> |
|
||||
|
||||
|
||||
<a id="cargo_dep_env"></a>
|
||||
|
|
|
@ -386,7 +386,7 @@ CARGO_BAZEL_REPIN=1 CARGO_BAZEL_REPIN_ONLY=crate_index bazel sync --only=crate_i
|
|||
| <a id="crates_repository-repo_mapping"></a>repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | required | |
|
||||
| <a id="crates_repository-rust_toolchain_cargo_template"></a>rust_toolchain_cargo_template | The template to use for finding the host <code>cargo</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{cfg}</code> (eg. 'exec'), <code>{channel}</code> (eg. 'stable'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | <code>"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</code> |
|
||||
| <a id="crates_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{cfg}</code> (eg. 'exec'), <code>{channel}</code> (eg. 'stable'), and <code>{tool}</code> (eg. 'cargo.exe') will be replaced in the string if present. | String | optional | <code>"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</code> |
|
||||
| <a id="crates_repository-rust_version"></a>rust_version | The version of Rust the currently registered toolchain is using. Eg. <code>1.56.0</code>, or <code>nightly/2021-09-08</code> | String | optional | <code>"1.70.0"</code> |
|
||||
| <a id="crates_repository-rust_version"></a>rust_version | The version of Rust the currently registered toolchain is using. Eg. <code>1.56.0</code>, or <code>nightly/2021-09-08</code> | String | optional | <code>"1.71.0"</code> |
|
||||
| <a id="crates_repository-splicing_config"></a>splicing_config | The configuration flags to use for splicing Cargo maniests. Use <code>//crate_universe:defs.bzl\%rsplicing_config</code> to generate the value for this field. If unset, the defaults defined there will be used. | String | optional | <code>""</code> |
|
||||
| <a id="crates_repository-supported_platform_triples"></a>supported_platform_triples | A set of all platform triples to consider when generating dependencies. | List of strings | optional | <code>["aarch64-unknown-linux-gnu", "i686-apple-darwin", "i686-pc-windows-msvc", "i686-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", "aarch64-apple-darwin", "aarch64-apple-ios-sim", "aarch64-apple-ios", "aarch64-fuchsia", "aarch64-linux-android", "aarch64-pc-windows-msvc", "arm-unknown-linux-gnueabi", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabi", "i686-linux-android", "i686-unknown-freebsd", "powerpc-unknown-linux-gnu", "riscv32imc-unknown-none-elf", "riscv64gc-unknown-none-elf", "s390x-unknown-linux-gnu", "thumbv7em-none-eabi", "thumbv8m.main-none-eabi", "wasm32-unknown-unknown", "wasm32-wasi", "x86_64-apple-ios", "x86_64-fuchsia", "x86_64-linux-android", "x86_64-unknown-freebsd", "x86_64-unknown-none"]</code> |
|
||||
|
||||
|
@ -725,7 +725,7 @@ Define dependencies of the `cargo-bazel` Rust target
|
|||
|
||||
| Name | Description | Default Value |
|
||||
| :------------- | :------------- | :------------- |
|
||||
| <a id="crate_universe_dependencies-rust_version"></a>rust_version | The version of rust to use when generating dependencies. | `"1.70.0"` |
|
||||
| <a id="crate_universe_dependencies-rust_version"></a>rust_version | The version of rust to use when generating dependencies. | `"1.71.0"` |
|
||||
| <a id="crate_universe_dependencies-bootstrap"></a>bootstrap | If true, a <code>cargo_bootstrap_repository</code> target will be generated. | `False` |
|
||||
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ A rule for bootstrapping a Rust binary using [Cargo](https://doc.rust-lang.org/c
|
|||
| <a id="cargo_bootstrap_repository-rust_toolchain_rustc_template"></a>rust_toolchain_rustc_template | The template to use for finding the host <code>rustc</code> binary. <code>{version}</code> (eg. '1.53.0'), <code>{triple}</code> (eg. 'x86_64-unknown-linux-gnu'), <code>{arch}</code> (eg. 'aarch64'), <code>{vendor}</code> (eg. 'unknown'), <code>{system}</code> (eg. 'darwin'), <code>{channel}</code> (eg. 'stable'), and <code>{tool}</code> (eg. 'rustc.exe') will be replaced in the string if present. | String | optional | <code>"@rust_{system}_{arch}__{triple}__{channel}_tools//:bin/{tool}"</code> |
|
||||
| <a id="cargo_bootstrap_repository-srcs"></a>srcs | Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | <code>[]</code> |
|
||||
| <a id="cargo_bootstrap_repository-timeout"></a>timeout | Maximum duration of the Cargo build command in seconds | Integer | optional | <code>600</code> |
|
||||
| <a id="cargo_bootstrap_repository-version"></a>version | The version of cargo the resolver should use | String | optional | <code>"1.70.0"</code> |
|
||||
| <a id="cargo_bootstrap_repository-version"></a>version | The version of cargo the resolver should use | String | optional | <code>"1.71.0"</code> |
|
||||
|
||||
|
||||
<a id="cargo_dep_env"></a>
|
||||
|
@ -1899,7 +1899,7 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai
|
|||
| <a id="rust_register_toolchains-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions when global allocator is used with cc_common.link. | `None` |
|
||||
| <a id="rust_register_toolchains-iso_date"></a>iso_date | **Deprecated**: Use <code>versions</code> instead. | `None` |
|
||||
| <a id="rust_register_toolchains-register_toolchains"></a>register_toolchains | If true, repositories will be generated to produce and register <code>rust_toolchain</code> targets. | `True` |
|
||||
| <a id="rust_register_toolchains-rustfmt_version"></a>rustfmt_version | The version of rustfmt. | `"nightly/2023-06-01"` |
|
||||
| <a id="rust_register_toolchains-rustfmt_version"></a>rustfmt_version | The version of rustfmt. | `"nightly/2023-07-13"` |
|
||||
| <a id="rust_register_toolchains-rust_analyzer_version"></a>rust_analyzer_version | The version of Rustc to pair with rust-analyzer. | `None` |
|
||||
| <a id="rust_register_toolchains-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. | `None` |
|
||||
| <a id="rust_register_toolchains-extra_target_triples"></a>extra_target_triples | Additional rust-style targets that rust toolchains should support. | `["wasm32-unknown-unknown", "wasm32-wasi"]` |
|
||||
|
|
|
@ -267,7 +267,7 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai
|
|||
| <a id="rust_register_toolchains-global_allocator_library"></a>global_allocator_library | Target that provides allocator functions when global allocator is used with cc_common.link. | `None` |
|
||||
| <a id="rust_register_toolchains-iso_date"></a>iso_date | **Deprecated**: Use <code>versions</code> instead. | `None` |
|
||||
| <a id="rust_register_toolchains-register_toolchains"></a>register_toolchains | If true, repositories will be generated to produce and register <code>rust_toolchain</code> targets. | `True` |
|
||||
| <a id="rust_register_toolchains-rustfmt_version"></a>rustfmt_version | The version of rustfmt. | `"nightly/2023-06-01"` |
|
||||
| <a id="rust_register_toolchains-rustfmt_version"></a>rustfmt_version | The version of rustfmt. | `"nightly/2023-07-13"` |
|
||||
| <a id="rust_register_toolchains-rust_analyzer_version"></a>rust_analyzer_version | The version of Rustc to pair with rust-analyzer. | `None` |
|
||||
| <a id="rust_register_toolchains-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. | `None` |
|
||||
| <a id="rust_register_toolchains-extra_target_triples"></a>extra_target_triples | Additional rust-style targets that rust toolchains should support. | `["wasm32-unknown-unknown", "wasm32-wasi"]` |
|
||||
|
|
|
@ -24,29 +24,31 @@
|
|||
__attribute__((weak)) uint8_t __rust_alloc_error_handler_should_panic = 0;
|
||||
|
||||
extern "C" uint8_t *__rdl_alloc(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_alloc(uintptr_t size, uintptr_t align) {
|
||||
return __rdl_alloc(size, align);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_alloc(uintptr_t size,
|
||||
uintptr_t align) {
|
||||
return __rdl_alloc(size, align);
|
||||
}
|
||||
extern "C" void __rdl_dealloc(uint8_t *ptr, uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
void __rust_dealloc(uint8_t *ptr, uintptr_t size, uintptr_t align) {
|
||||
__rdl_dealloc(ptr, size, align);
|
||||
extern "C" __attribute__((weak)) void __rust_dealloc(uint8_t *ptr,
|
||||
uintptr_t size,
|
||||
uintptr_t align) {
|
||||
__rdl_dealloc(ptr, size, align);
|
||||
}
|
||||
extern "C" uint8_t *__rdl_realloc(uint8_t *ptr, uintptr_t old_size, uintptr_t align,
|
||||
uintptr_t new_size);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_realloc(uint8_t *ptr, uintptr_t old_size, uintptr_t align,
|
||||
uintptr_t new_size) {
|
||||
return __rdl_realloc(ptr, old_size, align, new_size);
|
||||
extern "C" uint8_t *__rdl_realloc(uint8_t *ptr, uintptr_t old_size,
|
||||
uintptr_t align, uintptr_t new_size);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_realloc(uint8_t *ptr,
|
||||
uintptr_t old_size,
|
||||
uintptr_t align,
|
||||
uintptr_t new_size) {
|
||||
return __rdl_realloc(ptr, old_size, align, new_size);
|
||||
}
|
||||
extern "C" uint8_t *__rdl_alloc_zeroed(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_alloc_zeroed(uintptr_t size, uintptr_t align) {
|
||||
return __rdl_alloc_zeroed(size, align);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_alloc_zeroed(uintptr_t size,
|
||||
uintptr_t align) {
|
||||
return __rdl_alloc_zeroed(size, align);
|
||||
}
|
||||
extern "C" void __rdl_oom(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
void __rust_alloc_error_handler(uintptr_t size, uintptr_t align) {
|
||||
__rdl_oom(size, align);
|
||||
extern "C" __attribute__((weak)) void __rust_alloc_error_handler(
|
||||
uintptr_t size, uintptr_t align) {
|
||||
__rdl_oom(size, align);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
// https://github.com/bazelbuild/rules_rust/issues/1271
|
||||
extern void android_link_hack(void);
|
||||
|
||||
void call_link_hack(void) {
|
||||
android_link_hack();
|
||||
}
|
||||
void call_link_hack(void) { android_link_hack(); }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"checksum": "0e2c953783fed1bd0ad375bb438573edea3996f54b3bb1b2720f78485bb0411b",
|
||||
"checksum": "ab64fb3163272359b2af39202766d8f5e87ac2b1df40266913f798070b6f6979",
|
||||
"crates": {
|
||||
"aho-corasick 0.7.20": {
|
||||
"name": "aho-corasick",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"checksum": "69cc99a674d1673703f9040785d30dae97441e553d73b95143977a3c1ba97f15",
|
||||
"checksum": "6f112e662b88f114281a88c9910907a36f9dd34fabb1965fcabb9f4dad943bdb",
|
||||
"crates": {
|
||||
"autocfg 1.1.0": {
|
||||
"name": "autocfg",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"checksum": "ca84ee6cbcc26ec4c700df2e87dd19c4ace81f350dd2fb474fb3438bcbeaa7d8",
|
||||
"checksum": "a53a28a5df977c7cfdee748d1d522a044997de08d5cdfddcb8e37b7a8e78f762",
|
||||
"crates": {
|
||||
"ansi_term 0.12.1": {
|
||||
"name": "ansi_term",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"checksum": "3e48fcdf670ea94a38b45561e9a48d6b59616718868e7f79eaf7f7a65f845243",
|
||||
"checksum": "beaff14af74802a0384e8a0bc4cfb334bdd387ac9cb71487ffc7247995fc57f9",
|
||||
"crates": {
|
||||
"aho-corasick 0.7.20": {
|
||||
"name": "aho-corasick",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"checksum": "fce1cf308ae39e5fae86bcb1f26fe066c5c5d3de3a44df7fc48cfc4ed7955d86",
|
||||
"checksum": "c518dbc2b39c4423ef684f6f6f35c46cdac3cda011b1c427724d42a15a2b6520",
|
||||
"crates": {
|
||||
"async-trait 0.1.64": {
|
||||
"name": "async-trait",
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
extern int32_t my_favorite_number();
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
assert(my_favorite_number() == 4);
|
||||
return 0;
|
||||
assert(my_favorite_number() == 4);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -18,106 +18,106 @@
|
|||
#include <string.h>
|
||||
|
||||
Matrix* matrix_new(size_t rows, size_t cols, const uint64_t* data) {
|
||||
if (data == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
Matrix* matrix = (Matrix*)malloc(sizeof(*matrix));
|
||||
if (matrix == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
matrix->rows = rows;
|
||||
matrix->cols = cols;
|
||||
matrix->data = (uint64_t*)malloc(rows * cols * sizeof(*(matrix->data)));
|
||||
memcpy(matrix->data, data, rows * cols * sizeof(*data));
|
||||
return matrix;
|
||||
if (data == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
Matrix* matrix = (Matrix*)malloc(sizeof(*matrix));
|
||||
if (matrix == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
matrix->rows = rows;
|
||||
matrix->cols = cols;
|
||||
matrix->data = (uint64_t*)malloc(rows * cols * sizeof(*(matrix->data)));
|
||||
memcpy(matrix->data, data, rows * cols * sizeof(*data));
|
||||
return matrix;
|
||||
}
|
||||
|
||||
int matrix_at(const Matrix* matrix, size_t row, size_t col, uint64_t* n) {
|
||||
if (matrix == NULL || matrix->data == NULL || n == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (row >= matrix->rows || col >= matrix->cols) {
|
||||
return 0;
|
||||
}
|
||||
*n = matrix->data[row * matrix->cols + col];
|
||||
return 1;
|
||||
if (matrix == NULL || matrix->data == NULL || n == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (row >= matrix->rows || col >= matrix->cols) {
|
||||
return 0;
|
||||
}
|
||||
*n = matrix->data[row * matrix->cols + col];
|
||||
return 1;
|
||||
}
|
||||
|
||||
int matrix_set(const Matrix* matrix, size_t row, size_t col, uint64_t n) {
|
||||
if (matrix == NULL || matrix->data == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (row >= matrix->rows || col >= matrix->cols) {
|
||||
return 0;
|
||||
}
|
||||
matrix->data[row * matrix->cols + col] = n;
|
||||
return 1;
|
||||
if (matrix == NULL || matrix->data == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (row >= matrix->rows || col >= matrix->cols) {
|
||||
return 0;
|
||||
}
|
||||
matrix->data[row * matrix->cols + col] = n;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void matrix_transpose(Matrix* matrix) {
|
||||
if (matrix == NULL || matrix->data == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
size_t len = matrix->rows * matrix->cols;
|
||||
int* visited = (int*)malloc(len * sizeof(*visited));
|
||||
if (visited == NULL) {
|
||||
return;
|
||||
}
|
||||
memset(visited, 0, len * sizeof(*visited));
|
||||
|
||||
// Follow-the-cycles implementation of matrix transposition. Note that we
|
||||
// skip the last element since it always has a cycle of length 1 and thus
|
||||
// does not need to be moved.
|
||||
size_t q = matrix->rows * matrix->cols - 1;
|
||||
for (size_t i = 0; i < q; ++i) {
|
||||
if (visited[i] == 1) {
|
||||
continue;
|
||||
if (matrix == NULL || matrix->data == NULL) {
|
||||
return;
|
||||
}
|
||||
size_t current_idx = i;
|
||||
size_t next_idx = i;
|
||||
do {
|
||||
visited[current_idx] = 1;
|
||||
next_idx = (current_idx * matrix->cols) % q;
|
||||
if (next_idx == i) {
|
||||
break;
|
||||
}
|
||||
|
||||
uint64_t current_val = matrix->data[current_idx];
|
||||
matrix->data[current_idx] = matrix->data[next_idx];
|
||||
matrix->data[next_idx] = current_val;
|
||||
current_idx = next_idx;
|
||||
} while (1);
|
||||
}
|
||||
size_t len = matrix->rows * matrix->cols;
|
||||
int* visited = (int*)malloc(len * sizeof(*visited));
|
||||
if (visited == NULL) {
|
||||
return;
|
||||
}
|
||||
memset(visited, 0, len * sizeof(*visited));
|
||||
|
||||
free(visited);
|
||||
size_t cols = matrix->rows;
|
||||
matrix->rows = matrix->cols;
|
||||
matrix->cols = cols;
|
||||
// Follow-the-cycles implementation of matrix transposition. Note that we
|
||||
// skip the last element since it always has a cycle of length 1 and thus
|
||||
// does not need to be moved.
|
||||
size_t q = matrix->rows * matrix->cols - 1;
|
||||
for (size_t i = 0; i < q; ++i) {
|
||||
if (visited[i] == 1) {
|
||||
continue;
|
||||
}
|
||||
size_t current_idx = i;
|
||||
size_t next_idx = i;
|
||||
do {
|
||||
visited[current_idx] = 1;
|
||||
next_idx = (current_idx * matrix->cols) % q;
|
||||
if (next_idx == i) {
|
||||
break;
|
||||
}
|
||||
|
||||
uint64_t current_val = matrix->data[current_idx];
|
||||
matrix->data[current_idx] = matrix->data[next_idx];
|
||||
matrix->data[next_idx] = current_val;
|
||||
current_idx = next_idx;
|
||||
} while (1);
|
||||
}
|
||||
|
||||
free(visited);
|
||||
size_t cols = matrix->rows;
|
||||
matrix->rows = matrix->cols;
|
||||
matrix->cols = cols;
|
||||
}
|
||||
|
||||
int matrix_equal(const Matrix* a, const Matrix* b) {
|
||||
if (a == NULL || b == NULL || a->data == NULL || b->data == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (a->rows != b->rows || a->cols != b->cols) {
|
||||
return 0;
|
||||
}
|
||||
size_t len = a->rows * a->cols;
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
if (a->data[i] != b->data[i]) {
|
||||
return 0;
|
||||
if (a == NULL || b == NULL || a->data == NULL || b->data == NULL) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
if (a->rows != b->rows || a->cols != b->cols) {
|
||||
return 0;
|
||||
}
|
||||
size_t len = a->rows * a->cols;
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
if (a->data[i] != b->data[i]) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void matrix_free(Matrix* matrix) {
|
||||
if (matrix == NULL) {
|
||||
return;
|
||||
}
|
||||
if (matrix->data != NULL) {
|
||||
free(matrix->data);
|
||||
}
|
||||
free(matrix);
|
||||
if (matrix == NULL) {
|
||||
return;
|
||||
}
|
||||
if (matrix->data != NULL) {
|
||||
free(matrix->data);
|
||||
}
|
||||
free(matrix);
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
typedef struct {
|
||||
size_t rows;
|
||||
size_t cols;
|
||||
uint64_t* data;
|
||||
size_t rows;
|
||||
size_t cols;
|
||||
uint64_t* data;
|
||||
} Matrix;
|
||||
|
||||
// Constructs a new Matrix from the given data.
|
||||
|
|
|
@ -21,56 +21,56 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
void matrix_print(const Matrix* m) {
|
||||
for (size_t i = 0; i < m->rows; ++i) {
|
||||
for (size_t j = 0; j < m->cols; ++j) {
|
||||
uint64_t val = 0;
|
||||
matrix_at(m, i, j, &val);
|
||||
printf("%" PRIu64 " ", val);
|
||||
for (size_t i = 0; i < m->rows; ++i) {
|
||||
for (size_t j = 0; j < m->cols; ++j) {
|
||||
uint64_t val = 0;
|
||||
matrix_at(m, i, j, &val);
|
||||
printf("%" PRIu64 " ", val);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
int check_equal(const Matrix* a, const Matrix* b) {
|
||||
int equal = matrix_equal(a, b);
|
||||
if (!equal) {
|
||||
printf("Matrices not equal:\n");
|
||||
printf("a:\n");
|
||||
matrix_print(a);
|
||||
printf("\nb:\n");
|
||||
matrix_print(b);
|
||||
}
|
||||
return equal;
|
||||
int equal = matrix_equal(a, b);
|
||||
if (!equal) {
|
||||
printf("Matrices not equal:\n");
|
||||
printf("a:\n");
|
||||
matrix_print(a);
|
||||
printf("\nb:\n");
|
||||
matrix_print(b);
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
|
||||
void test_equal() {
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
static uint64_t a_data[] = {11, 12, 13, 14,
|
||||
21, 22, 23, 24};
|
||||
// clang-format on
|
||||
Matrix* a = matrix_new(2, 4, a_data);
|
||||
assert(a != NULL);
|
||||
assert(check_equal(a, a));
|
||||
// clang-format on
|
||||
Matrix* a = matrix_new(2, 4, a_data);
|
||||
assert(a != NULL);
|
||||
assert(check_equal(a, a));
|
||||
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
static uint64_t b_data[] = {13, 14, 15, 16,
|
||||
22, 23, 24, 25};
|
||||
// clang-format on
|
||||
Matrix* b = matrix_new(2, 4, b_data);
|
||||
assert(b != NULL);
|
||||
assert(!matrix_equal(a, b));
|
||||
// clang-format on
|
||||
Matrix* b = matrix_new(2, 4, b_data);
|
||||
assert(b != NULL);
|
||||
assert(!matrix_equal(a, b));
|
||||
}
|
||||
|
||||
void test_transpose() {
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
static uint64_t matrix_data[] = {11, 12, 13, 14,
|
||||
21, 22, 23, 24};
|
||||
// clang-format on
|
||||
Matrix* matrix = matrix_new(2, 4, matrix_data);
|
||||
assert(matrix != NULL);
|
||||
matrix_transpose(matrix);
|
||||
// clang-format on
|
||||
Matrix* matrix = matrix_new(2, 4, matrix_data);
|
||||
assert(matrix != NULL);
|
||||
matrix_transpose(matrix);
|
||||
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
static uint64_t expected_transpose_data[] = {11, 21,
|
||||
12, 22,
|
||||
13, 23,
|
||||
|
|
|
@ -24,29 +24,35 @@
|
|||
__attribute__((weak)) uint8_t __rust_alloc_error_handler_should_panic = 0;
|
||||
|
||||
extern "C" uint8_t *__rdl_alloc(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_alloc(uintptr_t size, uintptr_t align) {
|
||||
return __rdl_alloc(size, align);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_alloc(uintptr_t size,
|
||||
uintptr_t align) {
|
||||
return __rdl_alloc(size, align);
|
||||
}
|
||||
extern "C" void __rdl_dealloc(uint8_t *ptr, uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
void __rust_dealloc(uint8_t *ptr, uintptr_t size, uintptr_t align) {
|
||||
__rdl_dealloc(ptr, size, align);
|
||||
extern "C" __attribute__((weak)) void __rust_dealloc(uint8_t *ptr,
|
||||
uintptr_t size,
|
||||
uintptr_t align) {
|
||||
__rdl_dealloc(ptr, size, align);
|
||||
}
|
||||
extern "C" uint8_t *__rdl_realloc(uint8_t *ptr, uintptr_t old_size, uintptr_t align,
|
||||
uintptr_t new_size);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_realloc(uint8_t *ptr, uintptr_t old_size, uintptr_t align,
|
||||
uintptr_t new_size) {
|
||||
return __rdl_realloc(ptr, old_size, align, new_size);
|
||||
extern "C" uint8_t *__rdl_realloc(uint8_t *ptr, uintptr_t old_size,
|
||||
uintptr_t align, uintptr_t new_size);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_realloc(uint8_t *ptr,
|
||||
uintptr_t old_size,
|
||||
uintptr_t align,
|
||||
uintptr_t new_size) {
|
||||
return __rdl_realloc(ptr, old_size, align, new_size);
|
||||
}
|
||||
extern "C" uint8_t *__rdl_alloc_zeroed(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_alloc_zeroed(uintptr_t size, uintptr_t align) {
|
||||
return __rdl_alloc_zeroed(size, align);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_alloc_zeroed(uintptr_t size,
|
||||
uintptr_t align) {
|
||||
return __rdl_alloc_zeroed(size, align);
|
||||
}
|
||||
extern "C" void __rdl_oom(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
void __rust_alloc_error_handler(uintptr_t size, uintptr_t align) {
|
||||
__rdl_oom(size, align);
|
||||
extern "C" __attribute__((weak)) void __rust_alloc_error_handler(
|
||||
uintptr_t size, uintptr_t align) {
|
||||
__rdl_oom(size, align);
|
||||
}
|
||||
|
||||
// New requirement as of Rust 1.71.0. For more details see
|
||||
// https://github.com/rust-lang/rust/issues/73632.
|
||||
__attribute__((weak)) uint8_t __rust_no_alloc_shim_is_unstable = 0;
|
||||
|
|
|
@ -8,6 +8,5 @@ package common;
|
|||
// A configuration object. This is used to test the viability of
|
||||
// protobuf imports.
|
||||
message Config {
|
||||
bool verbose = 1;
|
||||
bool verbose = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,17 +7,17 @@ package helloworld;
|
|||
|
||||
// The greeting service definition.
|
||||
service Greeter {
|
||||
// Sends a greeting
|
||||
rpc SayHello (HelloRequest) returns (HelloReply) {}
|
||||
// Sends a greeting
|
||||
rpc SayHello(HelloRequest) returns (HelloReply) {}
|
||||
}
|
||||
|
||||
// The request message containing the user's name.
|
||||
message HelloRequest {
|
||||
string name = 1;
|
||||
common.Config config = 2;
|
||||
string name = 1;
|
||||
common.Config config = 2;
|
||||
}
|
||||
|
||||
// The response message containing the greetings
|
||||
message HelloReply {
|
||||
string message = 1;
|
||||
string message = 1;
|
||||
}
|
||||
|
|
|
@ -3,5 +3,5 @@ syntax = "proto3";
|
|||
package mod;
|
||||
|
||||
message A {
|
||||
string name = 1;
|
||||
string name = 1;
|
||||
}
|
||||
|
|
|
@ -3,24 +3,24 @@ syntax = "proto3";
|
|||
package nested_messages;
|
||||
|
||||
message A {
|
||||
string name = 1;
|
||||
|
||||
message B {
|
||||
string name = 1;
|
||||
|
||||
message C {
|
||||
string name = 1;
|
||||
message B {
|
||||
string name = 1;
|
||||
|
||||
message C {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
enum D {
|
||||
E = 0;
|
||||
F = 1;
|
||||
}
|
||||
|
||||
C c = 2;
|
||||
|
||||
D d = 3;
|
||||
}
|
||||
|
||||
enum D {
|
||||
E = 0;
|
||||
F = 1;
|
||||
}
|
||||
|
||||
C c = 2;
|
||||
|
||||
D d = 3;
|
||||
}
|
||||
|
||||
B b = 2;
|
||||
B b = 2;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import "foo.proto";
|
|||
package bAR.bAz.QAZ.QuX;
|
||||
|
||||
message Bar {
|
||||
string name = 1;
|
||||
string name = 1;
|
||||
|
||||
Foo.QuuX.CoRgE.GRAULT.gaRply.Foo foo = 2;
|
||||
Foo.QuuX.CoRgE.GRAULT.gaRply.Foo foo = 2;
|
||||
|
||||
Foo.QuuX.CoRgE.GRAULT.gaRply.Foo.NestedFoo nested_foo = 3;
|
||||
Foo.QuuX.CoRgE.GRAULT.gaRply.Foo.NestedFoo nested_foo = 3;
|
||||
|
||||
message Baz {
|
||||
string name = 4;
|
||||
}
|
||||
message Baz {
|
||||
string name = 4;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@ syntax = "proto3";
|
|||
package Foo.QuuX.CoRgE.GRAULT.gaRply;
|
||||
|
||||
message Foo {
|
||||
string name = 1;
|
||||
string name = 1;
|
||||
|
||||
message NestedFoo {
|
||||
string name = 2;
|
||||
}
|
||||
message NestedFoo {
|
||||
string name = 2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,26 +4,26 @@ package echo;
|
|||
|
||||
// EchoRequest is the request for echo.
|
||||
message EchoRequest {
|
||||
string message = 1;
|
||||
string message = 1;
|
||||
}
|
||||
|
||||
// EchoResponse is the response for echo.
|
||||
message EchoResponse {
|
||||
string message = 1;
|
||||
string message = 1;
|
||||
}
|
||||
|
||||
// Echo is the echo service.
|
||||
service Echo {
|
||||
// UnaryEcho is unary echo.
|
||||
rpc UnaryEcho(EchoRequest) returns (EchoResponse) {}
|
||||
// UnaryEcho is unary echo.
|
||||
rpc UnaryEcho(EchoRequest) returns (EchoResponse) {}
|
||||
|
||||
// ServerStreamingEcho is server side streaming.
|
||||
rpc ServerStreamingEcho(EchoRequest) returns (stream EchoResponse) {}
|
||||
// ServerStreamingEcho is server side streaming.
|
||||
rpc ServerStreamingEcho(EchoRequest) returns (stream EchoResponse) {}
|
||||
|
||||
// ClientStreamingEcho is client side streaming.
|
||||
rpc ClientStreamingEcho(stream EchoRequest) returns (EchoResponse) {}
|
||||
// ClientStreamingEcho is client side streaming.
|
||||
rpc ClientStreamingEcho(stream EchoRequest) returns (EchoResponse) {}
|
||||
|
||||
// BidirectionalStreamingEcho is bidi streaming.
|
||||
rpc BidirectionalStreamingEcho(stream EchoRequest)
|
||||
returns (stream EchoResponse) {}
|
||||
// BidirectionalStreamingEcho is bidi streaming.
|
||||
rpc BidirectionalStreamingEcho(stream EchoRequest)
|
||||
returns (stream EchoResponse) {}
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@ package helloworld;
|
|||
|
||||
// The greeting service definition.
|
||||
service Greeter {
|
||||
// Sends a greeting
|
||||
rpc SayHello (HelloRequest) returns (HelloReply) {}
|
||||
// Sends a greeting
|
||||
rpc SayHello(HelloRequest) returns (HelloReply) {}
|
||||
}
|
||||
|
||||
// The request message containing the user's name.
|
||||
message HelloRequest {
|
||||
string name = 1;
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
// The response message containing the greetings.
|
||||
message HelloReply {
|
||||
string message = 1;
|
||||
string message = 1;
|
||||
}
|
||||
|
|
|
@ -8,13 +8,13 @@ import "types/types.proto";
|
|||
package a;
|
||||
|
||||
message A {
|
||||
string name = 1;
|
||||
string name = 1;
|
||||
|
||||
a.b.B b = 2;
|
||||
a.b.B b = 2;
|
||||
|
||||
google.protobuf.Timestamp timestamp = 3;
|
||||
google.protobuf.Timestamp timestamp = 3;
|
||||
|
||||
google.protobuf.Duration duration = 4;
|
||||
google.protobuf.Duration duration = 4;
|
||||
|
||||
Types types = 5;
|
||||
Types types = 5;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ import "b/c/c.proto";
|
|||
package a.b;
|
||||
|
||||
message B {
|
||||
string name = 1;
|
||||
string name = 1;
|
||||
|
||||
google.protobuf.Empty empty = 2;
|
||||
google.protobuf.Empty empty = 2;
|
||||
|
||||
a.b.c.C c = 3;
|
||||
a.b.c.C c = 3;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ import "google/protobuf/duration.proto";
|
|||
package a.b.c;
|
||||
|
||||
message C {
|
||||
string name = 1;
|
||||
string name = 1;
|
||||
|
||||
google.protobuf.Any any = 3;
|
||||
google.protobuf.Any any = 3;
|
||||
|
||||
google.protobuf.Duration duration = 4;
|
||||
google.protobuf.Duration duration = 4;
|
||||
}
|
||||
|
|
|
@ -1,79 +1,79 @@
|
|||
syntax = "proto3";
|
||||
|
||||
enum Enum {
|
||||
A = 0;
|
||||
B = 1;
|
||||
C = 2;
|
||||
A = 0;
|
||||
B = 1;
|
||||
C = 2;
|
||||
}
|
||||
|
||||
message Types {
|
||||
Enum a_enum = 1;
|
||||
double a_double = 2;
|
||||
float a_float = 3;
|
||||
int32 a_int32 = 4;
|
||||
int64 a_int64 = 5;
|
||||
uint32 a_uint32 = 6;
|
||||
uint64 a_uint64 = 7;
|
||||
sint32 a_sint32 = 8;
|
||||
sint64 a_sint64 = 9;
|
||||
fixed32 a_fixed32 = 10;
|
||||
fixed64 a_fixed64 = 11;
|
||||
sfixed32 a_sfixed32 = 12;
|
||||
sfixed64 a_sfixed64 = 13;
|
||||
bool a_bool = 14;
|
||||
string a_string = 15;
|
||||
bytes a_bytes = 16;
|
||||
Enum a_enum = 1;
|
||||
double a_double = 2;
|
||||
float a_float = 3;
|
||||
int32 a_int32 = 4;
|
||||
int64 a_int64 = 5;
|
||||
uint32 a_uint32 = 6;
|
||||
uint64 a_uint64 = 7;
|
||||
sint32 a_sint32 = 8;
|
||||
sint64 a_sint64 = 9;
|
||||
fixed32 a_fixed32 = 10;
|
||||
fixed64 a_fixed64 = 11;
|
||||
sfixed32 a_sfixed32 = 12;
|
||||
sfixed64 a_sfixed64 = 13;
|
||||
bool a_bool = 14;
|
||||
string a_string = 15;
|
||||
bytes a_bytes = 16;
|
||||
|
||||
repeated Enum repeated_enum = 17;
|
||||
repeated double repeated_double = 18;
|
||||
repeated float repeated_float = 19;
|
||||
repeated int32 repeated_int32 = 20;
|
||||
repeated int64 repeated_int64 = 21;
|
||||
repeated uint32 repeated_uint32 = 22;
|
||||
repeated uint64 repeated_uint64 = 23;
|
||||
repeated sint32 repeated_sint32 = 24;
|
||||
repeated sint64 repeated_sint64 = 25;
|
||||
repeated fixed32 repeated_fixed32 = 26;
|
||||
repeated fixed64 repeated_fixed64 = 27;
|
||||
repeated sfixed32 repeated_sfixed32 = 28;
|
||||
repeated sfixed64 repeated_sfixed64 = 29;
|
||||
repeated bool repeated_bool = 30;
|
||||
repeated string repeated_string = 31;
|
||||
repeated bytes repeated_bytes = 32;
|
||||
repeated Enum repeated_enum = 17;
|
||||
repeated double repeated_double = 18;
|
||||
repeated float repeated_float = 19;
|
||||
repeated int32 repeated_int32 = 20;
|
||||
repeated int64 repeated_int64 = 21;
|
||||
repeated uint32 repeated_uint32 = 22;
|
||||
repeated uint64 repeated_uint64 = 23;
|
||||
repeated sint32 repeated_sint32 = 24;
|
||||
repeated sint64 repeated_sint64 = 25;
|
||||
repeated fixed32 repeated_fixed32 = 26;
|
||||
repeated fixed64 repeated_fixed64 = 27;
|
||||
repeated sfixed32 repeated_sfixed32 = 28;
|
||||
repeated sfixed64 repeated_sfixed64 = 29;
|
||||
repeated bool repeated_bool = 30;
|
||||
repeated string repeated_string = 31;
|
||||
repeated bytes repeated_bytes = 32;
|
||||
|
||||
map<string, Enum> map_string_enum = 33;
|
||||
map<string, double> map_string_double = 34;
|
||||
map<string, float> map_string_float = 35;
|
||||
map<string, int32> map_string_int32 = 36;
|
||||
map<string, int64> map_string_int64 = 37;
|
||||
map<string, uint32> map_string_uint32 = 38;
|
||||
map<string, uint64> map_string_uint64 = 39;
|
||||
map<string, sint32> map_string_sint32 = 40;
|
||||
map<string, sint64> map_string_sint64 = 41;
|
||||
map<string, fixed32> map_string_fixed32 = 42;
|
||||
map<string, fixed64> map_string_fixed64 = 43;
|
||||
map<string, sfixed32> map_string_sfixed32 = 44;
|
||||
map<string, sfixed64> map_string_sfixed64 = 45;
|
||||
map<string, bool> map_string_bool = 46;
|
||||
map<string, string> map_string_string = 47;
|
||||
map<string, bytes> map_string_bytes = 48;
|
||||
map<string, Enum> map_string_enum = 33;
|
||||
map<string, double> map_string_double = 34;
|
||||
map<string, float> map_string_float = 35;
|
||||
map<string, int32> map_string_int32 = 36;
|
||||
map<string, int64> map_string_int64 = 37;
|
||||
map<string, uint32> map_string_uint32 = 38;
|
||||
map<string, uint64> map_string_uint64 = 39;
|
||||
map<string, sint32> map_string_sint32 = 40;
|
||||
map<string, sint64> map_string_sint64 = 41;
|
||||
map<string, fixed32> map_string_fixed32 = 42;
|
||||
map<string, fixed64> map_string_fixed64 = 43;
|
||||
map<string, sfixed32> map_string_sfixed32 = 44;
|
||||
map<string, sfixed64> map_string_sfixed64 = 45;
|
||||
map<string, bool> map_string_bool = 46;
|
||||
map<string, string> map_string_string = 47;
|
||||
map<string, bytes> map_string_bytes = 48;
|
||||
|
||||
oneof OneOf {
|
||||
Enum oneof_enum = 49;
|
||||
double oneof_double = 50;
|
||||
float oneof_float = 51;
|
||||
int32 oneof_int32 = 52;
|
||||
int64 oneof_int64 = 53;
|
||||
uint32 oneof_uint32 = 54;
|
||||
uint64 oneof_uint64 = 55;
|
||||
sint32 oneof_sint32 = 56;
|
||||
sint64 oneof_sint64 = 57;
|
||||
fixed32 oneof_fixed32 = 58;
|
||||
fixed64 oneof_fixed64 = 59;
|
||||
sfixed32 oneof_sfixed32 = 60;
|
||||
sfixed64 oneof_sfixed64 = 61;
|
||||
bool oneof_bool = 62;
|
||||
string oneof_string = 63;
|
||||
bytes oneof_bytes = 64;
|
||||
}
|
||||
oneof OneOf {
|
||||
Enum oneof_enum = 49;
|
||||
double oneof_double = 50;
|
||||
float oneof_float = 51;
|
||||
int32 oneof_int32 = 52;
|
||||
int64 oneof_int64 = 53;
|
||||
uint32 oneof_uint32 = 54;
|
||||
uint64 oneof_uint64 = 55;
|
||||
sint32 oneof_sint32 = 56;
|
||||
sint64 oneof_sint64 = 57;
|
||||
fixed32 oneof_fixed32 = 58;
|
||||
fixed64 oneof_fixed64 = 59;
|
||||
sfixed32 oneof_sfixed32 = 60;
|
||||
sfixed64 oneof_sfixed64 = 61;
|
||||
bool oneof_bool = 62;
|
||||
string oneof_string = 63;
|
||||
bytes oneof_bytes = 64;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,50 +16,49 @@ import "google/protobuf/wrappers.proto";
|
|||
package wkt;
|
||||
|
||||
message WellKnownTypes {
|
||||
// Any
|
||||
google.protobuf.Any any = 1;
|
||||
|
||||
// Any
|
||||
google.protobuf.Any any = 1;
|
||||
// Api
|
||||
google.protobuf.Api api = 2;
|
||||
google.protobuf.Method method = 3;
|
||||
google.protobuf.Mixin mixin = 4;
|
||||
|
||||
// Api
|
||||
google.protobuf.Api api = 2;
|
||||
google.protobuf.Method method = 3;
|
||||
google.protobuf.Mixin mixin = 4;
|
||||
// Compiler Plugin
|
||||
google.protobuf.compiler.Version compiler_version = 5;
|
||||
|
||||
// Compiler Plugin
|
||||
google.protobuf.compiler.Version compiler_version = 5;
|
||||
// Descriptor
|
||||
google.protobuf.DescriptorProto descriptor_proto = 6;
|
||||
|
||||
// Descriptor
|
||||
google.protobuf.DescriptorProto descriptor_proto = 6;
|
||||
// Duration
|
||||
google.protobuf.Duration duration = 7;
|
||||
|
||||
// Duration
|
||||
google.protobuf.Duration duration = 7;
|
||||
// Empty
|
||||
google.protobuf.Empty empty = 8;
|
||||
|
||||
// Empty
|
||||
google.protobuf.Empty empty = 8;
|
||||
// Field Mask
|
||||
google.protobuf.FieldMask field_mask = 9;
|
||||
|
||||
// Field Mask
|
||||
google.protobuf.FieldMask field_mask = 9;
|
||||
// Source Context
|
||||
google.protobuf.SourceContext source_context = 10;
|
||||
|
||||
// Source Context
|
||||
google.protobuf.SourceContext source_context = 10;
|
||||
// Struct
|
||||
google.protobuf.Struct struct = 11;
|
||||
|
||||
// Struct
|
||||
google.protobuf.Struct struct = 11;
|
||||
// Timestamp
|
||||
google.protobuf.Timestamp timestamp = 12;
|
||||
|
||||
// Timestamp
|
||||
google.protobuf.Timestamp timestamp = 12;
|
||||
// Type
|
||||
google.protobuf.Type type = 13;
|
||||
|
||||
// Type
|
||||
google.protobuf.Type type = 13;
|
||||
|
||||
// Wrappers
|
||||
google.protobuf.BoolValue bool_value = 14;
|
||||
google.protobuf.BytesValue bytes_value = 15;
|
||||
google.protobuf.DoubleValue double_value = 16;
|
||||
google.protobuf.FloatValue float_value = 17;
|
||||
google.protobuf.Int32Value int32_value = 18;
|
||||
google.protobuf.Int64Value int64_value = 19;
|
||||
google.protobuf.StringValue string_value = 20;
|
||||
google.protobuf.UInt32Value uint32_value = 21;
|
||||
google.protobuf.UInt64Value uint64_value = 22;
|
||||
// Wrappers
|
||||
google.protobuf.BoolValue bool_value = 14;
|
||||
google.protobuf.BytesValue bytes_value = 15;
|
||||
google.protobuf.DoubleValue double_value = 16;
|
||||
google.protobuf.FloatValue float_value = 17;
|
||||
google.protobuf.Int32Value int32_value = 18;
|
||||
google.protobuf.Int64Value int64_value = 19;
|
||||
google.protobuf.StringValue string_value = 20;
|
||||
google.protobuf.UInt32Value uint32_value = 21;
|
||||
google.protobuf.UInt64Value uint64_value = 22;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,9 +31,9 @@ load(":providers.bzl", "CrateGroupInfo", "CrateInfo", "DepInfo", "DepVariantInfo
|
|||
#
|
||||
# Note: Code in `.github/workflows/crate_universe.yaml` looks for this line, if
|
||||
# you remove it or change its format, you will also need to update that code.
|
||||
DEFAULT_RUST_VERSION = "1.70.0"
|
||||
DEFAULT_RUST_VERSION = "1.71.0"
|
||||
|
||||
DEFAULT_NIGHTLY_ISO_DATE = "2023-06-01"
|
||||
DEFAULT_NIGHTLY_ISO_DATE = "2023-07-13"
|
||||
|
||||
def _create_crate_info(**kwargs):
|
||||
"""A constructor for a `CrateInfo` provider
|
||||
|
|
|
@ -24,29 +24,35 @@
|
|||
__attribute__((weak)) uint8_t __rust_alloc_error_handler_should_panic = 0;
|
||||
|
||||
extern "C" uint8_t *__rdl_alloc(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_alloc(uintptr_t size, uintptr_t align) {
|
||||
return __rdl_alloc(size, align);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_alloc(uintptr_t size,
|
||||
uintptr_t align) {
|
||||
return __rdl_alloc(size, align);
|
||||
}
|
||||
extern "C" void __rdl_dealloc(uint8_t *ptr, uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
void __rust_dealloc(uint8_t *ptr, uintptr_t size, uintptr_t align) {
|
||||
__rdl_dealloc(ptr, size, align);
|
||||
extern "C" __attribute__((weak)) void __rust_dealloc(uint8_t *ptr,
|
||||
uintptr_t size,
|
||||
uintptr_t align) {
|
||||
__rdl_dealloc(ptr, size, align);
|
||||
}
|
||||
extern "C" uint8_t *__rdl_realloc(uint8_t *ptr, uintptr_t old_size, uintptr_t align,
|
||||
uintptr_t new_size);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_realloc(uint8_t *ptr, uintptr_t old_size, uintptr_t align,
|
||||
uintptr_t new_size) {
|
||||
return __rdl_realloc(ptr, old_size, align, new_size);
|
||||
extern "C" uint8_t *__rdl_realloc(uint8_t *ptr, uintptr_t old_size,
|
||||
uintptr_t align, uintptr_t new_size);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_realloc(uint8_t *ptr,
|
||||
uintptr_t old_size,
|
||||
uintptr_t align,
|
||||
uintptr_t new_size) {
|
||||
return __rdl_realloc(ptr, old_size, align, new_size);
|
||||
}
|
||||
extern "C" uint8_t *__rdl_alloc_zeroed(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_alloc_zeroed(uintptr_t size, uintptr_t align) {
|
||||
return __rdl_alloc_zeroed(size, align);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_alloc_zeroed(uintptr_t size,
|
||||
uintptr_t align) {
|
||||
return __rdl_alloc_zeroed(size, align);
|
||||
}
|
||||
extern "C" void __rdl_oom(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
void __rust_alloc_error_handler(uintptr_t size, uintptr_t align) {
|
||||
__rdl_oom(size, align);
|
||||
extern "C" __attribute__((weak)) void __rust_alloc_error_handler(
|
||||
uintptr_t size, uintptr_t align) {
|
||||
__rdl_oom(size, align);
|
||||
}
|
||||
|
||||
// New requirement as of Rust 1.71.0. For more details see
|
||||
// https://github.com/rust-lang/rust/issues/73632.
|
||||
__attribute__((weak)) uint8_t __rust_no_alloc_shim_is_unstable = 0;
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
extern "C" int cclinkstampdep() {
|
||||
return 121;
|
||||
}
|
||||
extern "C" int cclinkstampdep() { return 121; }
|
||||
|
|
|
@ -23,30 +23,41 @@
|
|||
// New feature as of https://github.com/rust-lang/rust/pull/88098.
|
||||
__attribute__((weak)) uint8_t __rust_alloc_error_handler_should_panic = 0;
|
||||
|
||||
// As of 1.71.0, the following begin to cause issues if defined. For
|
||||
// more details see https://github.com/rust-lang/rust/issues/73632.
|
||||
/*
|
||||
extern "C" uint8_t *__rg_alloc(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_alloc(uintptr_t size, uintptr_t align) {
|
||||
return __rg_alloc(size, align);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_alloc(uintptr_t size,
|
||||
uintptr_t align) {
|
||||
return __rg_alloc(size, align);
|
||||
}
|
||||
extern "C" void __rg_dealloc(uint8_t *ptr, uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
void __rust_dealloc(uint8_t *ptr, uintptr_t size, uintptr_t align) {
|
||||
__rg_dealloc(ptr, size, align);
|
||||
extern "C" __attribute__((weak)) void __rust_dealloc(uint8_t *ptr,
|
||||
uintptr_t size,
|
||||
uintptr_t align) {
|
||||
__rg_dealloc(ptr, size, align);
|
||||
}
|
||||
extern "C" uint8_t *__rg_realloc(uint8_t *ptr, uintptr_t old_size, uintptr_t align,
|
||||
uintptr_t new_size);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_realloc(uint8_t *ptr, uintptr_t old_size, uintptr_t align,
|
||||
uintptr_t new_size) {
|
||||
return __rg_realloc(ptr, old_size, align, new_size);
|
||||
extern "C" uint8_t *__rg_realloc(uint8_t *ptr, uintptr_t old_size,
|
||||
uintptr_t align, uintptr_t new_size);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_realloc(uint8_t *ptr,
|
||||
uintptr_t old_size,
|
||||
uintptr_t align,
|
||||
uintptr_t new_size) {
|
||||
return __rg_realloc(ptr, old_size, align, new_size);
|
||||
}
|
||||
extern "C" uint8_t *__rg_alloc_zeroed(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
uint8_t *__rust_alloc_zeroed(uintptr_t size, uintptr_t align) {
|
||||
return __rg_alloc_zeroed(size, align);
|
||||
extern "C" __attribute__((weak)) uint8_t *__rust_alloc_zeroed(uintptr_t size,
|
||||
uintptr_t align) {
|
||||
return __rg_alloc_zeroed(size, align);
|
||||
}
|
||||
*/
|
||||
|
||||
extern "C" void __rg_oom(uintptr_t size, uintptr_t align);
|
||||
extern "C" __attribute__((weak))
|
||||
void __rust_alloc_error_handler(uintptr_t size, uintptr_t align) {
|
||||
__rg_oom(size, align);
|
||||
extern "C" __attribute__((weak)) void __rust_alloc_error_handler(
|
||||
uintptr_t size, uintptr_t align) {
|
||||
__rg_oom(size, align);
|
||||
}
|
||||
|
||||
// New requirement as of Rust 1.71.0. For more details see
|
||||
// https://github.com/rust-lang/rust/issues/73632.
|
||||
__attribute__((weak)) uint8_t __rust_no_alloc_shim_is_unstable = 0;
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
extern "C" int32_t four();
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
assert(four() == 4);
|
||||
return 0;
|
||||
assert(four() == 4);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
extern "C" int32_t double_foo();
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
assert(double_foo() == 84);
|
||||
return EXIT_SUCCESS;
|
||||
assert(double_foo() == 84);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "direct.h"
|
||||
|
||||
RustStruct MakeRustStruct() {
|
||||
RustStruct result;
|
||||
return result;
|
||||
RustStruct result;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
struct RustStruct{};
|
||||
struct RustStruct {};
|
||||
|
||||
extern "C" RustStruct MakeRustStruct();
|
||||
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
extern int32_t return_5_in_no_std();
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
assert(return_5_in_no_std() == 5);
|
||||
return 0;
|
||||
assert(return_5_in_no_std() == 5);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void lib() {
|
||||
printf("Hello, C lib!");
|
||||
}
|
||||
void lib() { printf("Hello, C lib!"); }
|
||||
|
|
|
@ -13,178 +13,180 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
void basic_part1_test(std::string current_dir_arg) {
|
||||
if (current_dir_arg != "--current-dir") {
|
||||
std::cerr << "error: argument \"--current-dir\" not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
if (current_dir_arg != "--current-dir") {
|
||||
std::cerr << "error: argument \"--current-dir\" not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void basic_part2_test(std::string current_dir, const char* envp[]) {
|
||||
if (current_dir != "${pwd}") {
|
||||
std::cerr << "error: unsubsituted ${pwd} not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
const std::string current_dir_env = "CURRENT_DIR=${pwd}/test_path";
|
||||
bool found = false;
|
||||
for (int i = 0; envp[i] != nullptr; ++i) {
|
||||
if (current_dir_env == envp[i]) {
|
||||
found = true;
|
||||
break;
|
||||
if (current_dir != "${pwd}") {
|
||||
std::cerr << "error: unsubsituted ${pwd} not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
const std::string current_dir_env = "CURRENT_DIR=${pwd}/test_path";
|
||||
bool found = false;
|
||||
for (int i = 0; envp[i] != nullptr; ++i) {
|
||||
if (current_dir_env == envp[i]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
std::cerr << "unsubsituted CURRENT_DIR not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
std::cerr << "unsubsituted CURRENT_DIR not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void subst_pwd_test(int argc, const char* argv[], const char* envp[]) {
|
||||
std::string current_dir = argv[3];
|
||||
if (current_dir.find("${pwd}") != std::string::npos) {
|
||||
std::cerr << "error: argument ${pwd} substitution failed.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
// find the param file using its "@" prefix
|
||||
std::string param_file;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (argv[i][0] == '@') {
|
||||
param_file = std::string(argv[i]+1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (param_file.empty()) {
|
||||
std::cerr << "error: no param file.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
std::string param_file_line;
|
||||
getline(std::ifstream(param_file), param_file_line);
|
||||
if (param_file_line != current_dir) {
|
||||
std::cerr << "error: param file " << param_file << " should contain " << current_dir << ", found " << param_file_line << ".\n";
|
||||
std::exit(1);
|
||||
}
|
||||
bool found = false;
|
||||
for (int i = 0; envp[i] != nullptr; ++i) {
|
||||
const std::string env = envp[i];
|
||||
if (env.rfind("CURRENT_DIR", 0) == 0) {
|
||||
found = true;
|
||||
if (env.find("${pwd}") != std::string::npos) {
|
||||
std::cerr
|
||||
<< "error: environment variable ${pwd} substitution failed.\n";
|
||||
std::string current_dir = argv[3];
|
||||
if (current_dir.find("${pwd}") != std::string::npos) {
|
||||
std::cerr << "error: argument ${pwd} substitution failed.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
// find the param file using its "@" prefix
|
||||
std::string param_file;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (argv[i][0] == '@') {
|
||||
param_file = std::string(argv[i] + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (param_file.empty()) {
|
||||
std::cerr << "error: no param file.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
std::string param_file_line;
|
||||
getline(std::ifstream(param_file), param_file_line);
|
||||
if (param_file_line != current_dir) {
|
||||
std::cerr << "error: param file " << param_file << " should contain "
|
||||
<< current_dir << ", found " << param_file_line << ".\n";
|
||||
std::exit(1);
|
||||
}
|
||||
bool found = false;
|
||||
for (int i = 0; envp[i] != nullptr; ++i) {
|
||||
const std::string env = envp[i];
|
||||
if (env.rfind("CURRENT_DIR", 0) == 0) {
|
||||
found = true;
|
||||
if (env.find("${pwd}") != std::string::npos) {
|
||||
std::cerr << "error: environment variable ${pwd} substitution "
|
||||
"failed.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
std::cerr << "CURRENT_DIR not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
std::cerr << "CURRENT_DIR not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void env_files_test(const char* envp[]) {
|
||||
const std::string must_exist[] = {
|
||||
"FOO=BAR",
|
||||
"FOOBAR=BARFOO",
|
||||
"BAR=FOO",
|
||||
"ENV_ESCAPE=with\nnew line",
|
||||
"ENV_NO_ESCAPE=with no new line\\",
|
||||
"ENV_ESCAPE_WITH_BACKSLASH=new line\\\nhere",
|
||||
};
|
||||
for (const std::string& env : must_exist) {
|
||||
bool found = false;
|
||||
for (int i = 0; envp[i] != nullptr; ++i) {
|
||||
if (env == envp[i]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
const std::string must_exist[] = {
|
||||
"FOO=BAR",
|
||||
"FOOBAR=BARFOO",
|
||||
"BAR=FOO",
|
||||
"ENV_ESCAPE=with\nnew line",
|
||||
"ENV_NO_ESCAPE=with no new line\\",
|
||||
"ENV_ESCAPE_WITH_BACKSLASH=new line\\\nhere",
|
||||
};
|
||||
for (const std::string& env : must_exist) {
|
||||
bool found = false;
|
||||
for (int i = 0; envp[i] != nullptr; ++i) {
|
||||
if (env == envp[i]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
std::cerr << "error: environment variable \"" << env
|
||||
<< "\" not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
std::cerr << "error: environment variable \"" << env << "\" not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void arg_files_test(int argc, const char* argv[]) {
|
||||
const std::string must_exist[] = {
|
||||
"--arg1=foo",
|
||||
"--arg2",
|
||||
"foo bar",
|
||||
"--arg2=bar",
|
||||
"--arg3",
|
||||
"foobar",
|
||||
"arg with\nnew line",
|
||||
"arg with\\",
|
||||
"no new line",
|
||||
"arg with\\\nnew line and a trailing backslash",
|
||||
};
|
||||
const std::string must_exist[] = {
|
||||
"--arg1=foo",
|
||||
"--arg2",
|
||||
"foo bar",
|
||||
"--arg2=bar",
|
||||
"--arg3",
|
||||
"foobar",
|
||||
"arg with\nnew line",
|
||||
"arg with\\",
|
||||
"no new line",
|
||||
"arg with\\\nnew line and a trailing backslash",
|
||||
};
|
||||
|
||||
for (const std::string& arg : must_exist) {
|
||||
bool found = false;
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
if (arg == argv[i]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
for (const std::string& arg : must_exist) {
|
||||
bool found = false;
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
if (arg == argv[i]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
std::cerr << "error: argument \"" << arg << "\" not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
std::cerr << "error: argument \"" << arg << "\" not found.\n";
|
||||
std::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_stdout() {
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
for (int i = 0; i < 10000; ++i) {
|
||||
// On windows writing LF to any stream in text mode gets changed to CRLF
|
||||
// Since the test file is saved using CRLF, we are forcing the same on
|
||||
// non windows systems
|
||||
#if defined(_WIN32)
|
||||
std::cout << "Child process to stdout : " << i << "\n";
|
||||
std::cout << "Child process to stdout : " << i << "\n";
|
||||
#else
|
||||
std::cout << "Child process to stdout : " << i << "\r\n";
|
||||
std::cout << "Child process to stdout : " << i << "\r\n";
|
||||
#endif // defined(_WIN32)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_stderr() { std::cerr << "This is the stderr output"; }
|
||||
|
||||
int main(int argc, const char* argv[], const char* envp[]) {
|
||||
if (argc < 4) {
|
||||
std::cerr << "error: Invalid number of args exected at least 4 got " << argc
|
||||
<< ".\n";
|
||||
return 1;
|
||||
}
|
||||
std::string test_config = argv[1];
|
||||
bool combined = test_config == "combined";
|
||||
if (combined || test_config == "basic") {
|
||||
basic_part1_test(argv[2]);
|
||||
}
|
||||
if (argc < 4) {
|
||||
std::cerr << "error: Invalid number of args exected at least 4 got "
|
||||
<< argc << ".\n";
|
||||
return 1;
|
||||
}
|
||||
std::string test_config = argv[1];
|
||||
bool combined = test_config == "combined";
|
||||
if (combined || test_config == "basic") {
|
||||
basic_part1_test(argv[2]);
|
||||
}
|
||||
|
||||
if (combined || test_config == "subst-pwd") {
|
||||
subst_pwd_test(argc, argv, envp);
|
||||
} else if (test_config == "basic") {
|
||||
basic_part2_test(argv[3], envp);
|
||||
}
|
||||
if (combined || test_config == "subst-pwd") {
|
||||
subst_pwd_test(argc, argv, envp);
|
||||
} else if (test_config == "basic") {
|
||||
basic_part2_test(argv[3], envp);
|
||||
}
|
||||
|
||||
if (combined || test_config == "env-files") {
|
||||
env_files_test(envp);
|
||||
}
|
||||
if (combined || test_config == "env-files") {
|
||||
env_files_test(envp);
|
||||
}
|
||||
|
||||
if (combined || test_config == "arg-files") {
|
||||
arg_files_test(argc, argv);
|
||||
}
|
||||
if (combined || test_config == "arg-files") {
|
||||
arg_files_test(argc, argv);
|
||||
}
|
||||
|
||||
if (combined || test_config == "stdout") {
|
||||
test_stdout();
|
||||
}
|
||||
if (combined || test_config == "stdout") {
|
||||
test_stdout();
|
||||
}
|
||||
|
||||
if (combined || test_config == "stderr") {
|
||||
test_stderr();
|
||||
}
|
||||
if (combined || test_config == "stderr") {
|
||||
test_stderr();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#include "first.h"
|
||||
|
||||
int get_one() {
|
||||
return 1;
|
||||
}
|
||||
int get_one() { return 1; }
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#include "second.h"
|
||||
|
||||
int get_two() {
|
||||
return 2;
|
||||
}
|
||||
int get_two() { return 2; }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
extern "C" void hello(void);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
hello();
|
||||
return 0;
|
||||
hello();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -27,3 +27,4 @@
|
|||
2023-03-23
|
||||
2023-04-20
|
||||
2023-06-01
|
||||
2023-07-13
|
||||
|
|
|
@ -59,3 +59,4 @@
|
|||
1.68.2
|
||||
1.69.0
|
||||
1.70.0
|
||||
1.71.0
|
||||
|
|
|
@ -308,7 +308,7 @@ fn environment_block(
|
|||
// Have the last values added take precedence over the first.
|
||||
// This is simpler than needing to track duplicates and explicitly override
|
||||
// them.
|
||||
environment_variables.extend(environment_file_block.into_iter());
|
||||
environment_variables.extend(environment_file_block);
|
||||
for (f, replace_with) in &[stable_stamp_mappings, volatile_stamp_mappings].concat() {
|
||||
for value in environment_variables.values_mut() {
|
||||
let from = format!("{{{f}}}");
|
||||
|
|
|
@ -84,13 +84,13 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_read_to_array() {
|
||||
let input = r#"some escaped \\\
|
||||
let input = r"some escaped \\\
|
||||
string
|
||||
with other lines"#
|
||||
with other lines"
|
||||
.to_owned();
|
||||
let expected = vec![
|
||||
r#"some escaped \
|
||||
string"#,
|
||||
r"some escaped \
|
||||
string",
|
||||
"with other lines",
|
||||
];
|
||||
let got = read_to_array(input.as_bytes()).unwrap();
|
||||
|
|
Loading…
Reference in New Issue