Code Monkey home page Code Monkey logo

libtool-rs's Introduction

libtool-rs

build script helper to automatically generate libtool convenience library (.la) files.

libtool-rs's People

Contributors

kanru avatar

Stargazers

Sora Suegami avatar Leonid Ryzhyk avatar

Watchers

 avatar James Cloos avatar Leonid Ryzhyk avatar

libtool-rs's Issues

PathBuf::exists() follows symlinks

Thanks for this very useful library!

I believe that this fragment does not work as expected:

if new_lib_path.exists() {

The exists() method follows symlinks and so instead of checking that new_lib_path exists it checks that the file it points to exists. This breaks my builds if the previous build was interrupted.

I think the fix is simply to drop the exists() check, since remove_file() will succeed if the file does not exist. FWIW, this code works for me:

pub fn generate_convenience_lib(lib: &str) -> std::io::Result<()> {
    let self_version = env!("CARGO_PKG_VERSION");
    let topdir = env::var("CARGO_MANIFEST_DIR").unwrap();
    let profile = env::var("PROFILE").unwrap();
    let target_dir = format!("{}/target/{}", topdir, profile);
    let libs_dir = format!("{}/.libs", target_dir);
    let libs_path = PathBuf::from(&libs_dir);
    let la_path = PathBuf::from(format!("{}/{}.la", target_dir, lib));
    let old_lib_path = PathBuf::from(format!("{}/{}.a", target_dir, lib));
    let new_lib_path = PathBuf::from(format!("{}/{}.a", libs_dir, lib));
    fs::create_dir_all(&libs_path).unwrap();

    fs::remove_file(&la_path)?;
    fs::remove_file(&new_lib_path)?;

    let mut file = File::create(&la_path)?;
    writeln!(file, "# {}.la - a libtool library file", lib)?;
    writeln!(file, "# Generated by libtool-rust {}", self_version)?;
    writeln!(file, "dlname=''")?;
    writeln!(file, "library_names=''")?;
    writeln!(file, "old_library='{}.a'", lib)?;
    writeln!(file, "inherited_linker_flags=' -pthread -lm -ldl'")?;
    writeln!(file, "installed=no")?;
    writeln!(file, "shouldnotlink=no")?;
    symlink(&old_lib_path, &new_lib_path)?;
    Ok(())
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.