aboutsummaryrefslogtreecommitdiffstats
path: root/compiler-explorer/index.js
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2021-05-14 18:14:50 +0000
committerterminaldweller <thabogre@gmail.com>2021-05-14 18:14:50 +0000
commit6e528248414e330c9e25e81596ab47b8b8a5b701 (patch)
treee1aa41a7f3198eeac187e6177ec7d4a33db229d3 /compiler-explorer/index.js
downloadscripts-master.tar.gz
scripts-master.zip
first commitmaster
Diffstat (limited to 'compiler-explorer/index.js')
-rw-r--r--compiler-explorer/index.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/compiler-explorer/index.js b/compiler-explorer/index.js
new file mode 100644
index 0000000..fae05b7
--- /dev/null
+++ b/compiler-explorer/index.js
@@ -0,0 +1,21 @@
+
+const fetch = require('node-fetch')
+const fs = require("fs")
+const util = require("util")
+const readFile = util.promisify(fs.readFile)
+
+async function JSON_POST_req(data,options) {
+ var dummy = {"source": data.toString(), "options":"{}"}
+ return await {method:"POST", body:JSON.stringify(dummy), headers:{"Content-Type":"application/json"}}
+}
+
+function compiler_explorer(data, options) {
+ JSON_POST_req(data, options).then(post_arg=>
+ fetch("https://godbolt.org/api/compiler/g92/compile?options=-O3", post_arg)).then(res=>
+ res.text()).then(body=>
+ console.log(body.split("\n").slice(1,body.split("\n").length).join("\n"))).catch(error=>
+ console.log(error))
+}
+
+const config = JSON.parse(fs.readFileSync("./ceconfig.json"))
+compiler_explorer(process.argv[2], config)