Remove absolute paths from build command lines

The GN convention is to specify paths in command lines relative to the
build directory. Unfortunately and contrary to pigweed's expectations
this is not what rebase_path(path) does; that outputs an absolute path.

Absolute paths are not desirable in most circumstances as they contain
sources of nondeterminism such as the developer's home directory. Using
them can for example reduce hit rate in build caches.

Replace rebase_path(path) with rebase_path(path, root_build_dir) which
is the correct idiom and matches GN's builtin behavior (e.g. for
sources, include_dirs, etc).

This also removes the --directory argument to python_action(). Changing
the directory during the build while using relative paths is likely to
result in confusion and should be discouraged.

There's a couple more things to do on top of this for identical
binaries between build directories / machines / developers:

- pass options to avoid embedding the working directory
- pass options to use relative paths for the vendored clang & libc++

See [1]-[2] for how to do that.

[1] https://source.chromium.org/chromium/chromium/src/+/main:build/config/compiler/BUILD.gn;l=1170-1239;drc=ab531c265c533cba1c2f6d8240cc0bf7679f605a
[2] https://cs.opensource.google/fuchsia/fuchsia/+/main:build/config/BUILD.gn;l=145-216;drc=f6d705f0937c778d5d5f807a4580113612b02f5a

Change-Id: I17708102c03d6488d68c8571b6e9343191fd47de
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/47461
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Michael Spang <spang@google.com>
34 files changed
tree: 647946d28774fd85692927435dc6e6ebc128ae6d
  1. .bazelignore
  2. .bazelrc
  3. .clang-format
  4. .eslintrc.json
  5. .gitattributes
  6. .gitignore
  7. .gn
  8. .prettierrc.js
  9. .pylintrc
  10. AUTHORS
  11. BUILD
  12. BUILD.gn
  13. BUILDCONFIG.gn
  14. CMakeLists.txt
  15. LICENSE
  16. OWNERS
  17. PW_PLUGINS
  18. README.md
  19. WORKSPACE
  20. activate.bat
  21. bootstrap.bat
  22. bootstrap.sh
  23. build_overrides/
  24. docker/
  25. docs/
  26. modules.gni
  27. package.json
  28. pw_allocator/
  29. pw_analog/
  30. pw_arduino_build/
  31. pw_assert/
  32. pw_assert_basic/
  33. pw_assert_log/
  34. pw_base64/
  35. pw_bloat/
  36. pw_blob_store/
  37. pw_boot_armv7m/
  38. pw_build/
  39. pw_bytes/
  40. pw_checksum/
  41. pw_chrono/
  42. pw_chrono_embos/
  43. pw_chrono_freertos/
  44. pw_chrono_stl/
  45. pw_chrono_threadx/
  46. pw_cli/
  47. pw_containers/
  48. pw_cpu_exception/
  49. pw_cpu_exception_cortex_m/
  50. pw_docgen/
  51. pw_doctor/
  52. pw_env_setup/
  53. pw_function/
  54. pw_fuzzer/
  55. pw_hdlc/
  56. pw_hex_dump/
  57. pw_i2c/
  58. pw_interrupt/
  59. pw_interrupt_cortex_m/
  60. pw_kvs/
  61. pw_libc/
  62. pw_log/
  63. pw_log_basic/
  64. pw_log_multisink/
  65. pw_log_null/
  66. pw_log_rpc/
  67. pw_log_sink/
  68. pw_log_tokenized/
  69. pw_malloc/
  70. pw_malloc_freelist/
  71. pw_metric/
  72. pw_minimal_cpp_stdlib/
  73. pw_module/
  74. pw_multisink/
  75. pw_package/
  76. pw_persistent_ram/
  77. pw_polyfill/
  78. pw_preprocessor/
  79. pw_presubmit/
  80. pw_protobuf/
  81. pw_protobuf_compiler/
  82. pw_random/
  83. pw_result/
  84. pw_ring_buffer/
  85. pw_router/
  86. pw_rpc/
  87. pw_snapshot/
  88. pw_span/
  89. pw_status/
  90. pw_stm32cube_build/
  91. pw_stream/
  92. pw_string/
  93. pw_sync/
  94. pw_sync_baremetal/
  95. pw_sync_embos/
  96. pw_sync_freertos/
  97. pw_sync_stl/
  98. pw_sync_threadx/
  99. pw_sys_io/
  100. pw_sys_io_arduino/
  101. pw_sys_io_baremetal_lm3s6965evb/
  102. pw_sys_io_baremetal_stm32f429/
  103. pw_sys_io_stdio/
  104. pw_target_runner/
  105. pw_thread/
  106. pw_thread_embos/
  107. pw_thread_freertos/
  108. pw_thread_stl/
  109. pw_thread_threadx/
  110. pw_tokenizer/
  111. pw_tool/
  112. pw_toolchain/
  113. pw_trace/
  114. pw_trace_tokenized/
  115. pw_unit_test/
  116. pw_varint/
  117. pw_watch/
  118. pw_web_ui/
  119. targets/
  120. third_party/
  121. tsconfig.json
  122. yarn.lock
README.md

See our website: http://pigweed.dev