Skip to content

Commit

Permalink
BuildConfig: check if project include dir exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Jan 24, 2025
1 parent 4974f68 commit f02e664
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/BuildConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ BuildConfig::init(const Manifest& manifest, const bool isDebug) {
fs::path buildOutPath = outBasePath / (manifest.package.name + ".d");
fs::path unittestOutPath = outBasePath / "unittests";

std::vector<std::string> includes;
fs::path projectIncludePath = projectBasePath / "include";
if (fs::exists(projectIncludePath)) {
includes.push_back("-I" + projectIncludePath.string());
}

std::string cxx;
if (const char* cxxP = std::getenv("CXX")) {
cxx = cxxP;
Expand Down Expand Up @@ -105,7 +111,8 @@ BuildConfig::init(const Manifest& manifest, const bool isDebug) {

return Ok(BuildConfig(
manifest, isDebug, std::move(libName), std::move(outBasePath),
std::move(buildOutPath), std::move(unittestOutPath), std::move(cxx)
std::move(buildOutPath), std::move(unittestOutPath), std::move(cxx),
std::move(includes)
));
}

Expand Down
6 changes: 3 additions & 3 deletions src/BuildConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class BuildConfig {
std::vector<std::string> cxxflags;
std::vector<std::string> ldflags;
std::vector<std::string> defines;
std::vector<std::string> includes = { "-I../../include" };
std::vector<std::string> includes;
std::vector<std::string> libs;

bool isUpToDate(std::string_view fileName) const;
Expand All @@ -87,12 +87,12 @@ class BuildConfig {
explicit BuildConfig(
const Manifest& manifest, bool isDebug, std::string libName,
fs::path outBasePath, fs::path buildOutPath, fs::path unittestOutPath,
std::string cxx
std::string cxx, std::vector<std::string> includes
)
: outBasePath(std::move(outBasePath)), manifest(manifest),
libName(std::move(libName)), buildOutPath(std::move(buildOutPath)),
unittestOutPath(std::move(unittestOutPath)), isDebug(isDebug),
cxx(std::move(cxx)) {}
cxx(std::move(cxx)), includes(std::move(includes)) {}

public:
static Result<BuildConfig>
Expand Down

0 comments on commit f02e664

Please sign in to comment.