Skip to content

Commit f7bec06

Browse files
author
Dmitry Grigoriev
committed
Now compiled scripts go to ~/.cache/build-n-run.
1 parent c2e4b0e commit f7bec06

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
2. Create C++ source file, prepend it with shebang line `#!/path/to/build-n-run`, make it executable `chmod +x script.cpp` and run: `./script.cpp`.
1010

11-
3. `build-n-run` compiles `script.cpp` to `~/bin/build-n-run.compiled/` **only if source file is newer than compiled binary**, and then runs compiled binary.
11+
3. `build-n-run` compiles `script.cpp` to `~/.cache/build-n-run/` **only if source file is newer than compiled binary**, and then runs compiled binary.
1212

1313
### In detail
1414

@@ -53,9 +53,9 @@ That's all. Now write C++ program with shebang line, **chmod it to be executable
5353
Recompiling...
5454
Hello world!
5555

56-
Let's take a look at `~/bin/build-n-run.compiled` directory:
56+
Let's take a look at `~/.cache/build-n-run` directory:
5757

58-
$ ls ~/bin/build-n-run.compiled
58+
$ ls ~/.cache/build-n-run
5959
home--me--tmp--hello
6060

6161
I downloaded `hello.cpp` to `/home/me/tmp`, and compiled binary's name reflects source's full path, slashes replaced with `"--"`.

build-n-run.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// How to build with gcc-7.3.0:
2-
// # g++ build-n-run.cpp -lstdc++fs -o /usr/local/bin/build-n-run
2+
// # c++ build-n-run.cpp -lstdc++fs -o /usr/local/bin/build-n-run
33

44
#include <stdio.h>
55
#include <stdlib.h>
@@ -65,7 +65,7 @@ int main(int argc, char** argv) {
6565
fputs("ERROR: HOME environment variable is not set", stderr);
6666
exit(1);
6767
}
68-
path target(string(home) + "/bin/" + me.filename().string() + ".compiled/" + replaceAll(canonical(source), "/", "--").substr(2));
68+
path target(string(home) + "/.cache/" + me.filename().string() + "/" + replaceAll(canonical(source), "/", "--").substr(2));
6969
target.replace_extension();
7070

7171
if (!exists(target) || last_write_time(source) > last_write_time(target)) {

0 commit comments

Comments
 (0)