Giter VIP home page Giter VIP logo

sheclang's Introduction

sheclang - A #! for your C++ files.

Installation & Test

To install, just stick the bash script in your path either by a copy or a symlink.

git clone https://github.com/lrenaud/sheclang
cd sheclang
sudo cp -v sheclang /usr/bin/

To run, try the demo after installing.

chmod +x ./hello-world.cpp
./hello-world.cpp

Use

Basic Use

  1. Add the following line to the first line of your C++ file.
#!/usr/bin/env sheclang
  1. Mark your top level *.cpp file as executable
cd ~/your-project
chmod +x your-source-code.cpp
  1. Run the source file like it was an executable. Arguments passed to the *.cpp file will be forwarded onto the resulting binary directly.
./your-source-code.cpp --your-argument positional --this-flag

Advanced Use

  • Use the env -S seperator to pass build arguments directly into sheclang.
    • sheclang looks for the -- as a seperator when invoked in this way to identify the arguments intended for the compiler verses arguments intended for your executable. If you do not want to have to play the game of complexities in the invocation here, consider using an environmental config to override the Magic Variables instead.
    • example: #!/usr/bin/env -S sheclang -lm -- to pass the -lm flag directly to the compiler.
  • Use a ~/.config, ~/.sheclang, or local sheclang.conf to add compiler arguments
    • sheclang will look for files the following order, and simply source the contents of the files prior to doing any file processing, compiling, or executing.
      1. $HOME/.config/sheclang/config
      2. $HOME/.sheclang
      3. $PWD/sheclang.conf
      4. $PWD/.sheclang
    • If you want to override the configuration of a previous script, uses a higher numbered (later loaded) script to set the final configuration prior to the build process. For arugments you can override, look at the Magic Variables List section.

Magic Variables List

The following variables are used internally by sheclang, and can be overriden by a sourced script as defined in the advanced usage.

Variable Default Description
COMPILER clang++ The compiler called by sheclang
SHECLANG_VERBOSE false When true, report information about the execution process for debugging
POST_BUILD_FLAGS empty array an array of flags to pass to $COMPILER at build time.
PRE_BUILD_FLAGS empty array an array of flags to pass to $COMPILER prior to the source code file. These are post-merged with arguments that are pased via an advanced !# call per the Advanced Use section above.
RUNTIME ARGS empty array Arguments passed to your executable. Automatically merged with things you pass when invoking the script. These arguments are placed before arguments passed via the CLI.

Why?

Because I could. And anything that makes building performant software more assessable to more users is worth it. I can't imagine many Python beginners are using the debugging facilities and interactivity of the Python interactive terminal. So why not do what I can to make building C++ as trivial to get off the ground as trivial python. I detest build systems, and I just want my tools to work.

sheclang's People

Contributors

opensiriusfox avatar

Watchers

 avatar James Cloos 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.