/// For each build target and cargo binary or example target, produce a shared library
For each build target and cargo binary or example target, produce a shared library
For each build target and cargo binary or example target produce a shared library
pub fn build_shared_libraries(
    workspace: &Workspace,
    config: &AndroidConfig,
    options: &ArgMatches,
    root_build_dir: &PathBuf,
) -> CargoResult<SharedLibraries> {
    let injected_glue_src_path = write_injected_glue_src(&root_build_dir)?;
    let android_native_glue_src_path = write_native_app_glue_src(&root_build_dir)?;
    let shared_libraries: Arc<Mutex<MultiMap<Target, SharedLibrary>>> =
        Arc::new(Mutex::new(MultiMap::new()));
    for build_target in config.build_targets.iter() {
        let build_target = *build_target;
        // Directory that will contain files specific to this build target
        let build_target_dir = root_build_dir.join(build_target.android_abi());
        fs::create_dir_all(&build_target_dir).unwrap();
        // Set environment variables needed for use with the cc crate
        std::env::set_var(format!("CC_{}", build_target.rust_triple()), util::find_clang(config, build_target)?);
        std::env::set_var(format!("CXX_{}", build_target.rust_triple()), util::find_clang_cpp(config, build_target)?);
        std::env::set_var(format!("AR_{}", build_target.rust_triple()), util::find_ar(config, build_target)?);
        // Use libc++. It is current default C++ runtime
        std::env::set_var(format!("CXXSTDLIB_{}", build_target.rust_triple()), "c++");
        // Generate cmake toolchain and set environment variables to allow projects which use the cmake crate to build correctly
        let cmake_toolchain_path = write_cmake_toolchain(config, &build_target_dir, build_target)?;
        std::env::set_var("CMAKE_TOOLCHAIN_FILE", cmake_toolchain_path);
        std::env::set_var("CMAKE_GENERATOR", r#"Unix Makefiles"#);
        std::env::set_var("CMAKE_MAKE_PROGRAM", util::make_path(config));
        // Build android_native_glue and injected-glue
        let injected_glue_lib = build_injected_glue(
            workspace,
            config,
            &injected_glue_src_path,
            &build_target_dir,
            build_target,
        )?;
        let android_native_glue_object = build_android_native_glue(
            config,
            &android_native_glue_src_path,
            &build_target_dir,
            build_target,
        )?;
        // Configure compilation options so that we will build the desired build_target
        let mut opts =
            options.compile_options(workspace.config(), CompileMode::Build, Some(&workspace))?;
        opts.build_config.requested_target = Some(build_target.rust_triple().to_owned());
        // Create executor
        let config = Arc::new(config.clone());
        let executor: Arc<dyn Executor> = Arc::new(SharedLibraryExecutor {
            config: Arc::clone(&config),
            build_target_dir: build_target_dir.clone(),
            injected_glue_lib,
            android_native_glue_object,
            build_target,
            shared_libraries: shared_libraries.clone(),
        });
        // Compile all targets for the requested build target
        cargo::ops::compile_with_exec(workspace, &opts, &executor)?;
    }
    // Remove the set of targets from the reference counted mutex
    let mut shared_libraries = shared_libraries.lock().unwrap();
    let shared_libraries = std::mem::replace(&mut *shared_libraries, MultiMap::new());
    Ok(SharedLibraries { shared_libraries })
}
pub fn build_shared_libraries ( workspace : & Workspace , config : & AndroidConfig , options : & ArgMatches , root_build_dir : & PathBuf , ) -> CargoResult < SharedLibraries > { let injected_glue_src_path = write_injected_glue_src ( & root_build_dir ) ? ; let android_native_glue_src_path = write_native_app_glue_src ( & root_build_dir ) ? ; let shared_libraries : Arc < Mutex < MultiMap < Target , SharedLibrary > > > = Arc :: new ( Mutex :: new ( MultiMap :: new ( ) ) ) ; for build_target in config . build_targets . iter ( ) { let build_target = * build_target ; // Directory that will contain files specific to this build target let build_target_dir = root_build_dir . join ( build_target . android_abi ( ) ) ; fs :: create_dir_all ( & build_target_dir ) . unwrap ( ) ; // Set environment variables needed for use with the cc crate std :: env :: set_var ( format ! ( " " build_target rust_triple ( ) ) , util :: find_clang ( config , build_target ) ? ) ; std :: env :: set_var ( format ! ( " " build_target rust_triple ( ) ) , util :: find_clang_cpp ( config , build_target ) ? ) ; std :: env :: set_var ( format ! ( " " build_target rust_triple ( ) ) , util :: find_ar ( config , build_target ) ? ) ; // Use libc++. It is current default C++ runtime std :: env :: set_var ( format ! ( " " build_target rust_triple ( ) ) , " " ) ; // Generate cmake toolchain and set environment variables to allow projects which use the cmake crate to build correctly let cmake_toolchain_path = write_cmake_toolchain ( config , & build_target_dir , build_target ) ? ; std :: env :: set_var ( " " , cmake_toolchain_path ) ; std :: env :: set_var ( " " , r#"Unix Makefiles"# ) ; std :: env :: set_var ( " " , util :: make_path ( config ) ) ; // Build android_native_glue and injected-glue let injected_glue_lib = build_injected_glue ( workspace , config , & injected_glue_src_path , & build_target_dir , build_target , ) ? ; let android_native_glue_object = build_android_native_glue ( config , & android_native_glue_src_path , & build_target_dir , build_target , ) ? ; // Configure compilation options so that we will build the desired build_target let mut opts = options . compile_options ( workspace . config ( ) , CompileMode :: Build , Some ( & workspace ) ) ? ; opts . build_config . requested_target = Some ( build_target . rust_triple ( ) . to_owned ( ) ) ; // Create executor let config = Arc :: new ( config . clone ( ) ) ; let executor : Arc < dyn Executor > = Arc :: new ( SharedLibraryExecutor { config : Arc :: clone ( & config ) , build_target_dir : build_target_dir . clone ( ) , injected_glue_lib , android_native_glue_object , build_target , shared_libraries : shared_libraries . clone ( ) , } ) ; // Compile all targets for the requested build target cargo :: ops :: compile_with_exec ( workspace , & opts , & executor ) ? ; } // Remove the set of targets from the reference counted mutex let mut shared_libraries = shared_libraries . lock ( ) . unwrap ( ) ; let shared_libraries = std :: mem :: replace ( & mut * shared_libraries , MultiMap :: new ( ) ) ; Ok ( SharedLibraries { shared_libraries } ) }
For each build target and cargo binary or example target, produce a shared library
For each build target and cargo binary or example target produce a shared library
workspace
&Workspace
config
&AndroidConfig
options
&ArgMatches
root_build_dir
&PathBuf