targetpath.lua 1.1 KB

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