Skip to content

Commit

Permalink
install as option
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxwellGengYF committed Feb 18, 2025
1 parent b07b8ac commit acaf825
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions scripts/xmake_func.lua
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,20 @@ rule_end()

rule('lc_install_sdk')
on_load(function(target)
local custom_sdk_dir = get_config("sdk_dir")
if custom_sdk_dir and not os.exists(custom_sdk_dir) then
return
end
local packages = import('packages')
local libnames = target:extraconf("rules", "lc_install_sdk", "libnames")
local find_sdk = import('find_sdk')
local enable = true
local sdk_dir = get_config("sdk_dir")
for _, lib in ipairs(libnames) do
local valid = find_sdk.check_file(lib, sdk_dir)
local valid = find_sdk.check_file(lib, custom_sdk_dir)
if not valid then
utils.error("Library: " .. packages.sdks()[lib]['name'] ..
" not installed, run 'xmake lua setup.lua' or download it manually from " ..
packages.sdk_address(packages.sdks()[lib]) .. ' to ' .. packages.sdk_dir(os.arch(), sdk_dir) ..
packages.sdk_address(packages.sdks()[lib]) .. ' to ' .. packages.sdk_dir(os.arch(), custom_sdk_dir) ..
'.')
enable = false
end
Expand All @@ -419,6 +422,10 @@ on_load(function(target)
end
end)
on_clean(function(target)
local custom_sdk_dir = get_config("sdk_dir")
if custom_sdk_dir and not os.exists(custom_sdk_dir) then
return
end
local bin_dir = target:targetdir()
local find_sdk = import('find_sdk')
local packages = import('packages')
Expand All @@ -433,14 +440,18 @@ on_clean(function(target)
end
end)
before_build(function(target)
local custom_sdk_dir = get_config("sdk_dir")
if custom_sdk_dir and not os.exists(custom_sdk_dir) then
return
end
local bin_dir = target:targetdir()
local lib = import('lib')
lib.mkdirs(bin_dir)
local libnames = target:extraconf("rules", "lc_install_sdk", "libnames")
local packages = import('packages')
local find_sdk = import('find_sdk')
local sdks = packages.sdks()
local sdk_dir = packages.sdk_dir(os.arch(), get_config("sdk_dir"))
local sdk_dir = packages.sdk_dir(os.arch(), custom_sdk_dir)
for _, lib in ipairs(libnames) do
local sdk_map = sdks[lib]
local zip = sdk_map['name']
Expand Down

0 comments on commit acaf825

Please sign in to comment.