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

Build in workspace #31

Closed
alecnotthompson opened this issue Jun 30, 2021 · 5 comments
Closed

Build in workspace #31

alecnotthompson opened this issue Jun 30, 2021 · 5 comments
Labels
priority: low Nice to have status: needs discussion Direction must be ironed out type: enhancement Wouldn't this be the coolest?

Comments

@alecnotthompson
Copy link

alecnotthompson commented Jun 30, 2021

Cool tool! Found it at just the right time for a project I'm starting.

I am working on a project and am hoping to keep everything in a monorepo. The workspace members are defined with members = ["library/*"] and I created the mobile project with cargo mobile new library/mobile. Everything was set up just fine. Unfortunately I get the following build error:

=== BUILD TARGET mobile_iOS OF PROJECT mobile WITH CONFIGURATION debug ===
ld: warning: directory not found for option '-L/Users/isaac/local/<project>/library/mobile/target/aarch64-apple-ios/debug'
ld: library not found for -lmobile
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **

I don't have much time to dig around in the code base to find where to start but if you point me to where the path generation is I can probably fix the rest. Thanks in advance!

@zeerooth
Copy link
Contributor

Unfortunately, it's going to be pretty difficult to get cargo-mobile to work with workspaces or even with custom target directories because cargo doesn't really have a reliable option to retrieve the target directory of current project from a crate that's just a dependency, so cargo-mobile right now just guesses that the project uses default target directory in the root of the project (which is true most of the time, but not in some cases like yours).

I guess it's possible to do something like adding a new key to mobile.toml where it's possible to specify custom target directory, but I don't really like it because it'll duplicate the information cargo already holds and if you rename the project, move it, change the target-dir in cargo config it'll break again.

@zeerooth zeerooth added priority: low Nice to have status: needs discussion Direction must be ironed out type: enhancement Wouldn't this be the coolest? labels Jul 10, 2021
@katyo
Copy link

katyo commented Feb 22, 2022

@zeerooth,

Seems still have problems with workspace. I tried to build android app from workspace member subdirectory and I failed to do it:

$ cargo mobile android build
   Compiling demo v0.1.0 (/home/kayo/devel/oboe-rs/demo)
    Finished dev [unoptimized + debuginfo] target(s) in 1.44s
error: Failed to symlink lib
    The symlink source is "/home/kayo/devel/oboe-rs/demo/target/aarch64-linux-android/debug/libdemo.so", but nothing exists there

Actually the target directory located at workspace root directory, not in the member subdirectory.
When I created symlink to it the app built successfully.

@alecnotthompson
Copy link
Author

Sorry, should have added a comment. After the above comment I realized that I just needed to make a lib.rs file with a #[mobile_entry_point] fn that used my crates and a [bin] entry in my cargo.toml for my binary. Turned out to be essentially the same organization that I wanted

@FrankenApps
Copy link

@alecnotthompson So basically you are not using a workspace anymore?

Because I would like to use a workspace and I am running into the problem mentioned by @zeerooth:

=== BUILD TARGET my-app_iOS OF PROJECT my-app WITH CONFIGURATION debug ===
ld: warning: directory not found for option '-L/Users/mypath/my_workspace/my-app/target/aarch64-apple-ios/debug'
ld: library not found for -lmy_workspace
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **

error: Failed to build via `xcodebuild`
    Command "xcodebuild -quiet -scheme my-app_iOS -workspace /Users/my-path/my_workspace/my-app/gen/apple/wgpu-playground.xcodeproj/project.xcworkspace/ -configuration debug -arch
    arm64 -allowProvisioningUpdates build" didn't complete successfully, exiting with code 65.

Therefore I think this should be reopened?

@alecnotthompson
Copy link
Author

No based on what the members said I think there should be a “wontfix” label. I’m still using a workspace but the entry point for each application needs to be in the root which is easily handled with cargo cfg/target attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low Nice to have status: needs discussion Direction must be ironed out type: enhancement Wouldn't this be the coolest?
Projects
None yet
Development

No branches or pull requests

4 participants