diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-03-30 09:41:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-30 09:41:36 -0700 |
commit | 709bca8d2c59923cd397fc55cdcdb7f80751555d (patch) | |
tree | 84119269a7ce40c7b51d950097f668249659b8e9 /src/support/path.h | |
parent | 5f61c3208212beaf9e69230f69770ab64c61e06f (diff) | |
download | binaryen-709bca8d2c59923cd397fc55cdcdb7f80751555d.tar.gz binaryen-709bca8d2c59923cd397fc55cdcdb7f80751555d.tar.bz2 binaryen-709bca8d2c59923cd397fc55cdcdb7f80751555d.zip |
refactor Path utils: store the bin/ dir so that all users of the API can use it by the standard calls, even if it was modified by user input (move it out of just being in wasm-reduce.cpp) (#1489)
Diffstat (limited to 'src/support/path.h')
-rw-r--r-- | src/support/path.h | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/src/support/path.h b/src/support/path.h index 5852fcc4d..505ba0d88 100644 --- a/src/support/path.h +++ b/src/support/path.h @@ -28,30 +28,19 @@ namespace wasm { namespace Path { -inline std::string getPathSeparator() { - // TODO: use c++17's path separator - // http://en.cppreference.com/w/cpp/experimental/fs/path -#if defined(WIN32) || defined(_WIN32) - return "\\"; -#else - return "/"; -#endif -} - -inline std::string getBinaryenRoot() { - auto* envVar = getenv("BINARYEN_ROOT"); - if (envVar) return envVar; - return "."; -} - -inline std::string getBinaryenBinDir() { - return getBinaryenRoot() + getPathSeparator() + "bin" + getPathSeparator(); -} - -// Gets the path to a binaryen binary tool, like wasm-opt -inline std::string getBinaryenBinaryTool(std::string name) { - return getBinaryenBinDir() + name; -} +std::string getPathSeparator(); + +// Get the binaryen root dor. +std::string getBinaryenRoot(); + +// Get the binaryen bin dir. +std::string getBinaryenBinDir(); + +// Set the binaryen bin dir (allows tools to change it based on user input). +void setBinaryenBinDir(std::string dir); + +// Gets the path to a binaryen binary tool, like wasm-opt. +std::string getBinaryenBinaryTool(std::string name); } // namespace Path |