tsc.gni 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import("npm.gni")
  2. template("typescript_build") {
  3. assert(defined(invoker.tsconfig), "Need tsconfig name to run")
  4. assert(defined(invoker.sources), "Need tsc sources to run")
  5. assert(defined(invoker.output_dir_name),
  6. "Need output_dir_name to run, should be 'lib' or other top level dir")
  7. assert(defined(invoker.output_gen_dir),
  8. "Need output_gen_dir to run, should be relative to the root gen dir")
  9. npm_action(target_name) {
  10. forward_variables_from(invoker,
  11. [
  12. "deps",
  13. "public_deps",
  14. "outputs",
  15. ])
  16. script = "tsc"
  17. sources = invoker.sources
  18. inputs = [
  19. invoker.tsconfig,
  20. "//electron/tsconfig.json",
  21. "//electron/yarn.lock",
  22. "//electron/typings/internal-ambient.d.ts",
  23. "//electron/typings/internal-electron.d.ts",
  24. ]
  25. base_out_path = invoker.output_gen_dir + "/electron/"
  26. args = [
  27. "-p",
  28. rebase_path(invoker.tsconfig),
  29. "--outDir",
  30. rebase_path("$base_out_path" + invoker.output_dir_name),
  31. ]
  32. outputs = []
  33. foreach(invoker_source, invoker.sources) {
  34. # The output of TSC is all inputs but with JS instead of TS as the extension
  35. outputs += [ "$base_out_path" + get_path_info(invoker_source, "dir") +
  36. "/" + get_path_info(invoker_source, "name") + ".js" ]
  37. }
  38. }
  39. }