fn staticlib(target: &Triple) {
        // minirake dynamically generates some c source files so we can't build
        // directly with the `cc` crate. We must first hijack the mruby build
        // system to do the codegen for us.
        generate_mrbgem_config();
        let status = Command::new("ruby")
            .arg(mruby_minirake())
            .arg("--verbose")
            .env("MRUBY_BUILD_DIR", mruby_build_dir())
            .env("MRUBY_CONFIG", mruby_build_config())
            .current_dir(mruby_source_dir())
            .status()
            .unwrap();
        if !status.success() {
            panic!("minirake failed");
        }

        let mut sources = HashMap::new();
        sources.insert(
            buildpath::source::mruby_sys_ext_source_file(),
            buildpath::source::mruby_sys_ext_source_file(),
        );
        let mut mruby_sources = vec![];
        crate::enumerate_sources(mruby_source_dir(), &mut mruby_sources).unwrap();
        for source in mruby_sources {
            let relative_source = source.strip_prefix(mruby_source_dir()).unwrap();
            let is_core_source = source.strip_prefix(mruby_source_dir().join("src")).is_ok();
            let is_required_gem_source = gems().iter().any(|gem| {
                source
                    .components()
                    .any(|component| component.as_os_str() == OsStr::new(gem))
            });
            if is_core_source || is_required_gem_source {
                let is_build_source = relative_source
                    .components()
                    .any(|component| component.as_os_str() == OsStr::new("build"));
                let is_test_source = relative_source
                    .components()
                    .any(|component| component.as_os_str() == OsStr::new("test"));
                if is_build_source || is_test_source {
                    continue;
                }
                if source.extension().and_then(OsStr::to_str) == Some("c") {
                    sources.insert(relative_source.to_owned(), source.to_owned());
                }
            }
        }

        let mut mruby_codegen_sources = vec![];
        crate::enumerate_sources(mruby_generated_source_dir(), &mut mruby_codegen_sources).unwrap();
        for source in mruby_codegen_sources {
            let relative_source = source.strip_prefix(mruby_generated_source_dir()).unwrap();
            let is_test_source = relative_source
                .components()
                .any(|component| component.as_os_str() == OsStr::new("test"));
            if is_test_source {
                continue;
            }
            if source.extension().and_then(OsStr::to_str) == Some("c") {
                sources.insert(relative_source.to_owned(), source.to_owned());
            }
        }
        // Build the extension library
        let mut build = cc::Build::new();
        build
            .warnings(false)
            .files(sources.values())
            .include(mruby_include_dir())
            .include(buildpath::source::mruby_sys_ext_include_dir())
            .define("MRB_NO_BOXING", None)
            .define("MRB_NO_PRESYM", None)
            .define("MRB_NO_STDIO", None)
            .define("MRB_ARY_NO_EMBED", None)
            .define("MRB_INT64", None)
            .define("MRB_UTF8_STRING", None)
            .define("DISABLE_GEMS", None)
            .define("ARTICHOKE", None);

        for gem in gems() {
            let dir = if gem == "mruby-compiler" { "core" } else { "include" };
            let gem_include_dir = mruby_source_dir().join("mrbgems").join(gem).join(dir);
            build.include(gem_include_dir);
        }

        if let Architecture::Wasm32 = target.architecture {
            build.include(wasm_include_dir());
            if let OperatingSystem::Emscripten = target.operating_system {
                build.define("MRB_API", Some(r#"__attribute__((used))"#));
            } else if let OperatingSystem::Unknown = target.operating_system {
                build.define("MRB_API", Some(r#"__attribute__((visibility("default")))"#));
                build.define("MRB_NO_DIRECT_THREADING", None);
            }
        }

        build.compile("libartichokemruby.a");
    }
/// Build the mruby static library with its built in minirake build system.
Build the mruby static library with its built in minirake build system.
Build the mruby static library with its built in minirake build system .
fn staticlib(target: &Triple) {
        // minirake dynamically generates some c source files so we can't build
        // directly with the `cc` crate. We must first hijack the mruby build
        // system to do the codegen for us.
        generate_mrbgem_config();
        let status = Command::new("ruby")
            .arg(mruby_minirake())
            .arg("--verbose")
            .env("MRUBY_BUILD_DIR", mruby_build_dir())
            .env("MRUBY_CONFIG", mruby_build_config())
            .current_dir(mruby_source_dir())
            .status()
            .unwrap();
        if !status.success() {
            panic!("minirake failed");
        }
        let mut sources = HashMap::new();
        sources.insert(
            buildpath::source::mruby_sys_ext_source_file(),
            buildpath::source::mruby_sys_ext_source_file(),
        );
        let mut mruby_sources = vec![];
        crate::enumerate_sources(mruby_source_dir(), &mut mruby_sources).unwrap();
        for source in mruby_sources {
            let relative_source = source.strip_prefix(mruby_source_dir()).unwrap();
            let is_core_source = source.strip_prefix(mruby_source_dir().join("src")).is_ok();
            let is_required_gem_source = gems().iter().any(|gem| {
                source
                    .components()
                    .any(|component| component.as_os_str() == OsStr::new(gem))
            });
            if is_core_source || is_required_gem_source {
                let is_build_source = relative_source
                    .components()
                    .any(|component| component.as_os_str() == OsStr::new("build"));
                let is_test_source = relative_source
                    .components()
                    .any(|component| component.as_os_str() == OsStr::new("test"));
                if is_build_source || is_test_source {
                    continue;
                }
                if source.extension().and_then(OsStr::to_str) == Some("c") {
                    sources.insert(relative_source.to_owned(), source.to_owned());
                }
            }
        }
        let mut mruby_codegen_sources = vec![];
        crate::enumerate_sources(mruby_generated_source_dir(), &mut mruby_codegen_sources).unwrap();
        for source in mruby_codegen_sources {
            let relative_source = source.strip_prefix(mruby_generated_source_dir()).unwrap();
            let is_test_source = relative_source
                .components()
                .any(|component| component.as_os_str() == OsStr::new("test"));
            if is_test_source {
                continue;
            }
            if source.extension().and_then(OsStr::to_str) == Some("c") {
                sources.insert(relative_source.to_owned(), source.to_owned());
            }
        }
        // Build the extension library
        let mut build = cc::Build::new();
        build
            .warnings(false)
            .files(sources.values())
            .include(mruby_include_dir())
            .include(buildpath::source::mruby_sys_ext_include_dir())
            .define("MRB_NO_BOXING", None)
            .define("MRB_NO_PRESYM", None)
            .define("MRB_NO_STDIO", None)
            .define("MRB_ARY_NO_EMBED", None)
            .define("MRB_INT64", None)
            .define("MRB_UTF8_STRING", None)
            .define("DISABLE_GEMS", None)
            .define("ARTICHOKE", None);
        for gem in gems() {
            let dir = if gem == "mruby-compiler" { "core" } else { "include" };
            let gem_include_dir = mruby_source_dir().join("mrbgems").join(gem).join(dir);
            build.include(gem_include_dir);
        }
        if let Architecture::Wasm32 = target.architecture {
            build.include(wasm_include_dir());
            if let OperatingSystem::Emscripten = target.operating_system {
                build.define("MRB_API", Some(r#"__attribute__((used))"#));
            } else if let OperatingSystem::Unknown = target.operating_system {
                build.define("MRB_API", Some(r#"__attribute__((visibility("default")))"#));
                build.define("MRB_NO_DIRECT_THREADING", None);
            }
        }
        build.compile("libartichokemruby.a");
    }
fn staticlib ( target : & Triple ) { // minirake dynamically generates some c source files so we can't build // directly with the `cc` crate. We must first hijack the mruby build // system to do the codegen for us. generate_mrbgem_config ( ) ; let status = Command :: new ( " " ) . arg ( mruby_minirake ( ) ) . arg ( " " ) . env ( " " , mruby_build_dir ( ) ) . env ( " " , mruby_build_config ( ) ) . current_dir ( mruby_source_dir ( ) ) . status ( ) . unwrap ( ) ; if ! status . success ( ) { panic ! ( " " ) ; } let mut sources = HashMap :: new ( ) ; sources . insert ( buildpath :: source :: mruby_sys_ext_source_file ( ) , buildpath :: source :: mruby_sys_ext_source_file ( ) , ) ; let mut mruby_sources = vec ! [ ] ; crate :: enumerate_sources ( mruby_source_dir ( ) , & mut mruby_sources ) . unwrap ( ) ; for source in mruby_sources { let relative_source = source . strip_prefix ( mruby_source_dir ( ) ) . unwrap ( ) ; let is_core_source = source . strip_prefix ( mruby_source_dir ( ) . join ( " " ) ) . is_ok ( ) ; let is_required_gem_source = gems ( ) . iter ( ) . any ( | gem | { source . components ( ) . any ( | component | component . as_os_str ( ) == OsStr :: new ( gem ) ) } ) ; if is_core_source || is_required_gem_source { let is_build_source = relative_source . components ( ) . any ( | component | component . as_os_str ( ) == OsStr :: new ( " " ) ) ; let is_test_source = relative_source . components ( ) . any ( | component | component . as_os_str ( ) == OsStr :: new ( " " ) ) ; if is_build_source || is_test_source { continue ; } if source . extension ( ) . and_then ( OsStr :: to_str ) == Some ( " " ) { sources . insert ( relative_source . to_owned ( ) , source . to_owned ( ) ) ; } } } let mut mruby_codegen_sources = vec ! [ ] ; crate :: enumerate_sources ( mruby_generated_source_dir ( ) , & mut mruby_codegen_sources ) . unwrap ( ) ; for source in mruby_codegen_sources { let relative_source = source . strip_prefix ( mruby_generated_source_dir ( ) ) . unwrap ( ) ; let is_test_source = relative_source . components ( ) . any ( | component | component . as_os_str ( ) == OsStr :: new ( " " ) ) ; if is_test_source { continue ; } if source . extension ( ) . and_then ( OsStr :: to_str ) == Some ( " " ) { sources . insert ( relative_source . to_owned ( ) , source . to_owned ( ) ) ; } } // Build the extension library let mut build = cc :: Build :: new ( ) ; build . warnings ( false ) . files ( sources . values ( ) ) . include ( mruby_include_dir ( ) ) . include ( buildpath :: source :: mruby_sys_ext_include_dir ( ) ) . define ( " " , None ) . define ( " " , None ) . define ( " " , None ) . define ( " " , None ) . define ( " " , None ) . define ( " " , None ) . define ( " " , None ) . define ( " " , None ) ; for gem in gems ( ) { let dir = if gem == " " { " " } else { " " } ; let gem_include_dir = mruby_source_dir ( ) . join ( " " ) . join ( gem ) . join ( dir ) ; build . include ( gem_include_dir ) ; } if let Architecture :: Wasm32 = target . architecture { build . include ( wasm_include_dir ( ) ) ; if let OperatingSystem :: Emscripten = target . operating_system { build . define ( " " , Some ( r#"__attribute__((used))"# ) ) ; } else if let OperatingSystem :: Unknown = target . operating_system { build . define ( " " , Some ( r#"__attribute__((visibility("default")))"# ) ) ; build . define ( " " , None ) ; } } build . compile ( " " ) ; }
Build the mruby static library with its built in minirake build system.
Build the mruby static library with its built in minirake build system .
target
&Triple