From 709bca8d2c59923cd397fc55cdcdb7f80751555d Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 30 Mar 2018 09:41:36 -0700 Subject: 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) --- src/support/path.h | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'src/support/path.h') 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 -- cgit v1.2.3