Giter Club home page Giter Club logo

Comments (10)

jschwe avatar jschwe commented on June 21, 2024 1

Thanks for the report! I think know where the issue is and hope I can find a bit of time and fix it before the end of the week.

from corrosion.

jschwe avatar jschwe commented on June 21, 2024 1

Edit: it seems only the Debug folder is populated, the Release folder is empty when that command executes.

I've done a bit of investigating and tried out multiple different things, but it turns out this one is actually quite hard to fix.
The "proper way" of adding the built outputs as BYPRODUCTS of the cargo build custom target is not an option, since the output location of the artifacts depend on target properties of the imported target, such as hostbuild or the used cargo profile (dev/release/...). Sadly, BYPRODUCTS are not allowed to use target specific generator expressions.

I think I could perhaps work around the issue by creating per-config dummy output files, and using those files to specify the appropriate dependencies, but it requires a bit of refactoring.

from corrosion.

jschwe avatar jschwe commented on June 21, 2024

Are you setting any of the OUTPUT_DIRECTORY variables in your project?

from corrosion.

xTachyon avatar xTachyon commented on June 21, 2024

In the original project I found this problem, yes.
In this test project I just created, no.

from corrosion.

jschwe avatar jschwe commented on June 21, 2024

@xTachyon Could you test if #492 fixes your main issue? It's not a complete fix, since if the user sets OUTPUT_DIRECTORY to a path that does not differ per config, you would still run into the issue, while for normal CMake C/C++ executables CMake would implicitly add a $<CONFIG>. I'll probably fix that too, but if #492 is sufficient, then I would open a seperate issue for it and fix it later.

from corrosion.

xTachyon avatar xTachyon commented on June 21, 2024

It's another error now!

➜  build cmake --build . --verbose
Change Dir: '/home/x/y/repos/mytest/build'

Run Build Command(s): /usr/bin/ninja -v
[0/7] cd /home/x/y/repos/mytest/the_rust_lib && /usr/bin/cmake -E env CC_x86_64_unknown_linux_gnu=/usr/bin/cc CXX_x86_64_unknown_linux_gnu=/usr/bin/c++ AR_x86_64_unknown_linux_gnu=/usr/bin/ar CORROSION_BUILD_DIR=/home/x/y/repos/mytest/build CARGO_BUILD_RUSTC=/home/x/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc /home/x/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo rustc --lib --target=x86_64-unknown-linux-gnu --package the_rust_lib --manifest-path /home/x/y/repos/mytest/the_rust_lib/Cargo.toml --target-dir /home/x/y/repos/mytest/build/Debug/cargo/build -- -Cdefault-linker-libraries=yes
   Compiling the_rust_lib v0.1.0 (/home/x/y/repos/mytest/the_rust_lib)
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
[2/7] cd /home/x/y/repos/mytest/build && /usr/bin/cmake -E make_directory /home/x/y/repos/mytest/build/Release && /usr/bin/cmake -E copy_if_different /home/x/y/repos/mytest/build/Release/cargo/build/x86_64-unknown-linux-gnu/release/libthe_rust_lib.a /home/x/y/repos/mytest/build/Release
FAILED: CMakeFiles/Release/_cargo-build_the_rust_lib.util Release/libthe_rust_lib.a /home/x/y/repos/mytest/build/Release/libthe_rust_lib.a 
cd /home/x/y/repos/mytest/build && /usr/bin/cmake -E make_directory /home/x/y/repos/mytest/build/Release && /usr/bin/cmake -E copy_if_different /home/x/y/repos/mytest/build/Release/cargo/build/x86_64-unknown-linux-gnu/release/libthe_rust_lib.a /home/x/y/repos/mytest/build/Release
Error copying file (if different) from "/home/x/y/repos/mytest/build/Release/cargo/build/x86_64-unknown-linux-gnu/release/libthe_rust_lib.a" to "/home/x/y/repos/mytest/build/Release".
[3/7] cd /home/x/y/repos/mytest/build && /usr/bin/cmake -E make_directory /home/x/y/repos/mytest/build/Debug && /usr/bin/cmake -E copy_if_different /home/x/y/repos/mytest/build/Debug/cargo/build/x86_64-unknown-linux-gnu/debug/libthe_rust_lib.a /home/x/y/repos/mytest/build/Debug
ninja: build stopped: subcommand failed.

Edit: it seems only the Debug folder is populated, the Release folder is empty when that command executes.

from corrosion.

jschwe avatar jschwe commented on June 21, 2024

Could you share the test project you created?

from corrosion.

xTachyon avatar xTachyon commented on June 21, 2024

I believe the only relevant part of the project is the cmake:

cmake_minimum_required(VERSION 3.27)

project(mytest)

add_executable(mytest main.cpp)

add_subdirectory(corrosion)
corrosion_import_crate(MANIFEST_PATH
    the_rust_lib/Cargo.toml
    NO_LINKER_OVERRIDE
    FLAGS
)
target_link_libraries(mytest the_rust_lib)

The rust lib is just a staticlib which exports a symbol, which main.cpp uses. I could share a zip with all the files if you want.

from corrosion.

jschwe avatar jschwe commented on June 21, 2024

Hmm, that doesn't sound very different from our rust2cpp test case. If you don't mind to share it, I would like to test it with your zip. I'm travelling this week though (thus also the slow response), so I probably won't have time before next week to investigate.

from corrosion.

xTachyon avatar xTachyon commented on June 21, 2024

https://drive.google.com/file/d/1A1I2xiC5nqR5u8MJM6ZlQDEieGqn7OOX/view?usp=drive_link

from corrosion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.