11add_rules (" mode.debug" , " mode.release" )
2+ -- Define color codes
3+ local GREEN = ' \27 [0;32m'
4+ local YELLOW = ' \27 [1;33m'
5+ local NC = ' \27 [0m' -- No Color
26
37add_includedirs (" include" )
48
@@ -116,7 +120,7 @@ if has_config("cambricon-mlu") then
116120
117121 local includedirs = table.concat (target :get (" includedirs" ), " " )
118122 local args = {" -c" , sourcefile , " -o" , objectfile , " -I/usr/local/neuware/include" , " --bang-mlu-arch=mtp_592" , " -O3" , " -fPIC" , " -Wall" , " -Werror" , " -std=c++17" , " -pthread" }
119-
123+
120124 for _ , includedir in ipairs (target :get (" includedirs" )) do
121125 table.insert (args , " -I" .. includedir )
122126 end
@@ -127,7 +131,6 @@ if has_config("cambricon-mlu") then
127131
128132 rule_end ()
129133
130-
131134 target (" cambricon-mlu" )
132135 set_kind (" static" )
133136 on_install (function (target ) end )
@@ -152,7 +155,7 @@ if has_config("ascend-npu") then
152155 add_links (" libascendcl.so" )
153156 add_links (" libnnopbase.so" )
154157 add_links (" libopapi.so" )
155- add_links (" libruntime.so" )
158+ add_links (" libruntime.so" )
156159 add_linkdirs (ASCEND_HOME .. " /../../driver/lib64/driver" )
157160 add_links (" libascend_hal.so" )
158161 local builddir = string.format (
@@ -169,15 +172,15 @@ if has_config("ascend-npu") then
169172 os .exec (" make" )
170173 os .exec (" cp $(projectdir)/src/devices/ascend/build/lib/libascend_kernels.a " .. builddir .. " /" )
171174 os .cd (os.projectdir ())
172-
175+
173176 end )
174177 after_clean (function ()
175178 local ascend_build_dir = path.join (os.projectdir (), " src/devices/ascend" )
176179 os .cd (ascend_build_dir )
177180 os .exec (" make clean" )
178181 os .cd (os.projectdir ())
179182 os .rm (builddir .. " /libascend_kernels.a" )
180-
183+
181184 end )
182185 rule_end ()
183186
@@ -190,7 +193,7 @@ if has_config("ascend-npu") then
190193 add_files (" src/devices/ascend/*.cc" , " src/ops/*/ascend/*.cc" )
191194 add_cxflags (" -lstdc++ -Wall -Werror -fPIC" )
192195
193- -- Add operator
196+ -- Add operator
194197 add_rules (" ascend-kernels" )
195198 add_links (builddir .. " /libascend_kernels.a" )
196199
@@ -216,64 +219,10 @@ target("infiniop")
216219 add_files (" src/devices/handle.cc" )
217220 add_files (" src/ops/*/operator.cc" )
218221 add_files (" src/tensor/*.cc" )
222+ after_build (function (target ) print (YELLOW .. " You can install the libraries with \" xmake install\" " .. NC ) end )
219223
220- after_build (function (target )
221- local builddir = string.format (
222- " %s/build/%s/%s/%s" ,
223- os.projectdir (),
224- get_config (" plat" ),
225- get_config (" arch" ),
226- get_config (" mode" )
227- )
228-
229- -- Define color codes
230- local GREEN = ' \27 [0;32m'
231- local YELLOW = ' \27 [1;33m'
232- local NC = ' \27 [0m' -- No Color
233-
234- -- Get the current directory
235- local current_dir = os.curdir ()
236-
237- -- Output messages with colors
238- os .exec (" echo -e '" .. GREEN .. " Compilation completed successfully." .. NC .. " '" )
239- os .exec (" echo -e '" .. YELLOW .. " You can install the libraries with \" xmake install\" " .. NC .. " '" )
240- end )
241-
242- on_install (function (target )
243- print (" Installing libraries..." )
244-
245- local GREEN = ' \27 [0;32m'
246- local YELLOW = ' \27 [1;33m'
247- local NC = ' \27 [0m' -- No Color
248-
249- local infini_dir = os.getenv (" INFINI_ROOT" )
250- if infini_dir == nil then
251- print (YELLOW .. " INFINI_ROOT not set, installation path default to ~/.infini" .. NC )
252- print (YELLOW .. " It is recommended to set INFINI_ROOT as an environment variable." .. NC )
253- infini_dir = os.getenv (" HOME" ) .. " /.infini"
254- end
255-
256- if os.isdir (infini_dir ) then
257- print (" INFINI_ROOT already exists, duplicated contents will be overwritten." )
258- else
259- os .mkdir (infini_dir )
260- end
261-
262- local builddir = string.format (
263- " %s/build/%s/%s/%s" ,
264- os.projectdir (),
265- get_config (" plat" ),
266- get_config (" arch" ),
267- get_config (" mode" )
268- )
269- os .exec (" mkdir -p " .. infini_dir .. " /lib" )
270- os .exec (" cp " .. builddir .. " /libinfiniop.so " .. infini_dir .. " /lib/" )
271- os .exec (" cp -r $(projectdir)/include " .. infini_dir .. " /include" )
272-
273- os .exec (" echo -e '" .. GREEN .. " Installation completed successfully at " .. infini_dir .. NC .. " '" )
274- os .exec (" echo -e '" .. YELLOW .. " To set the environment variables, you can run the following command:" .. NC .. " '" )
275- os .exec (" echo -e '" .. YELLOW .. " export INFINI_ROOT=" .. infini_dir .. NC .. " '" )
276- os .exec (" echo -e '" .. YELLOW .. " export LD_LIBRARY_PATH=:$INFINI_ROOT/lib:$LD_LIBRARY_PATH" .. NC .. " '" )
277- end )
224+ set_installdir (os.getenv (" INFINI_ROOT" ) or (os.getenv (is_host (" windows" ) and " HOMEPATH" or " HOME" ) .. " /.infini" ))
225+ add_installfiles (" include/(**/*.h)" , {prefixdir = " include" })
226+ add_installfiles (" include/*.h" , {prefixdir = " include" })
278227
279228target_end ()
0 commit comments