commit
21ed11b700
5 changed files with 32 additions and 4 deletions
|
|
@ -74,6 +74,13 @@ public:
|
|||
do_set_flags(standard, flags);
|
||||
}
|
||||
|
||||
/// \effects Enables an `-fXXX` flag.
|
||||
/// \returns Whether or not it was a known feature and enabled.
|
||||
bool enable_feature(std::string name)
|
||||
{
|
||||
return do_enable_feature(name);
|
||||
}
|
||||
|
||||
/// \effects Adds the given path to the set of include directories.
|
||||
void add_include_dir(std::string path)
|
||||
{
|
||||
|
|
@ -121,6 +128,14 @@ private:
|
|||
/// \effects Sets the given C++ standard and compilation flags.
|
||||
virtual void do_set_flags(cpp_standard standard, compile_flags flags) = 0;
|
||||
|
||||
/// \effects Sets the given feature flags.
|
||||
/// \returns Whether or not it was a known feature and set.
|
||||
virtual bool do_enable_feature(std::string name)
|
||||
{
|
||||
(void)name;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// \effects Adds the given path to the set of include directories.
|
||||
virtual void do_add_include_dir(std::string path) = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -157,6 +157,8 @@ public:
|
|||
private:
|
||||
void do_set_flags(cpp_standard standard, compile_flags flags) override;
|
||||
|
||||
bool do_enable_feature(std::string name) override;
|
||||
|
||||
void do_add_include_dir(std::string path) override;
|
||||
|
||||
void do_add_macro_definition(std::string name, std::string definition) override;
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ libclang_compile_config::libclang_compile_config(const libclang_compilation_data
|
|||
else if (flag == "-std")
|
||||
// standard
|
||||
add_flag(std::move(flag) + "=" + std::move(args));
|
||||
else if (flag == "-f" && (args == "ms-compatibility" || args == "ms-extensions"))
|
||||
else if (flag == "-f")
|
||||
// other options
|
||||
add_flag(std::move(flag) + std::move(args));
|
||||
});
|
||||
|
|
@ -386,6 +386,12 @@ void libclang_compile_config::do_set_flags(cpp_standard standard, compile_flags
|
|||
add_flag("-fms-extensions");
|
||||
}
|
||||
|
||||
bool libclang_compile_config::do_enable_feature(std::string name)
|
||||
{
|
||||
add_flag("-f" + std::move(name));
|
||||
return true;
|
||||
}
|
||||
|
||||
void libclang_compile_config::do_add_include_dir(std::string path)
|
||||
{
|
||||
add_flag("-I" + std::move(path));
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ TEST_CASE("libclang_compile_config")
|
|||
},
|
||||
{
|
||||
"directory": "",
|
||||
"command": "/usr/bin/clang++ -std=c++14 -fms-extensions -fms-compatibility -c -o c.o c.cpp",
|
||||
"command": "/usr/bin/clang++ -std=c++14 -fms-extensions -fms-compatibility -fno-strict-aliasing -c -o c.o c.cpp",
|
||||
"file": "C:/c.cpp",
|
||||
}
|
||||
])";
|
||||
|
|
@ -84,7 +84,7 @@ TEST_CASE("libclang_compile_config")
|
|||
},
|
||||
{
|
||||
"directory": "",
|
||||
"command": "/usr/bin/clang++ -std=c++14 -fms-extensions -fms-compatibility -c -o c.o c.cpp",
|
||||
"command": "/usr/bin/clang++ -std=c++14 -fms-extensions -fms-compatibility -fno-strict-aliasing -c -o c.o c.cpp",
|
||||
"file": "/c.cpp",
|
||||
}
|
||||
])";
|
||||
|
|
@ -104,5 +104,5 @@ TEST_CASE("libclang_compile_config")
|
|||
"/absolute -DB(X)=X");
|
||||
|
||||
libclang_compile_config c(database, CPPAST_DETAIL_DRIVE "/c.cpp");
|
||||
require_flags(c, "-std=c++14 -fms-extensions -fms-compatibility");
|
||||
require_flags(c, "-std=c++14 -fms-extensions -fms-compatibility -fno-strict-aliasing");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,6 +207,8 @@ int main(int argc, char* argv[]) try
|
|||
cxxopts::value<std::vector<std::string>>())
|
||||
("U,macro_undefinition", "undefine a macro on the command line",
|
||||
cxxopts::value<std::vector<std::string>>())
|
||||
("f,feature", "enable a custom feature (-fXX flag)",
|
||||
cxxopts::value<std::vector<std::string>>())
|
||||
("gnu_extensions", "enable GNU extensions (equivalent to -std=gnu++XX)")
|
||||
("msvc_extensions", "enable MSVC extensions (equivalent to -fms-extensions)")
|
||||
("msvc_compatibility", "enable MSVC compatibility (equivalent to -fms-compatibility)")
|
||||
|
|
@ -275,6 +277,9 @@ int main(int argc, char* argv[]) try
|
|||
if (options.count("macro_undefinition"))
|
||||
for (auto& name : options["macro_undefinition"].as<std::vector<std::string>>())
|
||||
config.undefine_macro(name);
|
||||
if (options.count("feature"))
|
||||
for (auto& name : options["feature"].as<std::vector<std::string>>())
|
||||
config.enable_feature(name);
|
||||
|
||||
// the compile_flags are generic flags
|
||||
cppast::compile_flags flags;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue