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

[Feature Request]: Ability to Selectively Hide Functions #851

Open
lexi-the-cute opened this issue Jun 25, 2023 · 0 comments
Open

[Feature Request]: Ability to Selectively Hide Functions #851

lexi-the-cute opened this issue Jun 25, 2023 · 0 comments

Comments

@lexi-the-cute
Copy link

Looking at the defines section, I see I can convert cfgs to defines, but what I'd like to be able to do is just to mimic /// cbindgen:ignore depending on the cfg.

For example, in my lib.rs I have:

#[no_mangle]
#[cfg(not(target_os="android"))]
pub extern fn ce_start(argc: c_int, argv: *const *const c_char) -> c_int {
    game::setup_logger();
    debug!("Launched as library...");
    
    // This is to convert from C Main Args to Rust Main Args
    let _argc: isize = argc.try_into().unwrap();
    let _argv: *const *const u8 = argv as *const *const u8;

    return game::launch(_argc, _argv).try_into().unwrap();
}

The cfg, #[cfg(not(target_os="android"))], prevents it from being exported on Android because I have no idea what will happen when one tries to run the engine without passing the AndroidApp var that is passed in from GameActivity. I pass it to winit, starting from a separate function called android_main. This is used to load the engine as opposed to ce_start which is used for launching as a native library. The point is, I don't want ce_start to show up in my bindings when I compile for Android.

I give a copy of the bindings file for each platform I build and different functions are available depending on what the platform is.

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

1 participant