-
Notifications
You must be signed in to change notification settings - Fork 2
/
how2build.lua
172 lines (149 loc) · 4.82 KB
/
how2build.lua
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
--[[
Need Mac OSX and LuaJIT.
LuaJIT can be installed from homebrew.
download aite: https://github.com/rweichler/aite
cd into this directory and run this command:
/PATH/TO/AITE/main.lua
if this errored at you in any way, email me at rweichler@gmail.com so i can fix it.
OPTIONAL:
install aite permanently by running this command:
ln -s /PATH/TO/AITE/main.lua /usr/local/bin/aite
now, instead of all those annoying steps, you'd just run this command:
aite
]]
local use_luajit = false -- this doesn't work (yet)
local function builder()
local b = _G.builder('apple')
b.compiler = 'clang'
b.build_dir = '.aite_build'
b.sdk_path = 'deps/iPhoneOS13.2.sdk'
b.archs = {
'arm64',
}
b.include_dirs = {
'deps/src',
'deps/include',
'.tmp/include',
}
if use_luajit then
table.remove(b.include_dirs, 1)
end
b.library_dirs = {
'deps/lib',
}
b.sflags = '-mios-version-min=13.0'
return b
end
local deb = debber()
deb.packageinfo = {
Package = 'com.r333d.cylinder',
Name = 'Cylinder',
Version = '1.0.8~beta1',
Architecture = 'iphoneos-arm',
Depends = 'firmware (>= 3.0), mobilesubstrate (>= 0.9.6011), preferenceloader',
Icon = 'file:///Library/PreferenceBundles/CylinderSettings.bundle/Icon@2x.png',
Depiction = 'http://moreinfo.thebigboss.org/moreinfo/depiction.php?file=cylinderDp',
Description = 'Make your icons dance',
Homepage = 'http://github.com/rweichler/cylinder',
Maintainer = 'Reed Weichler <rweichler+cydia@gmail.com>',
Author = 'Reed Weichler (rweichler) <rweichler+cydia@gmail.com>',
Section = 'Tweaks',
}
deb.input = builder().build_dir..'/layout'
deb.output = 'cylinder.deb'
local function logos_workaround(flag)
if flag == 'clean' then
os.execute('rm -rf .tmp')
return
end
fs.mkdir('.tmp/include/logos')
io.open('.tmp/include/logos/logos.h', 'w'):close()
end
function default(flag)
logos_workaround()
tweak()
settings()
cydia()
end
function clean()
os.pexecute('rm -rf '..builder().build_dir..' '..deb.output)
end
function finish()
logos_workaround('clean')
end
function lua()
local b = builder()
b.src = fs.scandir('deps/src/lua/*.c')
b.defines = {
'LUA_USE_MACOSX',
}
b.output = ''
return b:compile()
end
function cydia()
local msdir = deb.input..'/Library/MobileSubstrate/DynamicLibraries'
fs.mkdir(msdir)
os.pexecute('cp '..builder().build_dir..'/Cylinder.dylib '..msdir)
os.pexecute('cp res/Cylinder.plist '..msdir)
fs.mkdir(deb.input..'/DEBIAN')
os.pexecute('cp src/DEBIAN/postinst '..deb.input..'/DEBIAN')
local scriptsdir = deb.input..'/Library/Cylinder'
fs.mkdir(scriptsdir)
os.pexecute('cp -r src/scripts/* '..scriptsdir)
local prefsdir = deb.input..'/Library/PreferenceBundles/CylinderSettings.bundle'
fs.mkdir(prefsdir)
os.pexecute('cp -r res/settings/* '..prefsdir)
os.pexecute('cp '..builder().build_dir..'/CylinderSettings.dylib '..prefsdir..'/CylinderSettings')
local prefloaderdir = deb.input..'/Library/PreferenceLoader/Preferences'
fs.mkdir(prefloaderdir)
os.pexecute('cp res/CylinderSettingsLoader.plist '..prefloaderdir)
deb:make_deb()
end
function tweak()
local b = builder()
-- todo: get rid of logos. using it was a bad idea
os.pexecute('aite/bin/logos.pl src/tweak/tweak.x > '..fs.mkdir(b.build_dir)..'/tweak.x.o.m')
table.insert(b.include_dirs, 'src/tweak')
b.src = table.merge(
fs.scandir('src/tweak/*.m'),
b.build_dir..'/tweak.x.o.m'
)
b.frameworks = {
'UIKit',
'Foundation',
'QuartzCore',
'CoreGraphics',
}
b.libraries = {
'substrate',
use_luajit and 'luajit' or nil,
}
b.bin = 'Cylinder.dylib'
print("DEBUG -> BEFORE tweak link")
print("DEBUG -> merging table")
local testing = table.merge(b:compile(), not use_luajit and lua() or nil)
print("DEBUG -> linking")
b:link(testing)
print("DEBUG -> AFTER tweak link")
end
function settings()
local b = builder()
b.src = fs.scandir('src/settings/*.m')
b.frameworks = {
'Foundation',
'UIKit',
'QuartzCore',
'CoreGraphics',
'AVFoundation',
-- 'Preferences',
}
b.bin = 'CylinderSettings.dylib'
b.ldflags = '-flat_namespace -undefined suppress' -- this is bad practice but meh
b:link(b:compile())
end
function install(iphone)
iphone = iphone or 'iphone'
local filename = fs.split_path(deb.output)
os.pexecute('scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '..deb.output..' '..iphone..':')
os.pexecute('ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '..iphone..' "dpkg -i '..filename..'; rm '..filename..'"')
end