From 3c8c72298985782b29f47232fee91ed787b58090 Mon Sep 17 00:00:00 2001 From: gambas Date: Fri, 25 May 2018 21:03:48 +0200 Subject: [PATCH] New component for compiling JIT code at runtime. [GB.JIT] * NEW: New component for compiling JIT code at runtime. --- comp/src/gb.jit/.component | 6 ++++ comp/src/gb.jit/.directory | 2 ++ comp/src/gb.jit/.icon.png | Bin 0 -> 10656 bytes comp/src/gb.jit/.project | 13 ++++++++ comp/src/gb.jit/.src/Main.module | 7 ++++ comp/src/gb.jit/.src/_Jit.module | 55 +++++++++++++++++++++++++++++++ comp/src/gb.jit/gambas.h | 1 + comp/src/gb.jit/jit.h | 0 8 files changed, 84 insertions(+) create mode 100644 comp/src/gb.jit/.component create mode 100644 comp/src/gb.jit/.directory create mode 100644 comp/src/gb.jit/.icon.png create mode 100644 comp/src/gb.jit/.project create mode 100644 comp/src/gb.jit/.src/Main.module create mode 100644 comp/src/gb.jit/.src/_Jit.module create mode 120000 comp/src/gb.jit/gambas.h create mode 100644 comp/src/gb.jit/jit.h diff --git a/comp/src/gb.jit/.component b/comp/src/gb.jit/.component new file mode 100644 index 000000000..844988ff4 --- /dev/null +++ b/comp/src/gb.jit/.component @@ -0,0 +1,6 @@ +[Component] +Key=gb.jit +Version=3.10.90 +State=2 +Hidden=True +Authors=Benoît Minisini diff --git a/comp/src/gb.jit/.directory b/comp/src/gb.jit/.directory new file mode 100644 index 000000000..06dab1c8a --- /dev/null +++ b/comp/src/gb.jit/.directory @@ -0,0 +1,2 @@ +[Desktop Entry] +Icon=./.icon.png diff --git a/comp/src/gb.jit/.icon.png b/comp/src/gb.jit/.icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4e185c57a4fcbd3c17a2c8164a10a2264e64b18a GIT binary patch literal 10656 zcmb_?byQT**Y+JcC8b+LknUy}kWx}oI;4>vLXd7L0qI7NkOoO*kOoOXKsrVckQA69 zzsv8d_gm}z^IPlAnqkgx&c0`#{p@Ey`^IW(st^;<5dZ){tfupXP}KDP+IIJnoP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gwg3`_BcLSmzj|WwUjRjsAQ?JRo_^Oe;fP0lUGP=~Ol@?P*&O(x?6t!N3|*Z^mUeM7|%O)u00COfSDbjS_9BNSvV_> zw8k(DeTws|iD=Qu$ZrmQCmgSQndznHwdXiUjdH>?aiZXdIA(07`RDI+-I}o{IXUvEOJ~C3gh0Coo>(#R zfO*PGgZOii%`4KvtpOTku1*Q1K=r9{!V1FV;Lqwbzv_rwW_ZD>z|VKI4>UWgbZ(+% zg_POj@k_uUB%76bvWW+i_;Li-OwKWbGG zr||EpL67pRAZVCCE_58x`~jrB{s4Epu?AR1f=b!;rlRMG86dhWVm;PI@+kJ!GW35i4e&Dr{zS6#U4YTi{?Y@7hL_;HwaN-S6*aAzgm3JRq!_5>Qjpd{U!e8TLN_yTvJj literal 0 HcmV?d00001 diff --git a/comp/src/gb.jit/.project b/comp/src/gb.jit/.project new file mode 100644 index 000000000..8b2777064 --- /dev/null +++ b/comp/src/gb.jit/.project @@ -0,0 +1,13 @@ +# Gambas Project File 3.0 +Title=Gambas JIT compiler support +Startup=Main +Version=3.10.90 +VersionFile=1 +Authors="Benoît Minisini" +TabSize=2 +Language=fr +Type=Component +Maintainer=benoit +Address=benoit@localhost +License=General Public Licence +Packager=1 diff --git a/comp/src/gb.jit/.src/Main.module b/comp/src/gb.jit/.src/Main.module new file mode 100644 index 000000000..96188747b --- /dev/null +++ b/comp/src/gb.jit/.src/Main.module @@ -0,0 +1,7 @@ +' Gambas module file + +Public Sub Main() + + + +End diff --git a/comp/src/gb.jit/.src/_Jit.module b/comp/src/gb.jit/.src/_Jit.module new file mode 100644 index 000000000..1390b3c75 --- /dev/null +++ b/comp/src/gb.jit/.src/_Jit.module @@ -0,0 +1,55 @@ +' Gambas module file + +Export + +Private $sCompiler As String + +Private Sub FindCompiler() + + $sCompiler = System.Find("gcc") + +End + +Public Sub Compile() As String + + Dim sFile As String + Dim sDir As String + Dim sName As String + Dim sPath As String + Dim hFile As File + Dim sResult As String + + sName = Component.FindFromPath("..") + sDir = File.Dir(Temp$()) &/ "jit" + Try Mkdir sDir + sPath = sDir &/ sName & ".c" + + hFile = Open sPath For Output Create + + Print #hFile, File.Load("gambas.h"); + Print #hFile, File.Load("jit.h"); + + sDir = "../.jit" + For Each sFile In Dir(sDir, "*.c") + Print #hFile, File.Load(sDir &/ sFile); + Next + + Close #hFile + + FindCompiler + 'gcc -c -fPIC -o foo.o foo.c + Exec [$sCompiler, "-c", "-fPIC", "-o", File.SetExt(sPath, "o"), sPath] To sResult + If Process.LastValue Then + Error("gb.jit: warning: unable to compile JIT code: " & sResult) + Return + Endif + 'gcc -shared -o libfoo.so foo.o + Exec [$sCompiler, "-shared", "-o", File.SetExt(sPath, "so"), File.SetExt(sPath, "o")] To sResult + If Process.LastValue Then + Error("gb.jit: warning: unable to link JIT code: " & sResult) + Return + Endif + + Return File.SetExt(sPath, "so") + +End diff --git a/comp/src/gb.jit/gambas.h b/comp/src/gb.jit/gambas.h new file mode 120000 index 000000000..e63efa23a --- /dev/null +++ b/comp/src/gb.jit/gambas.h @@ -0,0 +1 @@ +../../../main/share/gambas.h \ No newline at end of file diff --git a/comp/src/gb.jit/jit.h b/comp/src/gb.jit/jit.h new file mode 100644 index 000000000..e69de29bb