Giter Site home page Giter Site logo

Use gcc crate instead of cmake? about ritual HOT 6 OPEN

rust-qt avatar rust-qt commented on July 17, 2024
Use gcc crate instead of cmake?

from ritual.

Comments (6)

Riateche avatar Riateche commented on July 17, 2024

I think it would be nice to remove dependency on cmake, but I don't want to reinvent cmake. It actually solves a lot of issues:

  • It automatically builds a shared or static library from a folder of source files in a cross-platform way;
  • It skips building source files that were not changed (extremely important during development);
  • it allows to have parallel builds with "make -j N";
  • It allows to install all headers and library files in a chosen folder easily.

All this is accomplished with a very simple config file (less than 20 lines). How much code will it take to implement the same behavior using gcc crate? How much of these features can it provide?

from ritual.

emoon avatar emoon commented on July 17, 2024

In the simplest form using the gcc crate is this

// build.rs

extern crate gcc;

fn main() {
    gcc::compile_library("libfoo.a", &["foo.c", "bar.c"]);
}
  • The gcc crate uses rayon to build in parallel also and uses the correct compiler given the version of Rust (if MSVC on Windows it will build the code using MSVC etc)
  • Also for a user of a crate they will very rarely change the code inside the crate they just want to build the crate by adding a dependency in their project.
  • You can pick any folder to have the files for the gcc crate also.
  • Unsure about incremental. Yet this isn't important for a crate user as the will build the crate and don't touch it again.

from ritual.

Riateche avatar Riateche commented on July 17, 2024

But MSVC libraries are *.lib, not *.a. Also it seems that this crate doesn't support shared libraries, only static ones. I need shared libraries for MSVC because it can't compile them statically (too many symbols).

from ritual.

emoon avatar emoon commented on July 17, 2024

The gcc crate uses *.a even for msvc. I have used this in several projects and it works just fine. I have never ran into the issue with too many symbols on msvc so unsure about that.

from ritual.

Riateche avatar Riateche commented on July 17, 2024

Actually, this feature would be useful even if it doesn't cover all use cases. We can leave cmake as default option and fallback to gcc crate if cmake is not available and there are no other issues.

from ritual.

emoon avatar emoon commented on July 17, 2024

Sounds good!

from ritual.

Related Issues (20)

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.