Mercurial > repo
comparison share/candide @ 8781:345fd6459206
<fizzie> ` ( cd share; bash ./configure )
author | HackBot |
---|---|
date | Sun, 10 Jul 2016 08:58:42 +0000 |
parents | |
children | b1e4c3fdb2e8 |
comparison
equal
deleted
inserted
replaced
8780:2eddfbfc5c40 | 8781:345fd6459206 |
---|---|
1 #!/bin/bash | |
2 # compile c from stdin | |
3 # candide, kinda | |
4 | |
5 readinput () { | |
6 while read -r -e || { printf %s "$REPLY"; false; } ; do | |
7 printf '%s\n' "$REPLY" | |
8 done | |
9 } | |
10 | |
11 c=$(readinput) | |
12 if ! [[ $c ]] || ! out=$(mktemp); then | |
13 echo Error >&2 | |
14 exit 1 | |
15 fi | |
16 | |
17 # if you don't write 'main' it assumes that you're writing a full program (with free includes) | |
18 # this allows you to use other functions and stuff | |
19 # it will get false positives, but who cares? | |
20 if [[ $c != *main* ]]; then c=$(cat <<SOURCE | |
21 int main(int argc, char *argv[]) { | |
22 $c | |
23 return 0; | |
24 } | |
25 SOURCE | |
26 ); fi | |
27 | |
28 # will replace -O0 with the parameters | |
29 gcc -o "$out" -x c -I /hackenv/share "${@--O0}" /dev/fd/0 <<SOURCE && { "$out" && { rm -f "$out"; true; }; } | |
30 #include "headers" /* precompiled headers */ | |
31 $c | |
32 SOURCE |