Skip to content

Commit 8df3f42

Browse files
authored
Merge pull request #41 from xqyjlj/rootfs.prefixdir-dev
✨ feat: use rootfs.prefixdir
2 parents 1af8438 + 90a04f0 commit 8df3f42

3 files changed

Lines changed: 32 additions & 9 deletions

File tree

apps/cpp/xmake.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
--
1313
-- Copyright (C) 2022-2023 RT-Thread Development Team
1414
--
15-
-- @author xqyjlj
15+
-- @author xqyjlj
1616
-- @file xmake.lua
1717
--
1818
-- Change Logs:
@@ -22,9 +22,10 @@
2222
--
2323
add_rules("mode.debug", "mode.release")
2424

25-
target("cpp")
25+
target("cpp_tc")
2626
do
2727
add_rules("rt.cpp")
2828
add_files("*.cpp")
29+
add_values("rt.rootfs.prefixdir", "/tc")
2930
end
3031
target_end()

apps/zlib/xmake.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ add_rules("mode.debug", "mode.release")
2525

2626
add_requires("zlib")
2727

28-
target("zlib")
28+
target("zlib_tc")
2929
do
3030
add_files("*.c")
3131
add_packages("zlib")
32+
add_values("rt.rootfs.prefixdir", "/tc")
3233
end
3334
target_end()

tools/scripts/tasks/smart-rootfs/on_run.lua

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
--
1313
-- Copyright (C) 2023-2023 RT-Thread Development Team
1414
--
15-
-- @author xqyjlj
15+
-- @author xqyjlj
1616
-- @file on_run.lua
1717
--
1818
-- Change Logs:
@@ -33,19 +33,33 @@ function create_dir(dir)
3333
end
3434
end
3535

36+
function make_link(srcpath, dstpath)
37+
print(dstpath)
38+
if not os.exists(dstpath) then
39+
os.ln(srcpath, dstpath)
40+
end
41+
end
42+
3643
function create_rootfs(rootfs)
3744
create_dir(path.join(rootfs, "bin"))
3845
create_dir(path.join(rootfs, "dev"))
46+
create_dir(path.join(rootfs, "dev", "shm"))
3947
create_dir(path.join(rootfs, "etc"))
40-
create_dir(path.join(rootfs, "kernel"))
4148
create_dir(path.join(rootfs, "lib"))
4249
create_dir(path.join(rootfs, "proc"))
4350
create_dir(path.join(rootfs, "mnt"))
4451
create_dir(path.join(rootfs, "services"))
4552
create_dir(path.join(rootfs, "tmp"))
4653
create_dir(path.join(rootfs, "usr"))
47-
create_dir(path.join(rootfs, "var", "persistence"))
48-
create_dir(path.join(rootfs, "var", "run"))
54+
create_dir(path.join(rootfs, "var"))
55+
create_dir(path.join(rootfs, "run"))
56+
create_dir(path.join(rootfs, "root"))
57+
58+
if os.host() == "linux" then
59+
local olddir = os.cd(rootfs)
60+
make_link("../run", path.join(rootfs, "var", "run"))
61+
os.cd(olddir)
62+
end
4963
end
5064

5165
function deploy_package(rootfs)
@@ -66,7 +80,7 @@ function deploy_package(rootfs)
6680
local package_rootfs = path.join(repodir, "packages", packagename:sub(1, 1), packagename, "rootfs")
6781
if os.isdir(package_rootfs) then
6882
for _, filedir in ipairs(os.filedirs(package_rootfs .. "/*")) do
69-
os.vrunv("cp", {"-rfv", filedir, rootfs})
83+
os.vrunv("cp", {"-rfv", filedir, rootfs}) -- TODO: need support windows
7084
end
7185
end
7286
end
@@ -97,7 +111,14 @@ function deploy_target(rootfs)
97111
local srcpath = target:targetfile()
98112
local artifact_dir = path.join(config.buildir(), config.plat(), config.arch(), config.mode())
99113
targetfile = path.relative(targetfile, artifact_dir)
100-
local dstpath = path.join(rootfs, "bin", targetfile)
114+
115+
local prefixdir = target:values("rt.rootfs.prefixdir")
116+
local dstpath
117+
if prefixdir then
118+
dstpath = path.join(rootfs, prefixdir, targetfile)
119+
else
120+
dstpath = path.join(rootfs, "bin", targetfile)
121+
end
101122
cprint("${dim}> copy %s to %s", srcpath, dstpath)
102123
os.cp(srcpath, dstpath)
103124
end

0 commit comments

Comments
 (0)