rev: 30583020c3478909510618df68fc8cd735053b86 scopes/testing/makemain.sc -rw-r--r-- 1.0 KiB View raw Log this file
30583020c347 — Leonard Ritter * fixed `testing/makemain.sc` 13 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using import testing

# generate a new main executable

bin-dir := compiler-dir .. "/bin"
include-dir := compiler-dir .. "/include"

let lib =
    include
        options "-I" include-dir
        """"#include "scopes/scopes.h"

            int system(const char *command);

using lib.extern

#-----------------

fn get-executable-ptr ()
    bitcast (static-typify this-function) voidstar

fn main (argc argv)
    sc_init (get-executable-ptr) argc argv
    return (sc_main)

#-----------------

objfile := bin-dir .. "/newscopes.o"
compile-object
    default-target-triple
    compiler-file-kind-object
    objfile
    do
        let main =
            static-typify main i32 (mutable (@ (mutable (@ i8))))
        locals;

# build new binary
binfile := bin-dir .. "/newscopes"
let cmd =
    .. "gcc"
        \ " " objfile
        \ " -o " binfile
        \ " -Wl,-rpath=\\$ORIGIN"
        " -lscopesrt"
        \ " -L " bin-dir
print cmd
test ((system cmd) == 0)

# and execute it
print "launching" binfile
test ((system binfile) == 0)