forked from xfangfang/wiliwili
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuwp.lua
101 lines (95 loc) · 2.44 KB
/
uwp.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
import("lib.detect.find_program")
import("detect.sdks.find_vstudio")
local function listFiles(dir, out, i)
for _, f in ipairs(os.filedirs(path.join(dir, "**"))) do
if os.isfile(f) then
t = f
if i then
t = string.sub(f, i)
end
table.insert(out, {f, t})
end
end
end
local outPath = "build/wiliwili.msix"
local keyPath = "winrt/key.pfx"
local priconfigPath = "build/priconfig.xml"
local fileMapPath = "build/main.map.txt"
local priPath = "build\\resources.pri"
function main(target)
local files = {
{priPath, "resources.pri"},
{target:targetfile(), "wiliwili.exe"},
}
local d = {}
for _, pkg in pairs(target:pkgs()) do
if pkg:has_shared() then
for _, f in ipairs(pkg:libraryfiles()) do
if f:endswith(".dll") then
local k = path.filename(f)
if d[k] == nil then
table.insert(files, {f, k})
d[k] = true
end
end
end
end
end
listFiles("winrt/Assets", files, 7)
listFiles("resources", files)
local context = ""
for _, ff in ipairs(files) do
context = context..format('\n"%s"\t\t"%s"', ff[1], ff[2])
end
io.writefile(fileMapPath, format([[
[ResourceMetadata]
"ResourceDimensions" "language-en-US"
[Files]
%s
]], context))
local vs = find_vstudio()["2022"]["vcvarsall"]["x86"]
local windowsSdkBinPath = path.join(vs["WindowsSdkBinPath"], vs["WindowsSDKVersion"], "x86")
local makepri = path.join(windowsSdkBinPath, "makepri.exe")
local makeappx = path.join(windowsSdkBinPath, "makeappx.exe")
local signtool = path.join(windowsSdkBinPath, "signtool.exe")
os.execv(makepri, {
"createconfig",
"-Overwrite",
"/cf",
priconfigPath,
"/dq",
"en-US"
})
os.execv(makepri, {
"new",
"-Overwrite",
"/pr",
"winrt",
"/cf",
priconfigPath,
"-OutputFile",
priPath
})
os.execv(makeappx, {
"pack",
"/l",
"/h",
"SHA256",
"/f",
fileMapPath,
"/m",
"winrt/AppxManifest.xml",
"/o",
"/p",
outPath
})
os.execv(signtool, {
"sign",
"/fd",
"SHA256",
"/a",
"/f",
keyPath,
outPath
})
end