0a24589bbdf0 — Leonard Ritter 2 years ago
* added tcc module and test
4 files changed, 78 insertions(+), 0 deletions(-)

M .hgignore
A => lib/tukan/tcc.sc
M recipes/tinycc.eo
A => testing/test_tcc.sc
M .hgignore +1 -0
@@ 40,6 40,7 @@ syntax: regexp
 ^llvm
 ^.vscode/
 ^.eo/
+^include/libtcc/
 ^include/SDL2/
 ^include/bullet/
 ^include/chipmunk/

          
A => lib/tukan/tcc.sc +25 -0
@@ 0,0 1,25 @@ 
+import .core
+using import .globals
+
+if (operating-system == 'windows)
+    #load-library "SDL2.dll" # todo
+else
+    shared-library "libtcc.so"
+
+run-stage;
+
+vvv bind TCC
+include "libtcc/libtcc.h"
+
+do
+    using TCC.define
+    using TCC.const
+    using TCC.typedef
+    using TCC.extern
+
+    TCC_RELOCATE_AUTO := (1:u64 as (mutable voidstar))
+
+    TCC_INCLUDE_PATH := module-dir .. "/../../include/libtcc/include"
+    TCC_LIB_PATH := module-dir .. "/../../lib"
+
+    locals;

          
M recipes/tinycc.eo +3 -0
@@ 21,6 21,9 @@ package tinycc
     version version
 
     alias "/lib/libtcc.so" "{build-path}/libtcc.so"
+    in "/lib" "{build-path}/libtcc1.a"
     in "/include/libtcc"
         "{build-path}/libtcc.h"
         "{build-path}/include"
+    in "/include/libtcc/include"
+        "{build-path}/tcclib.h"

          
A => testing/test_tcc.sc +49 -0
@@ 0,0 1,49 @@ 
+
+
+using import tukan.tcc
+
+inline tcc_verify (f ...)
+    let res = (f ...)
+    assert (res == 0)
+    res
+
+vvv bind testcode
+""""#include <tcclib.h>
+
+    void main() {
+        printf("Hello, World!\n");
+    }
+
+cc := (tcc_new)
+defer tcc_delete cc
+tcc_set_lib_path cc TCC_LIB_PATH
+va-map
+    inline (path)
+        tcc_add_include_path cc path
+    TCC_INCLUDE_PATH
+    #"/usr/local/include/x86_64-linux-gnu"
+    #"/usr/local/include"
+    #"/usr/include/x86_64-linux-gnu"
+    #"/usr/include"
+va-map
+    inline (path)
+        tcc_add_library_path cc path
+    #"/usr/lib/x86_64-linux-gnu"
+    #"/usr/lib"
+    #"/lib/x86_64-linux-gnu"
+    #"/lib"
+    #"/usr/local/lib/x86_64-linux-gnu"
+    #"/usr/local/lib"
+
+tcc_set_output_type cc TCC_OUTPUT_MEMORY
+tcc_verify tcc_compile_string cc testcode
+#tcc_run cc 0 null
+tcc_verify tcc_relocate cc TCC_RELOCATE_AUTO
+
+func := (tcc_get_symbol cc "main")
+assert (func != null)
+call
+    func as (@ (function void))
+
+
+;
  No newline at end of file