Page MenuHomePhabricator

[services] Tunnelbroker - Creating `build.rs` file for building and linking C++ dependencies
ClosedPublic

Authored by max on Oct 20 2022, 7:39 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 26, 5:26 AM
Unknown Object (File)
Tue, Nov 26, 5:25 AM
Unknown Object (File)
Mon, Nov 25, 3:44 AM
Unknown Object (File)
Mon, Nov 25, 3:44 AM
Unknown Object (File)
Mon, Nov 25, 3:44 AM
Unknown Object (File)
Mon, Nov 25, 3:44 AM
Unknown Object (File)
Mon, Nov 25, 3:44 AM
Unknown Object (File)
Mon, Nov 25, 3:44 AM

Details

Summary

This diff is a part of the flat diffs stack to transform the current Tunnelbroker project into a Rust app by calling the current C++ codebase from Rust. The related transition task is ENG-1072.

This diff creates a Cargo build.rs file which builds and links the current C++ codebase to the Rust application.

Related Linear task and discussion: ENG-2093

CI Notice:
The CI will fail on this and further diffs until the D5461 where the changes to CI build commands are made.
This stack will be landed all in one to prevent CI from failing on diffs out of this stack.

Test Plan

1. CI Testing:
These diff changes are included as a part of the stack in the later D5461 diff, where the changes to CI build commands are made. The CI succeded on the D5461 which reflects that this changes are passing the build.

2. Manually testing:
These diff changes can be tested in the middle of the stack at D5436. To test it patch to D5436 using arc patch D5436, run nix develop. Go to tunnelbroker service directory services/tunnelbroker and run the Cargo building process cargo build or cargo run.
The Rust application will be successfully built.

Diff Detail

Repository
rCOMM Comm
Branch
add-build-rs
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

max held this revision as a draft.
max edited the test plan for this revision. (Show Details)
max added reviewers: varun, marcin. max added 1 blocking reviewer(s): jon.
max published this revision for review.Oct 20 2022, 8:26 AM
max edited the summary of this revision. (Show Details)

Adding of Tunnelbroker[.h,.cpp] to the if-changed scope.

services/tunnelbroker/build.rs
16 ↗(On Diff #17735)

We are using this function instead of passing the string path directly because the CFG.exported_header_dirs wants an absolute path and we are making it here from the relative.

30 ↗(On Diff #17735)

We are using the get_cpp_sources function to traverse the directory and get all the .cpp inside to be built.

Adding of -w flag to the C++ building process to suppress flooding of warnings.

Removing of unused PathBuff.

Fixing include path to meet the Docker, adding of linking double-conversion and gflags for the building in Ubuntu Docker container.

Updating on the stack reordering.

Update on a stack changes.

max edited the test plan for this revision. (Show Details)
jon requested changes to this revision.Oct 26 2022, 2:01 PM
jon added inline comments.
services/tunnelbroker/build.rs
8–10 ↗(On Diff #17865)

feel like this is a bit hard to read, and we should avoid explicit unwraps

11 ↗(On Diff #17865)

String::from and .to_string() should be redundant

17 ↗(On Diff #17865)

unwrap -> expect please.

This revision now requires changes to proceed.Oct 26 2022, 2:01 PM
max marked 3 inline comments as done.

Small changes addressing comments.

services/tunnelbroker/build.rs
8–10 ↗(On Diff #17865)

feel like this is a bit hard to read, and we should avoid explicit unwraps

I don't mind changing it if you find it hard to read.
Changed.

11 ↗(On Diff #17865)

String::from and .to_string() should be redundant

Good catch, thanks!

This revision is now accepted and ready to land.Nov 3 2022, 9:45 AM
This revision now requires review to proceed.Nov 3 2022, 10:24 AM
tomek added inline comments.
services/tunnelbroker/build.rs
7 ↗(On Diff #18022)

I guess we could use vec! macro

24–28 ↗(On Diff #18022)

Is it possible to provide a wildcard - any directory under src?

This revision is now accepted and ready to land.Nov 4 2022, 7:27 AM

Changing to use vec! macro.

max added inline comments.
services/tunnelbroker/build.rs
7 ↗(On Diff #18022)

I guess we could use vec! macro

Yes, we can! I've changed it.

24–28 ↗(On Diff #18022)

Is it possible to provide a wildcard - any directory under src?

Unfortunately no, it fails if we try to use any of the regexes like src/libcpp/src/*/:

thread 'main' panicked at 'Error getting full import path
max marked 2 inline comments as done.

Rebasing.

This revision was landed with ongoing or failed builds.Nov 7 2022, 6:04 AM
This revision was automatically updated to reflect the committed changes.