pub fn compile_stdlib(srcdir: &Path, outdir: &Path) -> Result<()> {
    let (_, imports, mut sem_pkgs) = infer_stdlib_dir(srcdir)?;
    // Write each file as compiled module
    for (path, pt) in &imports {
        if let Some(code) = sem_pkgs.remove(path) {
            let module = Module {
                polytype: Some(pt.clone()),
                code: Some(code),
            };
            let mut builder = flatbuffers::FlatBufferBuilder::new();
            let offset = build_module(&mut builder, module);
            let buf = finish_serialize(&mut builder, offset);

            // Write module contents to file
            let mut fpath = outdir.join(path);
            fpath.set_extension("fc");
            fs::create_dir_all(fpath.parent().unwrap())?;
            let file = fs::File::create(&fpath)?;
            let mut encoder = Encoder::new(file)?;
            encoder.write_all(buf)?;
            encoder.finish().into_result()?;
        } else {
            bail!("package {} missing code", &path);
        }
    }
    Ok(())
}
/// Compiles the stdlib found at the srcdir into the outdir.
Compiles the stdlib found at the srcdir into the outdir.
Compiles the stdlib found at the srcdir into the outdir .
pub fn compile_stdlib(srcdir: &Path, outdir: &Path) -> Result<()> {
    let (_, imports, mut sem_pkgs) = infer_stdlib_dir(srcdir)?;
    // Write each file as compiled module
    for (path, pt) in &imports {
        if let Some(code) = sem_pkgs.remove(path) {
            let module = Module {
                polytype: Some(pt.clone()),
                code: Some(code),
            };
            let mut builder = flatbuffers::FlatBufferBuilder::new();
            let offset = build_module(&mut builder, module);
            let buf = finish_serialize(&mut builder, offset);
            // Write module contents to file
            let mut fpath = outdir.join(path);
            fpath.set_extension("fc");
            fs::create_dir_all(fpath.parent().unwrap())?;
            let file = fs::File::create(&fpath)?;
            let mut encoder = Encoder::new(file)?;
            encoder.write_all(buf)?;
            encoder.finish().into_result()?;
        } else {
            bail!("package {} missing code", &path);
        }
    }
    Ok(())
}
pub fn compile_stdlib ( srcdir : & Path , outdir : & Path ) -> Result < ( ) > { let ( _ , imports , mut sem_pkgs ) = infer_stdlib_dir ( srcdir ) ? ; // Write each file as compiled module for ( path , pt ) in & imports { if let Some ( code ) = sem_pkgs . remove ( path ) { let module = Module { polytype : Some ( pt . clone ( ) ) , code : Some ( code ) , } ; let mut builder = flatbuffers :: FlatBufferBuilder :: new ( ) ; let offset = build_module ( & mut builder , module ) ; let buf = finish_serialize ( & mut builder , offset ) ; // Write module contents to file let mut fpath = outdir . join ( path ) ; fpath . set_extension ( " " ) ; fs :: create_dir_all ( fpath . parent ( ) . unwrap ( ) ) ? ; let file = fs :: File :: create ( & fpath ) ? ; let mut encoder = Encoder :: new ( file ) ? ; encoder . write_all ( buf ) ? ; encoder . finish ( ) . into_result ( ) ? ; } else { bail ! ( " " path ) ; } } Ok ( ( ) ) }
Compiles the stdlib found at the srcdir into the outdir.
Compiles the stdlib found at the srcdir into the outdir .
srcdir
&Path
outdir
&Path
srcdir
&Path
outdir
&Path