Renamed from cppscript to compilescript.
This commit is contained in:
parent
1b46b56624
commit
93e079cc89
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required (VERSION 3.2)
|
cmake_minimum_required (VERSION 3.2)
|
||||||
project(cppscript
|
project(compilescript
|
||||||
VERSION 0.1.0
|
VERSION 0.1.0
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
21
README.md
21
README.md
|
@ -1,20 +1,21 @@
|
||||||
**cppscript** allows you to execute C++ files as scripts.
|
**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}/cppscript/`
|
It compiles the source file, stores the binary in
|
||||||
and executes it.
|
`${XDG_CACHE_HOME}/compilescript/` and executes it.
|
||||||
|
|
||||||
It does compile the file every time at the moment.
|
It does compile the file every time at the moment.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use `#!/usr/bin/env cppscript` as shebang and write the compiler arguments in
|
Use `#!/usr/bin/env compilescript` as shebang and write the compiler arguments
|
||||||
the line below with the prefix: `//cppscript:`
|
in the line below with the prefix: `//compilescript:`
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
```C++
|
```C++
|
||||||
#!/usr/bin/env cppscript
|
#!/usr/bin/env compilescript
|
||||||
//cppscript: -Wall -pedantic -Wextra
|
//compilescript: -Wall -pedantic -Wextra
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -29,13 +30,13 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
The configuration file is in `${XDG_CONFIG_HOME}/cppscript.cfg`.
|
The configuration file is in `${XDG_CONFIG_HOME}/compilescript.cfg`.
|
||||||
|
|
||||||
### Example config
|
### Example config
|
||||||
|
|
||||||
```CFG
|
```CFG
|
||||||
compiler = "g++";
|
compiler = "g++";
|
||||||
cache_dir = "/home/user/.cache/cppscript";
|
cache_dir = "/home/user/.cache/compilescript";
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
@ -53,7 +54,7 @@ cache_dir = "/home/user/.cache/cppscript";
|
||||||
#### Get sourcecode
|
#### Get sourcecode
|
||||||
|
|
||||||
Download the current
|
Download the current
|
||||||
[release](https://schlomp.space/tastytea/cppscript/releases) and copy
|
[release](https://schlomp.space/tastytea/compilescript/releases) and copy
|
||||||
[xdgcfg](https://schlomp.space/tastytea/xdgcfg) into `xdgcfg/`.
|
[xdgcfg](https://schlomp.space/tastytea/xdgcfg) into `xdgcfg/`.
|
||||||
|
|
||||||
If you clone from git, be sure to `git submodule init` and
|
If you clone from git, be sure to `git submodule init` and
|
||||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -1,4 +1,4 @@
|
||||||
/* This file is part of cppscript.
|
/* This file is part of compilescript.
|
||||||
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -44,7 +44,7 @@ fs::path cache_dir;
|
||||||
void read_settings()
|
void read_settings()
|
||||||
{
|
{
|
||||||
bool need_save = false;
|
bool need_save = false;
|
||||||
xdgcfg config("cppscript.cfg");
|
xdgcfg config("compilescript.cfg");
|
||||||
if (config.read() != 0)
|
if (config.read() != 0)
|
||||||
{
|
{
|
||||||
config.write();
|
config.write();
|
||||||
|
@ -70,7 +70,7 @@ void read_settings()
|
||||||
xdgHandle xdg;
|
xdgHandle xdg;
|
||||||
xdgInitHandle(&xdg);
|
xdgInitHandle(&xdg);
|
||||||
cache_dir = xdgCacheHome(&xdg);
|
cache_dir = xdgCacheHome(&xdg);
|
||||||
cache_dir /= "cppscript";
|
cache_dir /= "compilescript";
|
||||||
xdgWipeHandle(&xdg);
|
xdgWipeHandle(&xdg);
|
||||||
}
|
}
|
||||||
if (!fs::is_directory(cache_dir))
|
if (!fs::is_directory(cache_dir))
|
||||||
|
@ -104,9 +104,9 @@ int main(int argc, char *argv[])
|
||||||
string buf;
|
string buf;
|
||||||
std::getline(in, buf);
|
std::getline(in, buf);
|
||||||
std::getline(in, buf);
|
std::getline(in, buf);
|
||||||
if (buf.substr(0, 12).compare("//cppscript:") == 0)
|
if (buf.substr(0, 16).compare("//compilescript:") == 0)
|
||||||
{
|
{
|
||||||
compiler_arguments = buf.substr(12);
|
compiler_arguments = buf.substr(16);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Reference in New Issue