target_rundir.lua 940 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. -- imports
  2. import("core.project.config")
  3. import("core.project.project")
  4. -- main entry
  5. function main (targetname)
  6. -- load config
  7. config.load()
  8. if not os.isfile(os.projectfile()) then
  9. return
  10. end
  11. -- get target
  12. local target = nil
  13. if targetname then
  14. target = project.target(targetname)
  15. end
  16. if not target then
  17. for _, t in pairs(project.targets()) do
  18. local default = t:get("default")
  19. if (default == nil or default == true) and t:get("kind") == "binary" then
  20. target = t
  21. break
  22. end
  23. end
  24. end
  25. -- denote the start of vscode information to ignore anything logging to stdout before this point
  26. print("__begin__")
  27. -- get run directory
  28. if target then
  29. print(path.absolute(target:rundir()))
  30. end
  31. -- print end tag to ignore other deprecated/warnings infos
  32. print("__end__")
  33. end