exe_path.h 734 B

123456789101112131415161718192021
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_COMMON_EXE_PATH_H_
  5. #define CARBON_COMMON_EXE_PATH_H_
  6. #include "llvm/ADT/StringRef.h"
  7. namespace Carbon {
  8. // Computes the executable path for the given `argv[0]` value form `main`.
  9. //
  10. // A simplistic approach -- if the provided string isn't already a valid path,
  11. // we look it up in the PATH environment variable. Doesn't resolve any symlinks
  12. // and if it fails, simply returns the provided `argv0`.
  13. auto FindExecutablePath(llvm::StringRef argv0) -> std::string;
  14. } // namespace Carbon
  15. #endif // CARBON_COMMON_EXE_PATH_H_