Coder Social home page Coder Social logo

refi64 / rcmake Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 15 KB

rcmake is a wrapper over CMake designed to avoid having to constantly repeat the same command-line arguments

License: Mozilla Public License 2.0

Shell 14.18% Crystal 85.82%
cmake cmake-resources crystal wrapper command-line command-line-tool

rcmake's Introduction

rcmake

rcmake is a wrapper over CMake designed to avoid having to constantly repeat the same command-line arguments.

If you feel like you're constantly doing stuff like this:

mkdir build_dir
cd build_dir
cmake -G Ninja .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -D...

then rcmake is for you! Imagine all that being simplified to just:

rcmake build_dir

Intrigued? Then read on!

Installation

You need Crystal (installation instructions for that are here). (You need shards too, but it's included by default in the Crystal binary distributions.)

Once you have that, the easy way to get rcmake is:

$ curl -L https://goo.gl/FQKLvw | sh

If you don't like running random internet scripts, then do it manually:

$ git clone https://github.com/kirbyfan64/rcmake.git
$ cd rcmake
$ shards build
$ ./install.sh /usr/local/bin

How-to

rcmake greatly simplifies how you call CMake. In order to do so, it utilizes a config file automatically created when you first run it (it's located at ~/.rcmake.yml).

Here's the most basic way to use rcmake:

rcmake build_dir
cd build_dir
ninja

That's it! By default, rcmake will use Ninja as the generator target and Clang as the compiler. Within rcmake, compilers are referred to as suites, which consist of both the C compiler and the C++ compiler.

If you want to use make instead of Ninja, just run:

rcmake build_dir -g make

-g allows you to pick a different generator. Here, the make generator (which corresponds to CMake's Unix Makefiles generator) is being used instead.

On the other hand, how about using GCC instead of Clang? You can do that pretty easily:

rcmake build_dir -c gcc

The -c options allows you to change the compiler suite rcmake uses. Here, it's being changed to gcc. (ZapCC is also supported.)

If you want a release build instead of debug, you can use:

rcmake build_dir -t release

In addition, you can even change the linker from the default (gold) to LLD or the classic BFD linker:

rcmake build_dir -l bfd
rcmake build_dir -l lld

What if there's an option rcmake doesn't cover? You can just pass it manually using -C for C compiler flags, -X for C++ compiler flags, or -L for linker flags:

rcmake build_dir -C=-std=c99 -X=-std=c++11 -L=-B/usr/bin/ld.gold

You can even pass flags straight to CMake itself:

rcmake build_dir -F=-DWHATEVER=123

The config file

You can customize the default compiler suite and the different suites themselves via the config file, ~/.rcmake.yml. By default, it looks like this:

# This is the default rcmake config file.

defaults:
  suite: clang
  generator: ninja
  linker: gold

  # Default C/C++/linker/CMake flags would go here:
  # cflags:
    # - "-std=c99"
  # cxxflags:
  #   - "-std=c++11"
  # lflags:
  #   - "-rpath ."
  # cmakeflags:
  #   - "-DFOO=BAR"

suites:
  clang:
    c: clang
    cxx: clang++
    flavor: clang
  gcc:
    c: gcc
    cxx: g++
    flavor: gcc
  zapcc:
    c: zapcc
    cxx: zapcc++
    flavor: clang

If you want to change the default suite, just change the defaults section like this:

defaults:
  suite: gcc
  # ...

The same goes changing the default generator and linker: just change their value inside the defaults section.

You can add custom suites, too. For instance, if you find yourself often cross-compiling for Windows, you could add a suite like this:

suites:
  mingw:
    c: i686-w64-mingw32-gcc
    cxx: i686-w64-mingw32-g++
    flavor: gcc
  # ...

Command-line usage

Usage:
  /usr/local/bin/rcmake [flags...] <dir> [arg...]

rcmake is a wrapper over CMake designed to avoid having to constantly repeat
the same command-line arguments.

Flags:
  --cflag, -C (default: [])                           # Pass the given flag to the C compiler
  --cmake, -x (default: cmake)                        # The cmake executable to use
  --cmakeflag, -F (default: [])                       # Pass the given flag to CMake
  --config, -f (default: ~/.rcmake.yml)               # The config file to use
  --cxxflag, -X (default: [])                         # Pass the given flag to the C++ compiler
  --gen, -g (default: Ninja)                          # The generator to use (choices: make, ninja)
  --help, -h (default: false)                         # Displays help for the current command.
  --lflag, -L (default: [])                           # Pass the given flag to the linker
  --linker, -l (default: Gold)                        # The linker to use (choices: bfd, gold, lld)
  --source, -s (default: /home/ryan/rcmake.cr/build)  # The source directory
  --suite, -c                                         # The compiler suite to use
  --type, -t (default: Debug)                         # The build type (choices: debug, release, relwithdebinfo, minsizerel)
  --version (default: false)

Arguments:
  dir (required)                                      # The build directory to run CMake inside of

Contributors

rcmake's People

Contributors

refi64 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rcmake's Issues

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.