GithubHelp home page GithubHelp logo

alejandrogallo / rooki Goto Github PK

View Code? Open in Web Editor NEW
27.0 3.0 0.0 206 KB

A stupid simple script runner supporting c, c++, rust, haskell and virtually anything

License: GNU General Public License v3.0

Makefile 12.99% Shell 87.01%
cpp scripting c rust fortran tcc clang gcc compiler

rooki's Introduction

rooki

A stupid simple script runner supporting c, c++, rust, haskell and virtually anything

Rooki is written in 20 lines of bash, and has a very flexible functionality.

How does it work?

You just write comments as rooki instructions, the only instruction that you have to define is the rooki:spell, which will be run in the shell. Otherwise you can define any flag you want with the name you want for instance in a c file, the following

// rooki:someflag -I$(pwd)
// rooki:someflag -I$HOME

will define a shell variable someflag with the value

someflag="-I$(pwd) -I$HOME"

which later can be used in the rooki:spell section as

// rooki:someflag -I$(pwd)
// rooki:someflag -I$HOME
// rooki:spell cc $someflag $f -o $bin

There are some general variables already defined:

Variable Explanation Example
bin Path to the created binary rooki:spell gcc $f -o $bin
f Path to the temporary source file that will be compiled // rooki:spell gcc $f -o $bin
src Path to the source file, the caller rooki:include -I$(dirname $src)/include
config_folder Path to rooki config folder

What rooki does when you do rooki yourscript is the following

  • Create a temporal file and save the path in the variable f.
  • Create a bin path out of the md5 hash of the source script, the bin will be stored in $XDG_CONFIG_HOME/rooki/. In the case that your XDG_CONFIG_HOME is not defined, it will be stored in ~/.config/rooki/.
  • Remove the shbang (#!/usr/bin/env rooki) on top of your script (if there is any) and copy the script to $f without the shbang.
  • Read the rooki: flags stored in text in your script.
  • Expand shell constructs within these flags, environment variables and general shell commands within.
  • Run the rooki:spell construct, which should be creating a binary in the path $bin.

Quick start

For instance to write a c++ script called hello.cxx just create an executable file hello.cxx and write

#!/usr/bin/env rooki
// rooki:flags -pedantic -std=c++11
// rooki:flags -x c++
// rooki:include -I/usr/include
// rooki:include -I$HOME/.local/include
// rooki:spell g++ $flags $include $f -o $bin

#include <iostream>

int main(int argc, char *argv[])
{
  std::cout << "Hello world" << std::endl;
  return 0;
}

then do

./test.cxx
# or
rooki test.cxx

if you want to see exactly what rooki is doing then set the environment variable ROOKI_DEBUG like this

ROOKI_DEBUG=1 ./test.cxx

rooki's People

Contributors

alejandrogallo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.