xmake.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package("houdini")
  2. set_homepage("https://www.sidefx.com/")
  3. set_description("Houdini is built from the ground up to be a procedural system that empowers artists to work freely, create multiple iterations and rapidly share workflows with colleagues.")
  4. on_fetch(function (package, opt)
  5. if opt.system then
  6. import("lib.detect.find_path")
  7. import("lib.detect.find_program")
  8. import("lib.detect.find_library")
  9. -- init search paths
  10. local paths = {"$(env Houdini_ROOT)"}
  11. if package:is_plat("windows") then
  12. local keys = winos.registry_keys("HKEY_LOCAL_MACHINE\\SOFTWARE\\Side Effects Software\\Houdini *.*.*")
  13. for _, key in ipairs(keys) do
  14. table.insert(paths, winos.registry_query(key .. ";InstallPath"))
  15. end
  16. elseif package:is_plat("macosx") then
  17. for _, path in ipairs(os.dirs("/Applications/Houdini/Houdini*.*.*")) do
  18. table.insert(paths, path)
  19. end
  20. else
  21. for _, path in ipairs(os.dirs("/opt/hfs*.*.*")) do
  22. table.insert(paths, path)
  23. end
  24. end
  25. -- find sdkdir
  26. local result = {sdkdir = nil, links = {}, linkdirs = {}, includedirs = {}, libfiles = {}}
  27. result.sdkdir = find_path("houdini_setup", paths)
  28. if result.sdkdir then
  29. package:addenv("PATH", path.join(result.sdkdir, "bin"))
  30. else
  31. local prog = find_program("houdini", {paths = os.getenv("PATH")})
  32. if prog then
  33. result.sdkdir = path.directory(path.directory(prog))
  34. else
  35. return
  36. end
  37. end
  38. -- find library
  39. local prefix = (package:is_plat("windows") and "lib" or "")
  40. local libs = {"HAPI"}
  41. for _, lib in ipairs(libs) do
  42. local libname = prefix .. lib
  43. local linkinfo = find_library(libname, {result.sdkdir}, {suffixes = "custom/houdini/dsolib"})
  44. if linkinfo then
  45. table.insert(result.linkdirs, linkinfo.linkdir)
  46. table.insert(result.links, libname)
  47. if package:is_plat("windows") then
  48. table.insert(result.libfiles, path.join(linkinfo.linkdir, libname .. ".lib"))
  49. table.insert(result.libfiles, path.join(result.sdkdir, "bin", libname .. ".dll"))
  50. end
  51. end
  52. end
  53. -- find headers
  54. local path = find_path(path.join("HAPI", "HAPI.h"), {result.sdkdir}, {suffixes = path.join("toolkit", "include")})
  55. if path then
  56. table.insert(result.includedirs, path)
  57. end
  58. if #result.includedirs > 0 and #result.linkdirs > 0 then
  59. return result
  60. end
  61. end
  62. end)