Skip to content

Commit

Permalink
chore: Config has workingDir
Browse files Browse the repository at this point in the history
  • Loading branch information
vinniefalco committed Jun 5, 2023
1 parent 1f9bf64 commit f3694e3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
10 changes: 10 additions & 0 deletions include/mrdox/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ class MRDOX_VISIBLE

//--------------------------------------------

/** Full path to the working directory
The working directory is used to calculate
full paths from relative paths.
This string will always be POSIX style
and have a trailing directory separator.
*/
std::string_view workingDir;

/** A string holding the complete configuration YAML.
*/
std::string_view configYaml;
Expand Down
18 changes: 10 additions & 8 deletions source/ConfigImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,33 @@ namespace mrdox {
Error
ConfigImpl::
construct(
llvm::StringRef workingDir,
llvm::StringRef configYamlStr,
llvm::StringRef extraYamlStr)
llvm::StringRef workingDirArg,
llvm::StringRef configYamlArg,
llvm::StringRef extraYamlArg)
{
namespace fs = llvm::sys::fs;
namespace path = llvm::sys::path;

// calculate working directory
llvm::SmallString<64> s;
if(workingDir.empty())
if(workingDirArg.empty())
{
if(auto ec = fs::current_path(s))
return Error(ec);
}
else
{
s = workingDir;
s = workingDirArg;
}
path::remove_dots(s, true);
makeDirsy(s);
convert_to_slash(s);
workingDir_ = s;
workingDir = std::string_view(
workingDir_.data(), workingDir_.size());

configYamlStr_ = configYamlStr;
extraYamlStr_ = extraYamlStr;
configYamlStr_ = configYamlArg;
extraYamlStr_ = extraYamlArg;

configYaml = configYamlStr_;
extraYaml = extraYamlStr_;
Expand Down Expand Up @@ -138,7 +140,7 @@ normalizedPath(
llvm::SmallString<0> result;
if(! path::is_absolute(pathName))
{
result = workingDir();
result = workingDir;
path::append(result, path::Style::posix, pathName);
path::remove_dots(result, true, path::Style::posix);
}
Expand Down
11 changes: 0 additions & 11 deletions source/ConfigImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ class ConfigImpl
return concurrency_ != 1;
}

/** Return the full path to the working directory.
The returned path will always be POSIX
style and have a trailing separator.
*/
llvm::StringRef
workingDir() const noexcept
{
return workingDir_;
}

/** Return the full path to the source root directory.
The returned path will always be POSIX
Expand Down

0 comments on commit f3694e3

Please sign in to comment.