Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

TY-2194 code generation parts [2] #2

Merged
merged 25 commits into from
Jan 12, 2022
Merged

Conversation

rustonaut
Copy link
Contributor

No description provided.

@rustonaut rustonaut force-pushed the TY-2194-2-code-generation-parts branch from 4765fac to 0c44cd9 Compare December 13, 2021 15:37
@rustonaut rustonaut changed the title Ty 2194 2 code generation parts Ty 2194 code generation parts [2] Dec 14, 2021
@rustonaut rustonaut force-pushed the TY-2194-2-code-generation-parts branch 3 times, most recently from e422f0e to db5ea0a Compare December 14, 2021 15:22
@janpetschexain janpetschexain changed the title Ty 2194 code generation parts [2] TY-2194 code generation parts [2] Dec 21, 2021
Copy link
Contributor

@janpetschexain janpetschexain left a comment

Choose a reason for hiding this comment

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

this currently even fails to check:

cargo check
    Updating git repository `ssh://git@github.com/xaynetwork/xayn_dart_api_dl.git`
error: failed to resolve patches for `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to load source for dependency `xayn-dart-api-dl`

Caused by:
  Unable to update ssh://git@github.com/xaynetwork/xayn_dart_api_dl.git?branch=TY-2221-2-bindings-for-dart-api-dl-h

Caused by:
  failed to fetch into: /Users/janpetsche/.cargo/git/db/xayn_dart_api_dl-0480252925562bf4

Caused by:
  failed to authenticate when downloading repository

  * attempted ssh-agent authentication, but no usernames succeeded: `git`

  if the git CLI succeeds then `net.git-fetch-with-cli` may help here
  https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
  no authentication available

.github/workflows/integration_tests_ci.yml Outdated Show resolved Hide resolved
async-bindgen-derive/Cargo.toml Outdated Show resolved Hide resolved
async-bindgen-derive/Cargo.toml Outdated Show resolved Hide resolved
async-bindgen-derive/src/error.rs Outdated Show resolved Hide resolved
async-bindgen-derive/src/error.rs Outdated Show resolved Hide resolved
async-bindgen-derive/src/lib.rs Outdated Show resolved Hide resolved
async-bindgen-gen-dart/Cargo.toml Outdated Show resolved Hide resolved
async-bindgen-gen-dart/src/parse_genesis.rs Outdated Show resolved Hide resolved
Comment on lines +3 to +6
let left = $left;
let mut left = $crate::test_utils::trimmed_non_empty_lines(&left);
let right = $right;
let mut right = $crate::test_utils::trimmed_non_empty_lines(&right);
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems unnecessary that the macro takes its arguments by value, is there a temporary reference issue? (can't check myself because code doesn't compile)

Suggested change
let left = $left;
let mut left = $crate::test_utils::trimmed_non_empty_lines(&left);
let right = $right;
let mut right = $crate::test_utils::trimmed_non_empty_lines(&right);
let mut left = $crate::test_utils::trimmed_non_empty_lines(&$left);
let mut right = $crate::test_utils::trimmed_non_empty_lines(&$right);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Though assert statements in general get called with values all the time and then there would be an temporary reference issue and requiring an explicit referencing of values isn't good UX while an additional & normally doesn't cause problems.

async-bindgen-gen-dart/src/test_utils.rs Outdated Show resolved Hide resolved
@rustonaut
Copy link
Contributor Author

rustonaut commented Jan 3, 2022

this currently even fails to check

it fails to access the private repository, i.e. it fails before it even comes to checking.

To access private repositories as dependencies with cargo you need to have a running ssh agent.

Git CLI has a workarounds for the case no ssh-agent is running, but a .ssh folder with keys exists.
libgit used by cargo doesn't support that.

You can either:

  • setup an ssh agent
  • set the CARGO_NET_GIT_FETCH_WITH_CLI env variable to true to force cargo to use git CLI.
  • or in ~/.cargo/config add
    [net]
    git-fetch-with-cli = true

Related issues:

I also had to do this in the CI.

I originally wanted to make the repos public before the holidays, but thinks got in the way (like the whole thing about how to license things).

@rustonaut rustonaut force-pushed the TY-2194-2-code-generation-parts branch from d3acece to c3b6d0d Compare January 6, 2022 08:30
@rustonaut rustonaut force-pushed the TY-2194-2-code-generation-parts branch 2 times, most recently from 622797f to 01e578a Compare January 7, 2022 07:07
@rustonaut rustonaut force-pushed the TY-2194-2-code-generation-parts branch from 65ad9f4 to a13085f Compare January 7, 2022 10:18
@rustonaut
Copy link
Contributor Author

Be ware that due to the limitations mentioned in the (pre-)previous daily you might need to run cargo check once where it fails before being able to properly check it. Your IDE will probably do it for you. But that's why there is e.g. an

cargo check --quiet 2>/dev/null in test.sh

Copy link

@Robert-Steiner Robert-Steiner left a comment

Choose a reason for hiding this comment

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

looks good 👍 Just a few suggestions/questions
I was also able to run test.sh script

integration-tests-bindings/.gitignore Outdated Show resolved Hide resolved
async-bindgen-derive/src/generate/dart_glue.rs Outdated Show resolved Hide resolved
async-bindgen-derive/src/lib.rs Show resolved Hide resolved
}
";

static CLASS_TEMPLATE_NAME: &str = "class";

Choose a reason for hiding this comment

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

would it make sense to use consthere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I'm now wondering if it actually makes a difference in the generated code. 🤔

Like at least most times due to the nature of &str it makes sense for rust to generate roughly the same code for const strings of it as it does for statics ones ,I think (i.e. place it once in the executable in read-only memory and reference it from there).

And while it could optimize some pointer address comparisons differently, you probably don't run into them in rust in this context most of the times.

Anyway const is stylistically more appropriate for this use-cases so I switched to it.

Choose a reason for hiding this comment

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

I was also not sure if this makes any difference 😅

Anyway const is stylistically more appropriate for this use-cases so I switched to it.

👍

@rustonaut rustonaut merged commit b10a8b2 into main Jan 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants