mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 16:11:08 +03:00
Add -Xcpp CLI option for C preprocessor flags (-P with ldmd2)
This commit is contained in:
parent
5b137768a0
commit
1bf7e28c59
5 changed files with 23 additions and 13 deletions
|
@ -400,13 +400,15 @@ cl::list<std::string>
|
||||||
cl::value_desc("linkerflag"), cl::cat(linkingCategory),
|
cl::value_desc("linkerflag"), cl::cat(linkingCategory),
|
||||||
cl::Prefix);
|
cl::Prefix);
|
||||||
|
|
||||||
cl::list<std::string>
|
cl::list<std::string> ccSwitches(
|
||||||
ccSwitches("Xcc", cl::desc("Pass <ccflag> to GCC/Clang for linking"),
|
"Xcc", cl::value_desc("ccflag"), cl::cat(linkingCategory),
|
||||||
cl::value_desc("ccflag"), cl::cat(linkingCategory));
|
cl::desc("Pass <ccflag> to GCC/Clang for linking/preprocessing"));
|
||||||
|
|
||||||
cl::opt<std::string>
|
cl::list<std::string> cppSwitches("Xcpp", cl::value_desc("cppflag"),
|
||||||
moduleDeps("deps", cl::ValueOptional, cl::ZeroOrMore,
|
cl::desc("Pass <cppflag> to C preprocessor"));
|
||||||
cl::value_desc("filename"),
|
|
||||||
|
cl::opt<std::string> moduleDeps(
|
||||||
|
"deps", cl::ValueOptional, cl::ZeroOrMore, cl::value_desc("filename"),
|
||||||
cl::desc("Write module dependencies to <filename> (only imports). "
|
cl::desc("Write module dependencies to <filename> (only imports). "
|
||||||
"'-deps' alone prints module dependencies "
|
"'-deps' alone prints module dependencies "
|
||||||
"(imports/file/version/debug/lib)"));
|
"(imports/file/version/debug/lib)"));
|
||||||
|
|
|
@ -75,6 +75,7 @@ extern cl::opt<std::string> makeDeps;
|
||||||
extern cl::opt<std::string> cacheDir;
|
extern cl::opt<std::string> cacheDir;
|
||||||
extern cl::list<std::string> linkerSwitches;
|
extern cl::list<std::string> linkerSwitches;
|
||||||
extern cl::list<std::string> ccSwitches;
|
extern cl::list<std::string> ccSwitches;
|
||||||
|
extern cl::list<std::string> cppSwitches;
|
||||||
extern cl::list<std::string> includeModulePatterns;
|
extern cl::list<std::string> includeModulePatterns;
|
||||||
|
|
||||||
extern cl::opt<bool> m32bits;
|
extern cl::opt<bool> m32bits;
|
||||||
|
|
|
@ -46,7 +46,9 @@ FileName runCPreprocessor(FileName csrcfile, const Loc &loc, bool &ifile,
|
||||||
for (const auto &ccSwitch : opts::ccSwitches) {
|
for (const auto &ccSwitch : opts::ccSwitches) {
|
||||||
args.push_back(ccSwitch);
|
args.push_back(ccSwitch);
|
||||||
}
|
}
|
||||||
// TODO: -Xcpp switches?
|
for (const auto &cppSwitch : opts::cppSwitches) {
|
||||||
|
args.push_back(cppSwitch);
|
||||||
|
}
|
||||||
|
|
||||||
if (isMSVC) {
|
if (isMSVC) {
|
||||||
args.push_back("/P"); // run preprocessor
|
args.push_back("/P"); // run preprocessor
|
||||||
|
|
|
@ -234,7 +234,9 @@ Where:\n\
|
||||||
#if 0
|
#if 0
|
||||||
" -os=<os> sets target operating system to <os>\n"
|
" -os=<os> sets target operating system to <os>\n"
|
||||||
#endif
|
#endif
|
||||||
" -preview=<name> enable an upcoming language change identified by 'name'\n\
|
" -P=<preprocessorflag>\n\
|
||||||
|
pass preprocessorflag to C preprocessor\n\
|
||||||
|
-preview=<name> enable an upcoming language change identified by 'name'\n\
|
||||||
-preview=[h|help|?]\n\
|
-preview=[h|help|?]\n\
|
||||||
list all upcoming language changes\n\
|
list all upcoming language changes\n\
|
||||||
-profile profile runtime performance of generated code\n"
|
-profile profile runtime performance of generated code\n"
|
||||||
|
@ -707,7 +709,11 @@ void translateArgs(const llvm::SmallVectorImpl<const char *> &ldmdArgs,
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
/* -L
|
/* -L
|
||||||
* -defaultlib
|
*/
|
||||||
|
else if (p[1] == 'P') {
|
||||||
|
ldcArgs.push_back(concat("-Xcpp=", p + 2 + (p[2] == '=' ? 1 : 0)));
|
||||||
|
}
|
||||||
|
/* -defaultlib
|
||||||
* -debuglib
|
* -debuglib
|
||||||
* -deps
|
* -deps
|
||||||
* -main
|
* -main
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
/* REQUIRED_ARGS: -P=-DABC=3
|
/* REQUIRED_ARGS: -P=-DABC=3
|
||||||
*/
|
*/
|
||||||
// DISABLED: LDC // FIXME
|
|
||||||
|
|
||||||
_Static_assert(ABC == 3, "1");
|
_Static_assert(ABC == 3, "1");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue