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

Allow non IOS builds (for our dev tools) #1

Open
colbyn opened this issue Jun 19, 2021 · 2 comments
Open

Allow non IOS builds (for our dev tools) #1

colbyn opened this issue Jun 19, 2021 · 2 comments

Comments

@colbyn
Copy link

colbyn commented Jun 19, 2021

This check in build.rs breaks my development tools.
I.e. !target.contains("apple-ios") in:

fn main() {
    let target = std::env::var("TARGET").unwrap();
    if !target.contains("apple-ios") { 
        panic!("uikit-sys requires the ios target");
    }

    let directory = sdk_path(&target).ok();
    build(directory.as_ref().map(String::as_ref), &target);
}

I believe the rust wasm bindgen team just implemented stubs for non WebAssembly targets. Can this library do the same?

@simlay
Copy link
Owner

simlay commented Aug 12, 2021

Hi! Sorry for the late response, clearly something is wrong with my github notifications.

I believe the rust wasm bindgen team just implemented stubs for non WebAssembly targets. Can this library do the same?

Hmm. I suppose that could be done. It will just produce an empty lib.

I'm curious how it breaks your development tools.

@colbyn
Copy link
Author

colbyn commented Aug 12, 2021

@simlay Oh I don't have the error on hand (I decided against using rust for this purpose). But form looking at my snippet, you can see that it'll panic (see the line panic!("uikit-sys requires the ios target");):

fn main() {
    let target = std::env::var("TARGET").unwrap();
    if !target.contains("apple-ios") { 
        panic!("uikit-sys requires the ios target");
    }

    let directory = sdk_path(&target).ok();
    build(directory.as_ref().map(String::as_ref), &target);
}

This will cause the build to fail and therefore your rust development tools will report an error.

Regarding

Hmm. I suppose that could be done. It will just produce an empty lib.

This isn't necessarily any better, because as soon as you try to reference something from the library, you'll get an undefined error (and obviously no autocomplete). What you want is to produce the same symbols as just stubs that fail when you try to call such at runtime. This is (if I can recall correctly) what the WASM bindgen team does.

Update: for an example, running cargo check (which is used by e.g. rust analyzer) yields:

   Compiling uikit-sys v0.0.1 (/Users/colbyn/Scratch/uikit-sys)
error: failed to run custom build command for `uikit-sys v0.0.1 (/Users/colbyn/Scratch/uikit-sys)`

Caused by:
  process didn't exit successfully: `/Users/colbyn/Scratch/uikit-sys/target/debug/build/uikit-sys-0d40961a6e9dc9ce/build-script-build` (exit code: 101)
  --- stderr
  thread 'main' panicked at 'uikit-sys requires the ios target', build.rs:85:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants