-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdarwinconf.lua
More file actions
86 lines (62 loc) · 2.58 KB
/
darwinconf.lua
File metadata and controls
86 lines (62 loc) · 2.58 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
function silverchain_generation()
darwin.silverchain.generate({
src = "src",
tags = { "dep_declare", "macros", "types","consts", "fdeclare","globals", "dep_define","fdefine" },
project_short_cut = "LuaCEmbed",
implement_main = false
})
end
function amalgamation_build()
local MAX_CONNTENT = darwin.camalgamator.ONE_MB * 20
local MAX_RECURSION = 100
local lincense = "/* " .. darwin.dtw.load_file("LICENSE") .. " */ \n"
local onefile = darwin.camalgamator.generate_amalgamation("src/one.c", MAX_CONNTENT, MAX_RECURSION)
onefile = lincense .. onefile
darwin.dtw.write_file("release/LuaCEmbedOne.c", onefile)
local only_declare = darwin.camalgamator.generate_amalgamation("src/imports/imports.fdeclare.h", MAX_CONNTENT,
MAX_RECURSION)
only_declare = lincense .. only_declare
darwin.dtw.write_file("release/LuaCEmbed.h", only_declare)
local only_definition = darwin.camalgamator.generate_amalgamation_with_callback("src/imports/imports.fdefine.h",
function(import, path)
if darwin.dtw.ends_with(import,"cJSON.h") then
return "dont-include"
end
if darwin.dtw.ends_with(import,"CTextEngine.h") then
return "dont-include"
end
if darwin.dtw.ends_with(import,"UniversalGarbage.h") then
return "dont-include"
end
if darwin.dtw.ends_with(import,"UniversalSocket.h") then
return "dont-include"
end
if darwin.dtw.ends_with(path,"imports.fdeclare.h") then
return "dont-include"
end
return "include-once"
end,
MAX_CONNTENT,
MAX_RECURSION
)
only_definition = '#include "LuaCEmbed.h"\n' .. only_definition
only_definition = lincense .. only_definition
darwin.dtw.write_file("release/LuaCEmbed.c", only_definition)
os.execute("zip -r release/LuaCEmbed.zip dependencies src build")
end
-- Recipe definitions
darwin.add_recipe({
name = "silverchain",
description = "Generate silverchain imports",
outs = {"src/imports/"},
inputs = {"src"},
callback = silverchain_generation
})
darwin.add_recipe({
name = "amalgamation",
requires = {"silverchain"},
description = "Make a single file amalgamation of the project",
outs = {"release/LuaCEmbedOne.c", "release/LuaCEmbed.h", "release/LuaCEmbed.c", "release/LuaCEmbed.zip"},
inputs = {"src", "dependencies", "LICENSE"},
callback = amalgamation_build
})