|
1 | | -local SILVER_CHAIN_CODE = "32342jjressd" |
2 | | -local SILVER_CHAIN_PATH = "dependencies/CSilverChainApiNoDependenciesIncluded.h" |
3 | | -dtw.remove_any("release") |
4 | | - |
5 | | -function generate_full_c() |
6 | | - private_darwin.resset_c() |
7 | | - |
8 | | - darwin.add_c_file("citerop.c", true) |
9 | | - darwin.load_lualib_from_c( |
10 | | - "luaopen_private_silverchain_cinterop", |
11 | | - "private_silverchain_cinterop" |
12 | | - ) |
13 | | - |
14 | | - local full_clib = darwin.generate_c_lib_code({ |
15 | | - libname = "lua_silverchain", |
16 | | - object_export = "public_lua_silverchain", |
17 | | - include_e_luacembed = false |
18 | | - }) |
19 | | - |
20 | | - full_clib = full_clib:gsub(SILVER_CHAIN_CODE, "#include") |
21 | | - dtw.write_file("release/silverchain_full.c", full_clib) |
22 | | -end |
23 | | - |
24 | | -function generate_darwin_import() |
25 | | - private_darwin.resset_c() |
26 | | - darwin.add_c_file("citerop.c", true, function(import, path) |
27 | | - if import == "dependencies/LuaCEmbed.h" then |
28 | | - return false |
29 | | - end |
30 | | - return true |
31 | | - end) |
32 | | - darwin.load_lualib_from_c( |
33 | | - "luaopen_private_silverchain_cinterop", |
34 | | - "private_silverchain_cinterop" |
35 | | - ) |
36 | | - |
37 | | - local full_clib = darwin.generate_c_lib_code({ |
38 | | - libname = "lua_silverchain", |
39 | | - object_export = "public_lua_silverchain", |
40 | | - include_e_luacembed = false |
41 | | - }) |
42 | | - |
43 | | - full_clib = full_clib:gsub(SILVER_CHAIN_CODE, "#include") |
44 | | - dtw.write_file("release/silverchain_darwin_import.c", full_clib) |
45 | | -end |
46 | | - |
47 | | -function generate_darwin_no_dependencie_not_included() |
48 | | - private_darwin.resset_c() |
49 | | - |
50 | | - darwin.add_c_file("citerop.c", true, function(import, path) |
51 | | - if import == "dependencies/CSilverChainApiNoDependenciesIncluded.h" then |
52 | | - return true |
53 | | - end |
54 | | - return false |
55 | | - end) |
56 | | - |
57 | | - darwin.load_lualib_from_c( |
58 | | - "luaopen_private_silverchain_cinterop", |
59 | | - "private_silverchain_cinterop" |
60 | | - ) |
61 | | - |
62 | | - local full_clib = darwin.generate_c_lib_code({ |
63 | | - libname = "lua_silverchain", |
64 | | - object_export = "public_lua_silverchain", |
65 | | - include_e_luacembed = false |
66 | | - }) |
67 | | - |
68 | | - full_clib = full_clib:gsub(SILVER_CHAIN_CODE, "#include") |
69 | | - dtw.write_file("release/silverchain_no_dependecie_included.c", full_clib) |
70 | | -end |
71 | | - |
72 | | -darwin.add_lua_code("public_lua_silverchain = {}") |
73 | | -darwin.add_lua_code("private_silver_chain = {}") |
74 | | - |
75 | | -local concat_path = true |
76 | | -local src_files = dtw.list_files_recursively("public", concat_path) |
77 | | -for i = 1, #src_files do |
78 | | - local current = src_files[i] |
79 | | - darwin.add_lua_code("-- file: " .. current .. "\n") |
80 | | - darwin.add_lua_file(current) |
81 | | -end |
82 | | -darwin.generate_lua_output({ output_name = "debug.lua" }) |
83 | | - |
84 | | ---- we must format these , to avoid bugs on include |
85 | | -local camalgamator_content = dtw.load_file(SILVER_CHAIN_PATH) |
86 | | -camalgamator_content = camalgamator_content:gsub("#include", SILVER_CHAIN_CODE) |
87 | | -dtw.write_file(SILVER_CHAIN_PATH, camalgamator_content) |
88 | | - |
89 | | -generate_full_c() |
90 | | -generate_darwin_import() |
91 | | -generate_darwin_no_dependencie_not_included() |
92 | | - |
93 | | -dtw.copy_any_overwriting("types/luaSilverCHain_types.lua", "LuaSilverChain/types.lua") |
94 | | -dtw.copy_any_overwriting("init.lua", "LuaSilverChain/init.lua") |
95 | | - |
96 | | -os.execute("gcc -shared -fpic release/silverchain_full.c -o LuaSilverChain/silverchain.so") |
97 | | -os.execute("zip -r release/LuaSilverChain.zip LuaSilverChain") |
0 commit comments