@@ -133,16 +133,9 @@ function deploy_target(rootfs)
133133 end
134134end
135135
136- function deploy_syslib (toolchains , rootfs )
136+ function deploy_syslib (rootfs )
137137 local sdkdir = rt_utils .sdk_dir ()
138138 local arch = config .arch ()
139- local pkg = project :required_packages ()[toolchains ]
140-
141- if string .startswith (toolchains , " riscv64" ) then
142- toolchains = " riscv64-unknown-smart-musl"
143- end
144-
145- toolchains = string.gsub (toolchains , " smart" , " linux" ) -- TODO: should replace, when toolchains renamed
146139
147140 if arch == " arm64" then
148141 arch = " aarch64"
@@ -152,6 +145,12 @@ function deploy_syslib(toolchains, rootfs)
152145 arch = " arm/cortex-a"
153146 elseif arch == " aarch64" then
154147 arch = " aarch64/cortex-a"
148+ elseif arch == " riscv64gc" then
149+ arch = " risc-v/rv64gc/lp64"
150+ elseif arch == " riscv64gcv" then
151+ arch = " risc-v/rv64gcv/lp64"
152+ elseif arch == " xuantie" then
153+ arch = " risc-v/rv64gc/lp64d"
155154 end
156155
157156 local rtlibdir = path .join (sdkdir , " rt-thread" , " lib" , arch )
@@ -164,6 +163,16 @@ function deploy_syslib(toolchains, rootfs)
164163 local filename = path .filename (filepath )
165164 rt_utils .cp_with_symlink (filepath , path .join (rootfs , " lib" , filename ))
166165 end
166+ end
167+
168+ function deploy_toolchainlib (toolchains , rootfs )
169+ local pkg = project :required_packages ()[toolchains ]
170+
171+ if string .startswith (toolchains , " riscv64" ) then
172+ toolchains = " riscv64-unknown-smart-musl"
173+ end
174+
175+ toolchains = string.gsub (toolchains , " smart" , " linux" ) -- TODO: should replace, when toolchains renamed
167176
168177 for _ , filepath in ipairs (os .files (path .join (pkg :installdir (), toolchains ) .. " /*/lib*.so*" )) do
169178 if path .extension (filepath ) ~= " .py" then
@@ -178,6 +187,31 @@ function deploy_syslib(toolchains, rootfs)
178187 end
179188end
180189
190+ function deploy_xuantietoolchainlib (toolchains , rootfs )
191+ local pkg = project :required_packages ()[toolchains ]
192+ local path_root = " sysroot"
193+ local lib_path = {
194+ " usr/lib64/lp64d" ,
195+ " lib64/lp64d" ,
196+ }
197+
198+ for _ , filepath_lib in ipairs (lib_path ) do
199+ for _ , filepath in ipairs (os .files (path .join (pkg :installdir (), path_root , filepath_lib ) .. " /lib*.so*" )) do
200+ if path .extension (filepath ) ~= " .py" then
201+ local filename = path .filename (filepath )
202+ os .tryrm (path .join (rootfs , " lib" , filename ))
203+ os .vcp (filepath , path .join (rootfs , " lib" , filename ))
204+ end
205+ end
206+ end
207+
208+ for _ , filepath in ipairs (os .files (path .join (pkg :installdir (), path_root ) .. " /*/ld-musl-*.so.*" )) do
209+ local filename = path .filename (filepath )
210+ os .tryrm (path .join (rootfs , " lib" , filename ))
211+ os .vcp (filepath , path .join (rootfs , " lib" , filename ))
212+ end
213+ end
214+
181215function copy_packages ()
182216 local name = option .get (" export" )
183217 if name == " all" then
@@ -216,15 +250,22 @@ function main()
216250 local target = project .targets ()[targetname ]
217251 local toolchains = string.gsub (target :get (" toolchains" ), " @" , " " )
218252 local rootfs = option .get (" output" ) or rt_utils .rootfs_dir ()
219-
253+ local arch = config . arch ()
220254 if (option .get (" no-symlink" )) then
221255 os .setenv (" --rt-xmake-no-symlink" , " true" )
222256 end
223257
224258 create_rootfs (rootfs )
225259 deploy_package (rootfs )
226260 deploy_target (rootfs )
227- deploy_syslib (toolchains , rootfs )
261+ deploy_syslib (rootfs )
262+
263+ if arch == " xuantie" then
264+ deploy_xuantietoolchainlib (toolchains , rootfs )
265+ else
266+ deploy_toolchainlib (toolchains , rootfs )
267+ end
268+
228269
229270 local size = rt_utils .dirsize (rootfs )
230271 cprint (" ${green}> rootfs: %s" , rootfs )
0 commit comments