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

See our website: http://pigweed.dev