From 60a541bddd4f4de212c406ba5fabdd7ad1778fb6 Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Tue, 19 Jun 2018 16:52:05 +0430 Subject: fixes #43. the auto-gen source files by luatablegen dont look like source files instead of headers. luatablegen also generates an excuse of a doc for all the table methods. --- bruiser/bruiser.cpp | 26 ++++++++++++-- bruiser/lua-scripts/wasm.lua | 1 + bruiser/luatablegen/W_Code_Section_tablegen.c | 10 ------ bruiser/luatablegen/W_Code_Section_tablegen.h | 1 + bruiser/luatablegen/W_Data_Section_tablegen.c | 10 ------ bruiser/luatablegen/W_Data_Section_tablegen.h | 1 + bruiser/luatablegen/W_Data_Segment_tablegen.c | 10 ------ bruiser/luatablegen/W_Data_Segment_tablegen.h | 1 + bruiser/luatablegen/W_Elem_Segment_tablegen.c | 10 ------ bruiser/luatablegen/W_Elem_Segment_tablegen.h | 1 + bruiser/luatablegen/W_Element_Section_tablegen.c | 10 ------ bruiser/luatablegen/W_Element_Section_tablegen.h | 1 + bruiser/luatablegen/W_Export_Entry_tablegen.c | 10 ------ bruiser/luatablegen/W_Export_Entry_tablegen.h | 1 + bruiser/luatablegen/W_Export_Section_tablegen.c | 10 ------ bruiser/luatablegen/W_Export_Section_tablegen.h | 1 + bruiser/luatablegen/W_Function_Body_tablegen.c | 10 ------ bruiser/luatablegen/W_Function_Body_tablegen.h | 1 + bruiser/luatablegen/W_Function_Section_tablegen.c | 10 ------ bruiser/luatablegen/W_Function_Section_tablegen.h | 1 + bruiser/luatablegen/W_Global_Entry_tablegen.c | 10 ------ bruiser/luatablegen/W_Global_Entry_tablegen.h | 1 + bruiser/luatablegen/W_Global_Section_tablegen.c | 10 ------ bruiser/luatablegen/W_Global_Section_tablegen.h | 1 + .../luatablegen/W_Import_Section_Entry_tablegen.c | 10 ------ .../luatablegen/W_Import_Section_Entry_tablegen.h | 1 + bruiser/luatablegen/W_Import_Section_tablegen.c | 10 ------ bruiser/luatablegen/W_Import_Section_tablegen.h | 1 + bruiser/luatablegen/W_Local_Entry_tablegen.c | 10 ------ bruiser/luatablegen/W_Local_Entry_tablegen.h | 1 + bruiser/luatablegen/W_Memory_Section_tablegen.c | 10 ------ bruiser/luatablegen/W_Memory_Section_tablegen.h | 1 + bruiser/luatablegen/W_Start_Section_tablegen.c | 10 ------ bruiser/luatablegen/W_Start_Section_tablegen.h | 1 + bruiser/luatablegen/W_Table_Section_tablegen.c | 10 ------ bruiser/luatablegen/W_Table_Section_tablegen.h | 1 + .../luatablegen/W_Type_Section_Entry_tablegen.c | 10 ------ .../luatablegen/W_Type_Section_Entry_tablegen.h | 1 + bruiser/luatablegen/W_Type_Section_tablegen.c | 10 ------ bruiser/luatablegen/W_Type_Section_tablegen.h | 1 + bruiser/luatablegen/Wasm_Module_tablegen.c | 10 ------ bruiser/luatablegen/Wasm_Module_tablegen.h | 1 + bruiser/luatablegen/global_type_t_tablegen.c | 10 ------ bruiser/luatablegen/global_type_t_tablegen.h | 1 + bruiser/luatablegen/init_expr_t_tablegen.c | 10 ------ bruiser/luatablegen/init_expr_t_tablegen.h | 1 + bruiser/luatablegen/memory_type_t_tablegen.c | 10 ------ bruiser/luatablegen/memory_type_t_tablegen.h | 1 + bruiser/luatablegen/resizable_limit_t_tablegen.c | 10 ------ bruiser/luatablegen/resizable_limit_t_tablegen.h | 1 + bruiser/luatablegen/table_type_t_tablegen.c | 10 ------ bruiser/luatablegen/table_type_t_tablegen.h | 1 + bruiser/makefile | 3 +- bruiser/run.sh | 2 +- bruiser/wasm/dwasm.py | 7 +++- extra-tools/luatablegen.py | 35 ++++++++++++------ extra-tools/tablegen-test/run.sh | 3 +- macros.mk | 41 ++++++++++++++++++++++ 58 files changed, 125 insertions(+), 268 deletions(-) diff --git a/bruiser/bruiser.cpp b/bruiser/bruiser.cpp index b38327e..7e6a22e 100644 --- a/bruiser/bruiser.cpp +++ b/bruiser/bruiser.cpp @@ -372,8 +372,10 @@ class PyExec { PySys_SetArgv(argc, argv); pName = PyUnicode_DecodeFSDefault(py_script_name.c_str()); - std::string command = "import sys\nsys.path.append(\"" + bruiser_path + "/../bfd\")\n"; - PyRun_SimpleString(command.c_str()); + std::string command_1 = "import sys\nsys.path.append(\"" + bruiser_path + "/../bfd\")\n"; + std::string command_2 = "sys.path.append(\"" + bruiser_path + "/wasm\")\n"; + PyRun_SimpleString(command_1.c_str()); + PyRun_SimpleString(command_2.c_str()); pModule = PyImport_Import(pName); Py_DECREF(pName); @@ -1351,6 +1353,25 @@ class LuaWrapper return 0; } + int BruiserLuaDWASMPy(lua_State* __ls) { + int numargs = lua_gettop(__ls); + std::string filename = "dwasm"; + std::string funcname; + std::string objjpath; + std::string action; + if (numargs != 3) { + PRINT_WITH_COLOR_LB(RED, "wrong number of args. expected 3."); + return 0; + } + funcname = lua_tostring(__ls, 1); + objjpath = lua_tostring(__ls, 2); + action = lua_tostring(__ls, 3); + if (funcname == "" || objjpath == "" || action == "") { + PRINT_WITH_COLOR_LB(RED,"bad arg. nil passed. expected a value."); + } + PyExec py(filename.c_str(), funcname.c_str(), objjpath.c_str()); + } + int BruiserPyLoader(lua_State* __ls ) { int numargs = lua_gettop(__ls); //std::string filename = "../bfd/load.py"; @@ -2385,6 +2406,7 @@ int main(int argc, const char **argv) { lua_register(LE.GetLuaState(), "xsize", &LuaDispatch<&LuaWrapper::BruiserLuaGetXSize>); lua_register(LE.GetLuaState(), "xclear", &LuaDispatch<&LuaWrapper::BruiserLuaXObjDeallocate>); lua_register(LE.GetLuaState(), "xmemusage", &LuaDispatch<&LuaWrapper::BruiserLuaGetXMemSize>); + lua_register(LE.GetLuaState(), "dwasm", &LuaDispatch<&LuaWrapper::BruiserLuaDWASMPy>); runloop.setLW(std::move(LW)); runloop.run(); diff --git a/bruiser/lua-scripts/wasm.lua b/bruiser/lua-scripts/wasm.lua index 88588a6..3c94960 100644 --- a/bruiser/lua-scripts/wasm.lua +++ b/bruiser/lua-scripts/wasm.lua @@ -20,6 +20,7 @@ setmetatable(resizable_limit_t, {__call = setmetatable(global_type_t, {__call = function(self, arg0, arg1) local t = self.new(arg0, arg1) + print("created",t) return t end } diff --git a/bruiser/luatablegen/W_Code_Section_tablegen.c b/bruiser/luatablegen/W_Code_Section_tablegen.c index 717af94..1c516ce 100644 --- a/bruiser/luatablegen/W_Code_Section_tablegen.c +++ b/bruiser/luatablegen/W_Code_Section_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Code_Section_H -#define _W_Code_Section_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Code_Section_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Code_Section_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Code_Section_tablegen.h b/bruiser/luatablegen/W_Code_Section_tablegen.h index 76026d3..5c39e0c 100644 --- a/bruiser/luatablegen/W_Code_Section_tablegen.h +++ b/bruiser/luatablegen/W_Code_Section_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Code_Section_H #define _W_Code_Section_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Data_Section_tablegen.c b/bruiser/luatablegen/W_Data_Section_tablegen.c index a1f78f5..3dbc98b 100644 --- a/bruiser/luatablegen/W_Data_Section_tablegen.c +++ b/bruiser/luatablegen/W_Data_Section_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Data_Section_H -#define _W_Data_Section_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Data_Section_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Data_Section_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Data_Section_tablegen.h b/bruiser/luatablegen/W_Data_Section_tablegen.h index 53276c0..6275d39 100644 --- a/bruiser/luatablegen/W_Data_Section_tablegen.h +++ b/bruiser/luatablegen/W_Data_Section_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Data_Section_H #define _W_Data_Section_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Data_Segment_tablegen.c b/bruiser/luatablegen/W_Data_Segment_tablegen.c index 43d6df1..20b2762 100644 --- a/bruiser/luatablegen/W_Data_Segment_tablegen.c +++ b/bruiser/luatablegen/W_Data_Segment_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Data_Segment_H -#define _W_Data_Segment_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Data_Segment_tablegen.h" #include "../wasm.h" @@ -140,9 +135,4 @@ int W_Data_Segment_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Data_Segment_tablegen.h b/bruiser/luatablegen/W_Data_Segment_tablegen.h index 008cc15..c80428b 100644 --- a/bruiser/luatablegen/W_Data_Segment_tablegen.h +++ b/bruiser/luatablegen/W_Data_Segment_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Data_Segment_H #define _W_Data_Segment_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Elem_Segment_tablegen.c b/bruiser/luatablegen/W_Elem_Segment_tablegen.c index 0500f0d..82f8a30 100644 --- a/bruiser/luatablegen/W_Elem_Segment_tablegen.c +++ b/bruiser/luatablegen/W_Elem_Segment_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Elem_Segment_H -#define _W_Elem_Segment_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Elem_Segment_tablegen.h" #include "../wasm.h" @@ -140,9 +135,4 @@ int W_Elem_Segment_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Elem_Segment_tablegen.h b/bruiser/luatablegen/W_Elem_Segment_tablegen.h index bde6475..46fded5 100644 --- a/bruiser/luatablegen/W_Elem_Segment_tablegen.h +++ b/bruiser/luatablegen/W_Elem_Segment_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Elem_Segment_H #define _W_Elem_Segment_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Element_Section_tablegen.c b/bruiser/luatablegen/W_Element_Section_tablegen.c index 9e98ed7..93e545b 100644 --- a/bruiser/luatablegen/W_Element_Section_tablegen.c +++ b/bruiser/luatablegen/W_Element_Section_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Element_Section_H -#define _W_Element_Section_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Element_Section_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Element_Section_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Element_Section_tablegen.h b/bruiser/luatablegen/W_Element_Section_tablegen.h index 9696217..9123bb8 100644 --- a/bruiser/luatablegen/W_Element_Section_tablegen.h +++ b/bruiser/luatablegen/W_Element_Section_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Element_Section_H #define _W_Element_Section_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Export_Entry_tablegen.c b/bruiser/luatablegen/W_Export_Entry_tablegen.c index a9b5a73..68f40c2 100644 --- a/bruiser/luatablegen/W_Export_Entry_tablegen.c +++ b/bruiser/luatablegen/W_Export_Entry_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Export_Entry_H -#define _W_Export_Entry_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Export_Entry_tablegen.h" #include "../wasm.h" @@ -140,9 +135,4 @@ int W_Export_Entry_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Export_Entry_tablegen.h b/bruiser/luatablegen/W_Export_Entry_tablegen.h index 00d0e00..c4fcdbd 100644 --- a/bruiser/luatablegen/W_Export_Entry_tablegen.h +++ b/bruiser/luatablegen/W_Export_Entry_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Export_Entry_H #define _W_Export_Entry_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Export_Section_tablegen.c b/bruiser/luatablegen/W_Export_Section_tablegen.c index fc4ffdf..fbd2538 100644 --- a/bruiser/luatablegen/W_Export_Section_tablegen.c +++ b/bruiser/luatablegen/W_Export_Section_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Export_Section_H -#define _W_Export_Section_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Export_Section_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Export_Section_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Export_Section_tablegen.h b/bruiser/luatablegen/W_Export_Section_tablegen.h index 4ab9968..ded408e 100644 --- a/bruiser/luatablegen/W_Export_Section_tablegen.h +++ b/bruiser/luatablegen/W_Export_Section_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Export_Section_H #define _W_Export_Section_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Function_Body_tablegen.c b/bruiser/luatablegen/W_Function_Body_tablegen.c index eb93f21..173c381 100644 --- a/bruiser/luatablegen/W_Function_Body_tablegen.c +++ b/bruiser/luatablegen/W_Function_Body_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Function_Body_H -#define _W_Function_Body_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Function_Body_tablegen.h" #include "../wasm.h" @@ -140,9 +135,4 @@ int W_Function_Body_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Function_Body_tablegen.h b/bruiser/luatablegen/W_Function_Body_tablegen.h index 2dcfc65..bb9bf13 100644 --- a/bruiser/luatablegen/W_Function_Body_tablegen.h +++ b/bruiser/luatablegen/W_Function_Body_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Function_Body_H #define _W_Function_Body_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Function_Section_tablegen.c b/bruiser/luatablegen/W_Function_Section_tablegen.c index 9b83937..ebc249d 100644 --- a/bruiser/luatablegen/W_Function_Section_tablegen.c +++ b/bruiser/luatablegen/W_Function_Section_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Function_Section_H -#define _W_Function_Section_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Function_Section_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Function_Section_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Function_Section_tablegen.h b/bruiser/luatablegen/W_Function_Section_tablegen.h index bd53df6..328e2c3 100644 --- a/bruiser/luatablegen/W_Function_Section_tablegen.h +++ b/bruiser/luatablegen/W_Function_Section_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Function_Section_H #define _W_Function_Section_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Global_Entry_tablegen.c b/bruiser/luatablegen/W_Global_Entry_tablegen.c index 9021820..9b87c0f 100644 --- a/bruiser/luatablegen/W_Global_Entry_tablegen.c +++ b/bruiser/luatablegen/W_Global_Entry_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Global_Entry_H -#define _W_Global_Entry_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Global_Entry_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Global_Entry_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Global_Entry_tablegen.h b/bruiser/luatablegen/W_Global_Entry_tablegen.h index 80a9afa..7432095 100644 --- a/bruiser/luatablegen/W_Global_Entry_tablegen.h +++ b/bruiser/luatablegen/W_Global_Entry_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Global_Entry_H #define _W_Global_Entry_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Global_Section_tablegen.c b/bruiser/luatablegen/W_Global_Section_tablegen.c index cb3195c..1254816 100644 --- a/bruiser/luatablegen/W_Global_Section_tablegen.c +++ b/bruiser/luatablegen/W_Global_Section_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Global_Section_H -#define _W_Global_Section_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Global_Section_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Global_Section_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Global_Section_tablegen.h b/bruiser/luatablegen/W_Global_Section_tablegen.h index c58ae62..52ab0c5 100644 --- a/bruiser/luatablegen/W_Global_Section_tablegen.h +++ b/bruiser/luatablegen/W_Global_Section_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Global_Section_H #define _W_Global_Section_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Import_Section_Entry_tablegen.c b/bruiser/luatablegen/W_Import_Section_Entry_tablegen.c index 2f40fc0..0a568e8 100644 --- a/bruiser/luatablegen/W_Import_Section_Entry_tablegen.c +++ b/bruiser/luatablegen/W_Import_Section_Entry_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Import_Section_Entry_H -#define _W_Import_Section_Entry_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Import_Section_Entry_tablegen.h" #include "../wasm.h" @@ -174,9 +169,4 @@ int W_Import_Section_Entry_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Import_Section_Entry_tablegen.h b/bruiser/luatablegen/W_Import_Section_Entry_tablegen.h index db2bddc..6086ae1 100644 --- a/bruiser/luatablegen/W_Import_Section_Entry_tablegen.h +++ b/bruiser/luatablegen/W_Import_Section_Entry_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Import_Section_Entry_H #define _W_Import_Section_Entry_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Import_Section_tablegen.c b/bruiser/luatablegen/W_Import_Section_tablegen.c index 88354f0..de966f9 100644 --- a/bruiser/luatablegen/W_Import_Section_tablegen.c +++ b/bruiser/luatablegen/W_Import_Section_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Import_Section_H -#define _W_Import_Section_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Import_Section_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Import_Section_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Import_Section_tablegen.h b/bruiser/luatablegen/W_Import_Section_tablegen.h index 2dd6799..5d51bf2 100644 --- a/bruiser/luatablegen/W_Import_Section_tablegen.h +++ b/bruiser/luatablegen/W_Import_Section_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Import_Section_H #define _W_Import_Section_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Local_Entry_tablegen.c b/bruiser/luatablegen/W_Local_Entry_tablegen.c index a6fe99e..db10c46 100644 --- a/bruiser/luatablegen/W_Local_Entry_tablegen.c +++ b/bruiser/luatablegen/W_Local_Entry_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Local_Entry_H -#define _W_Local_Entry_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Local_Entry_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Local_Entry_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Local_Entry_tablegen.h b/bruiser/luatablegen/W_Local_Entry_tablegen.h index 05a36dc..d29b5b9 100644 --- a/bruiser/luatablegen/W_Local_Entry_tablegen.h +++ b/bruiser/luatablegen/W_Local_Entry_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Local_Entry_H #define _W_Local_Entry_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Memory_Section_tablegen.c b/bruiser/luatablegen/W_Memory_Section_tablegen.c index 075d5ad..8972528 100644 --- a/bruiser/luatablegen/W_Memory_Section_tablegen.c +++ b/bruiser/luatablegen/W_Memory_Section_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Memory_Section_H -#define _W_Memory_Section_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Memory_Section_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Memory_Section_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Memory_Section_tablegen.h b/bruiser/luatablegen/W_Memory_Section_tablegen.h index 54b9d84..37bffcf 100644 --- a/bruiser/luatablegen/W_Memory_Section_tablegen.h +++ b/bruiser/luatablegen/W_Memory_Section_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Memory_Section_H #define _W_Memory_Section_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Start_Section_tablegen.c b/bruiser/luatablegen/W_Start_Section_tablegen.c index 1f46d8a..b598e1b 100644 --- a/bruiser/luatablegen/W_Start_Section_tablegen.c +++ b/bruiser/luatablegen/W_Start_Section_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Start_Section_H -#define _W_Start_Section_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Start_Section_tablegen.h" #include "../wasm.h" @@ -89,9 +84,4 @@ int W_Start_Section_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Start_Section_tablegen.h b/bruiser/luatablegen/W_Start_Section_tablegen.h index 8e740d3..cf0c1e1 100644 --- a/bruiser/luatablegen/W_Start_Section_tablegen.h +++ b/bruiser/luatablegen/W_Start_Section_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Start_Section_H #define _W_Start_Section_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Table_Section_tablegen.c b/bruiser/luatablegen/W_Table_Section_tablegen.c index a27fb36..43bcdf0 100644 --- a/bruiser/luatablegen/W_Table_Section_tablegen.c +++ b/bruiser/luatablegen/W_Table_Section_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Table_Section_H -#define _W_Table_Section_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Table_Section_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Table_Section_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Table_Section_tablegen.h b/bruiser/luatablegen/W_Table_Section_tablegen.h index 5d10097..9793e6b 100644 --- a/bruiser/luatablegen/W_Table_Section_tablegen.h +++ b/bruiser/luatablegen/W_Table_Section_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Table_Section_H #define _W_Table_Section_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Type_Section_Entry_tablegen.c b/bruiser/luatablegen/W_Type_Section_Entry_tablegen.c index 4faeeb7..c6a38ea 100644 --- a/bruiser/luatablegen/W_Type_Section_Entry_tablegen.c +++ b/bruiser/luatablegen/W_Type_Section_Entry_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Type_Section_Entry_H -#define _W_Type_Section_Entry_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Type_Section_Entry_tablegen.h" #include "../wasm.h" @@ -157,9 +152,4 @@ int W_Type_Section_Entry_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Type_Section_Entry_tablegen.h b/bruiser/luatablegen/W_Type_Section_Entry_tablegen.h index 25d445d..dec22ae 100644 --- a/bruiser/luatablegen/W_Type_Section_Entry_tablegen.h +++ b/bruiser/luatablegen/W_Type_Section_Entry_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Type_Section_Entry_H #define _W_Type_Section_Entry_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/W_Type_Section_tablegen.c b/bruiser/luatablegen/W_Type_Section_tablegen.c index 3c784d1..237c87b 100644 --- a/bruiser/luatablegen/W_Type_Section_tablegen.c +++ b/bruiser/luatablegen/W_Type_Section_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _W_Type_Section_H -#define _W_Type_Section_H -#ifdef __cplusplus -extern "C" { -#endif #include "./W_Type_Section_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int W_Type_Section_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/W_Type_Section_tablegen.h b/bruiser/luatablegen/W_Type_Section_tablegen.h index 68cc567..fd2fd12 100644 --- a/bruiser/luatablegen/W_Type_Section_tablegen.h +++ b/bruiser/luatablegen/W_Type_Section_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _W_Type_Section_H #define _W_Type_Section_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/Wasm_Module_tablegen.c b/bruiser/luatablegen/Wasm_Module_tablegen.c index 724a7b3..318309e 100644 --- a/bruiser/luatablegen/Wasm_Module_tablegen.c +++ b/bruiser/luatablegen/Wasm_Module_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _Wasm_Module_H -#define _Wasm_Module_H -#ifdef __cplusplus -extern "C" { -#endif #include "./Wasm_Module_tablegen.h" #include "../wasm.h" @@ -293,9 +288,4 @@ int Wasm_Module_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/Wasm_Module_tablegen.h b/bruiser/luatablegen/Wasm_Module_tablegen.h index 795b219..7c9aaae 100644 --- a/bruiser/luatablegen/Wasm_Module_tablegen.h +++ b/bruiser/luatablegen/Wasm_Module_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _Wasm_Module_H #define _Wasm_Module_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/global_type_t_tablegen.c b/bruiser/luatablegen/global_type_t_tablegen.c index d583294..a2a8675 100644 --- a/bruiser/luatablegen/global_type_t_tablegen.c +++ b/bruiser/luatablegen/global_type_t_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _global_type_t_H -#define _global_type_t_H -#ifdef __cplusplus -extern "C" { -#endif #include "./global_type_t_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int global_type_t_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/global_type_t_tablegen.h b/bruiser/luatablegen/global_type_t_tablegen.h index 15a2c9e..9fbbc60 100644 --- a/bruiser/luatablegen/global_type_t_tablegen.h +++ b/bruiser/luatablegen/global_type_t_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _global_type_t_H #define _global_type_t_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/init_expr_t_tablegen.c b/bruiser/luatablegen/init_expr_t_tablegen.c index 08a6a3f..ff05e0c 100644 --- a/bruiser/luatablegen/init_expr_t_tablegen.c +++ b/bruiser/luatablegen/init_expr_t_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _init_expr_t_H -#define _init_expr_t_H -#ifdef __cplusplus -extern "C" { -#endif #include "./init_expr_t_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int init_expr_t_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/init_expr_t_tablegen.h b/bruiser/luatablegen/init_expr_t_tablegen.h index 3f7b518..aabcc64 100644 --- a/bruiser/luatablegen/init_expr_t_tablegen.h +++ b/bruiser/luatablegen/init_expr_t_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _init_expr_t_H #define _init_expr_t_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/memory_type_t_tablegen.c b/bruiser/luatablegen/memory_type_t_tablegen.c index fe921bc..5f75d51 100644 --- a/bruiser/luatablegen/memory_type_t_tablegen.c +++ b/bruiser/luatablegen/memory_type_t_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _memory_type_t_H -#define _memory_type_t_H -#ifdef __cplusplus -extern "C" { -#endif #include "./memory_type_t_tablegen.h" #include "../wasm.h" @@ -89,9 +84,4 @@ int memory_type_t_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/memory_type_t_tablegen.h b/bruiser/luatablegen/memory_type_t_tablegen.h index ffd02a9..2a63963 100644 --- a/bruiser/luatablegen/memory_type_t_tablegen.h +++ b/bruiser/luatablegen/memory_type_t_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _memory_type_t_H #define _memory_type_t_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/resizable_limit_t_tablegen.c b/bruiser/luatablegen/resizable_limit_t_tablegen.c index 16f0432..f777510 100644 --- a/bruiser/luatablegen/resizable_limit_t_tablegen.c +++ b/bruiser/luatablegen/resizable_limit_t_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _resizable_limit_t_H -#define _resizable_limit_t_H -#ifdef __cplusplus -extern "C" { -#endif #include "./resizable_limit_t_tablegen.h" #include "../wasm.h" @@ -123,9 +118,4 @@ int resizable_limit_t_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/resizable_limit_t_tablegen.h b/bruiser/luatablegen/resizable_limit_t_tablegen.h index bd9ab6f..b987261 100644 --- a/bruiser/luatablegen/resizable_limit_t_tablegen.h +++ b/bruiser/luatablegen/resizable_limit_t_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _resizable_limit_t_H #define _resizable_limit_t_H #ifdef __cplusplus diff --git a/bruiser/luatablegen/table_type_t_tablegen.c b/bruiser/luatablegen/table_type_t_tablegen.c index 21dd9da..a8e5af0 100644 --- a/bruiser/luatablegen/table_type_t_tablegen.c +++ b/bruiser/luatablegen/table_type_t_tablegen.c @@ -5,11 +5,6 @@ #include "../lua-5.3.4/src/lualib.h" #include #include -#ifndef _table_type_t_H -#define _table_type_t_H -#ifdef __cplusplus -extern "C" { -#endif #include "./table_type_t_tablegen.h" #include "../wasm.h" @@ -106,9 +101,4 @@ int table_type_t_register(lua_State* __ls) { return 1; } -#ifdef __cplusplus -} -#endif //end of extern c -#endif //end of inclusion guard - diff --git a/bruiser/luatablegen/table_type_t_tablegen.h b/bruiser/luatablegen/table_type_t_tablegen.h index c2aed8b..9999c40 100644 --- a/bruiser/luatablegen/table_type_t_tablegen.h +++ b/bruiser/luatablegen/table_type_t_tablegen.h @@ -5,6 +5,7 @@ #include "../lua-5.3.4/src/lualib.h" #include #include + #ifndef _table_type_t_H #define _table_type_t_H #ifdef __cplusplus diff --git a/bruiser/makefile b/bruiser/makefile index 393a7ae..ed592d8 100644 --- a/bruiser/makefile +++ b/bruiser/makefile @@ -17,7 +17,8 @@ C_SRCS=$(wildcard *.c) #for some reason without ld the build fails on ubuntu trusty on travis #EXTRA_LD_FLAGS+=-lpthread -ldl -lutil -lm -Xlinker -lpython3 EXTRA_LD_FLAGS+=$(shell $(PY_CONF) --ldflags) -lffi -lcapstone -lkeystone -L./lua-5.3.4/src -llua -TBG_OBJLIST_INC=$(patsubst ./luatablegen/%.c, ./luatablegen/%.o, $(wildcard ./luatablegen/*.c)) +TBG_OBJLIST_INC:=$(patsubst ./luatablegen/%.c, ./luatablegen/%.o, $(wildcard ./luatablegen/*.c)) +SAN?= ######################################RULES#################################### .DEFAULT: all diff --git a/bruiser/run.sh b/bruiser/run.sh index 0a1dca3..92d249d 100755 --- a/bruiser/run.sh +++ b/bruiser/run.sh @@ -2,6 +2,6 @@ cd $(dirname $0) #"./bruiser" --verbose --lua ./lua-scripts/demo1.lua -"./bruiser" --lua ./lua-scripts/demo1.lua +"./bruiser" --lua ./lua-scripts/regtest.lua #"./bruiser" ../test/bruisertest/test.cpp --src --verbose --lua ./lua-scripts/demo1.lua #gdb "./bruiser ../test/bruisertest/test.cpp --src" diff --git a/bruiser/wasm/dwasm.py b/bruiser/wasm/dwasm.py index 28f3c4d..e404dca 100755 --- a/bruiser/wasm/dwasm.py +++ b/bruiser/wasm/dwasm.py @@ -5,9 +5,14 @@ import code import readline import signal import sys -from parse import Argparser, premain, SigHandler_SIGINT +from parse import Argparser, premain, SigHandler_SIGINT,PythonInterpreter from utils import ParseFlags +def getWASMModule(): + module_path = sys.argv[1] + interpreter = PythonInterpreter() + module = interpreter.parse(module_path) + def main(): signal.signal(signal.SIGINT, SigHandler_SIGINT) argparser = Argparser() diff --git a/extra-tools/luatablegen.py b/extra-tools/luatablegen.py index c66b94c..dbf7435 100755 --- a/extra-tools/luatablegen.py +++ b/extra-tools/luatablegen.py @@ -14,7 +14,7 @@ EXTERN_C = ['#ifdef __cplusplus\nextern "C" {\n#endif\n', '#ifdef __cplusplus\n} BEGIN_NOTE = "//Generated Automatically by luatablegen." HEADER_LIST = ['#include "HHHlua.h"\n', '#include "HHHlauxlib.h"\n', '#include "HHHlualib.h"\n', '#include \n', - '#include '] + '#include \n'] CONVERT = ['static XXX* convert_XXX (lua_State* __ls, int index) {\n', '\tXXX* dummy = (XXX*)lua_touserdata(__ls, index);\n', '\tif (dummy == NULL) printf("XXX:bad user data type.\\n");\n', @@ -90,6 +90,7 @@ class Argparser(object): parser.add_argument("--outfile", type=str, help="name of the output file if signlefile is set, ignored otherwise") parser.add_argument("--headeraggr", type=str, help="header aggregate file name") parser.add_argument("--lualibpath", type=str, help="where the lua module file will be placed") + parser.add_argument("--docpath", type=str, help="where the doc file will be placed") self.args = parser.parse_args() class TbgParser(object): @@ -105,8 +106,8 @@ class TbgParser(object): c_source.write(header.replace("HHH", self.argparser.args.luaheader+"/")) else: c_source.write(header.replace("HHH", "")) - c_source.write(HEADER_GUARD[0].replace("XXX", struct_name)) - c_source.write(EXTERN_C[0]) + if not is_source: c_source.write(HEADER_GUARD[0].replace("XXX", struct_name)) + if not is_source: c_source.write(EXTERN_C[0]) if is_source: c_source.write("#include " + '"./' +h_filename+ '"\n') c_source.write("\n") if self.argparser.args.pre: @@ -241,7 +242,7 @@ class TbgParser(object): for line in TABLE_REGISTER: c_source.write(line.replace("XXX", struct_name)) - def end(self, c_source): + def end(self, c_source, is_source): if self.argparser.args.post: c_source.write("\n") post_file = open(self.argparser.args.post) @@ -249,10 +250,20 @@ class TbgParser(object): c_source.write(line) post_file.clsoe() c_source.write("\n") - c_source.write(EXTERN_C[1]) - c_source.write(HEADER_GUARD[1]) + if not is_source: c_source.write(EXTERN_C[1]) + if not is_source: c_source.write(HEADER_GUARD[1]) c_source.write("\n") + def docgen_md(self, d_source, struct_name, field_names, field_types, lua_types): + d_source.write("## wasm tables method list:\n") + for field_name,lua_type in zip(field_names, lua_types): + d_source.write(struct_name + ":" + field_name + "()" + " -- ") + d_source.write(lua_type + "
" + "\n") + for field_name,lua_type in zip(field_names, lua_types): + d_source.write("set_" + struct_name + ":" + field_name + "()" + " -- ") + d_source.write(lua_type + "
" + "\n") + d_source.write("\n") + def luagen(self): l_source = open(self.argparser.args.lualibpath, "w") l_source.write("-- automatically generated by luatablegen\n") @@ -280,6 +291,8 @@ class TbgParser(object): table_reg_list = [] if self.argparser.args.singlefile: c_source = open(self.argparser.args.outfile, "w") + if self.argparser.args.docpath: + d_source = open(self.argparser.args.docpath, "w") for k, v in self.tbg_file.items(): struct_name = k field_names = v['field_name'] @@ -298,10 +311,7 @@ class TbgParser(object): header_aggr_list.append("./" + h_filename) h_source = open(self.argparser.args.out + "/" + h_filename, "w") # source file - # TODO - the c source file is getting a header guard and cpp - # inclusion macros self.begin(c_source, struct_name, h_filename, True) - #self.struct(c_source, field_names, field_types, struct_name) self.convert(c_source, struct_name) self.check(c_source, struct_name) self.push_self(c_source, struct_name) @@ -312,7 +322,7 @@ class TbgParser(object): self.register_table_methods(c_source, struct_name, field_names) self.register_table_meta(c_source, struct_name) self.register_table(c_source, struct_name) - self.end(c_source) + self.end(c_source, True) if not self.argparser.args.singlefile: c_source.close() # header file self.begin(h_source, struct_name, h_filename, False) @@ -327,7 +337,10 @@ class TbgParser(object): h_source.write(SETTER_GEN[0].replace("XXX", struct_name).replace("YYY", field_name).replace(" {\n", ";\n")) table_reg_list.append(struct_name + "_register(__ls);\n") h_source.write(TABLE_REGISTER[0].replace("XXX", struct_name).replace(" {\n", ";\n")) - self.end(h_source) + self.end(h_source, False) + # docs + if self.argparser.args.docpath: + self.docgen_md(d_source, struct_name, field_names, field_types, lua_types) # header aggregate if self.argparser.args.headeraggr: name = self.argparser.args.headeraggr diff --git a/extra-tools/tablegen-test/run.sh b/extra-tools/tablegen-test/run.sh index c70e23b..a4afb66 100755 --- a/extra-tools/tablegen-test/run.sh +++ b/extra-tools/tablegen-test/run.sh @@ -1,7 +1,6 @@ #!/usr/bin/bash cd $(dirname $0) -../luatablegen.py --tbg ../wasmtablegen.json --out ../../bruiser/luatablegen --luaheader ../../bruiser/lua-5.3.4/src --pre ./wasmheader.txt --headeraggr ../../bruiser/luatablegen/wasm_tables.h --lualibpath ../../bruiser/lua-scripts/wasm.lua -#../luatablegen.py --tbg ../wasmtablegen.json --out ../../bruiser/luatablegen --luaheader ../../bruiser/lua-5.3.4/src --pre ./wasmheader.txt --singlefile --outfile ../../bruiser/luatablegen/wasmtablegen.h +../luatablegen.py --tbg ../wasmtablegen.json --out ./ --luaheader ../../bruiser/lua-5.3.4/src --pre ./wasmheader.txt --headeraggr ../../bruiser/luatablegen/wasm_tables.h --lualibpath ./wasm.lua --docpath ./wasm.md for filename in ../../bruiser/luatablegen/*.c; do gcc -c $filename > /dev/null 2>&1 if [[ $? != 0 ]]; then diff --git a/macros.mk b/macros.mk index 3fe8e96..f946abe 100644 --- a/macros.mk +++ b/macros.mk @@ -9,6 +9,12 @@ BUILD_MODE?=COV_NO_CLANG_1Z SHELL:=/bin/bash MAKEFLAGS+=--warn-undefined-variables +ADD_SANITIZERS_CC= -g -fsanitize=address -fno-omit-frame-pointer +ADD_SANITIZERS_LD= -g -fsanitize=address +MEM_SANITIZERS_CC= -g -fsanitize=memory -fno-omit-frame-pointer +MEM_SANITIZERS_LD= -g -fsanitize=memory +UB_SANITIZERS_CC= -g -fsanitize=undefined -fno-omit-frame-pointer +UB_SANITIZERS_LD= -g -fsanitize=undefined CXX_FLAGS=$(shell $(LLVM_CONF) --cxxflags) CC_FLAGS= @@ -65,6 +71,41 @@ EXTRA_CXX_FALGS=-I$(shell $(LLVM_CONF) --src-root)/tools/clang/include -I$(shell EXTRA_LD_FLAGS=-v endif +############################################################################################################################## +ifeq ($(BUILD_MODE), ADDSAN) +ifeq ($(CXX), g++) +$(error This build mode is only useable with clang++.) +endif +EXTRA_CXX_FALGS=-I$(shell $(LLVM_CONF) --src-root)/tools/clang/include -I$(shell $(LLVM_CONF) --obj-root)/tools/clang/include\ + -std=c++17 -stdlib=libstdc++ -UNDEBUG -fexceptions +EXTRA_CXX_FALGS+=$(ADD_SANITIZERS_CC) +EXTRA_LD_FLAGS=-v +EXTRA_LD_FLAGS+=$(ADD_SANITIZERS_LD) +endif + +ifeq ($(BUILD_MODE), MEMSAN) +ifeq ($(CXX), g++) +$(error This build mode is only useable with clang++.) +endif +EXTRA_CXX_FALGS=-I$(shell $(LLVM_CONF) --src-root)/tools/clang/include -I$(shell $(LLVM_CONF) --obj-root)/tools/clang/include\ + -std=c++17 -stdlib=libstdc++ -UNDEBUG -fexceptions +EXTRA_CXX_FALGS+=$(MEM_SANITIZERS_CC) +EXTRA_LD_FLAGS=-v +EXTRA_LD_FLAGS+=$(MEM_SANITIZERS_LD) +endif + +ifeq ($(BUILD_MODE), UBSAN) +ifeq ($(CXX), g++) +$(error This build mode is only useable with clang++.) +endif +EXTRA_CXX_FALGS=-I$(shell $(LLVM_CONF) --src-root)/tools/clang/include -I$(shell $(LLVM_CONF) --obj-root)/tools/clang/include\ + -std=c++17 -stdlib=libstdc++ -UNDEBUG -fexceptions +EXTRA_CXX_FALGS+=$(UB_SANITIZERS_CC) +EXTRA_LD_FLAGS=-v +EXTRA_LD_FLAGS+=$(UB_SANITIZERS_LD) +endif +############################################################################################################################## + ifeq ($(BUILD_MODE), COV_NO_CLANG_14) ifeq ($(CXX), g++) $(error This build mode is only useable with clang++.) -- cgit v1.2.3