This repository has been archived on 2019-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
compilescript/compilescript.1.adoc
tastytea 9eb18e0c95
All checks were successful
the build was successful
Change default compiler from g++ to g++ -x c++
g++ guesses the language from file extensions. -x c++ forces the
language to C++, so you don't need file extensions on your scripts.
2019-02-09 00:20:05 +01:00

1.8 KiB

compilescript(1)

NAME

compilescript - allows you to execute files from compiled languages as scripts.

SYNOPSIS

compilescript [file|--cleanup] [arguments]

DESCRIPTION

compilescript allows you to execute files from compiled languages as scripts. By default it uses g++.

It compiles the source file, stores the binary in ${XDG_CACHE_HOME}/compilescript/ and executes it. If the binary in cache is newer than the source file, the compilation is skipped.

Use #!/usr/bin/env compilescript as shebang and write the compiler arguments in the second line with the prefix: //compilescript:.

The configuration file is in ${XDG_CONFIG_HOME}/compilescript.cfg. It will be generated on first run.

OPTIONS

--cleanup

Delete old cache files (older than clean_after_hours).

EXAMPLES

Example script

#!/usr/bin/env compilescript
//compilescript: -Wall -pedantic -Wextra

#include <iostream>

using std::cout;

int main(int argc, char *argv[])
{
    cout << "Hello world!\n";
    cout << argv[1] << '\n';
}

Example config

compiler = "g++ -x c++";
clean_after_hours = 720;
cache_dir = "/home/user/.cache/compilescript";

FILES

Configuration file:

${XDG_CONFIG_HOME}/compilescript.cfg

Cache:

${XDG_CACHE_HOME}/compilescript/

${XDG_CONFIG_HOME} is usually ~/.config and ${XDG_CACHE_HOME} is usually ~/.cache