24
24
#include " llvm/Config/config.h"
25
25
#include " llvm/Support/FileSystem.h"
26
26
#include " llvm/Support/Path.h"
27
- #include " llvm/Support/Program.h"
28
27
#include " llvm/Support/WithColor.h"
29
28
#include " llvm/Support/raw_ostream.h"
30
29
#include " llvm/TargetParser/Triple.h"
@@ -327,7 +326,7 @@ int main(int argc, char **argv) {
327
326
// information.
328
327
std::string ActivePrefix, ActiveBinDir, ActiveIncludeDir, ActiveLibDir,
329
328
ActiveCMakeDir;
330
- std::vector<std:: string> ActiveIncludeOptions ;
329
+ std::string ActiveIncludeOption ;
331
330
if (IsInDevelopmentTree) {
332
331
ActiveIncludeDir = std::string (LLVM_SRC_ROOT) + " /include" ;
333
332
ActivePrefix = CurrentExecPrefix;
@@ -353,8 +352,8 @@ int main(int argc, char **argv) {
353
352
}
354
353
355
354
// We need to include files from both the source and object trees.
356
- ActiveIncludeOptions. push_back (ActiveIncludeDir);
357
- ActiveIncludeOptions. push_back ( ActiveObjRoot + " /include" );
355
+ ActiveIncludeOption =
356
+ ( " -I " + ActiveIncludeDir + " " + " -I " + ActiveObjRoot + " /include" );
358
357
} else {
359
358
ActivePrefix = CurrentExecPrefix;
360
359
{
@@ -373,7 +372,7 @@ int main(int argc, char **argv) {
373
372
sys::fs::make_absolute (ActivePrefix, Path);
374
373
ActiveCMakeDir = std::string (Path);
375
374
}
376
- ActiveIncludeOptions. push_back ( ActiveIncludeDir) ;
375
+ ActiveIncludeOption = " -I " + ActiveIncludeDir;
377
376
}
378
377
379
378
// / We only use `shared library` mode in cases where the static library form
@@ -402,8 +401,8 @@ int main(int argc, char **argv) {
402
401
std::replace (ActiveBinDir.begin (), ActiveBinDir.end (), ' /' , ' \\ ' );
403
402
std::replace (ActiveLibDir.begin (), ActiveLibDir.end (), ' /' , ' \\ ' );
404
403
std::replace (ActiveCMakeDir.begin (), ActiveCMakeDir.end (), ' /' , ' \\ ' );
405
- for ( auto &Include : ActiveIncludeOptions)
406
- std::replace (Include. begin (), Include. end (), ' / ' , ' \\ ' );
404
+ std::replace (ActiveIncludeOption. begin (), ActiveIncludeOption. end (), ' / ' ,
405
+ ' \\ ' );
407
406
}
408
407
SharedDir = ActiveBinDir;
409
408
StaticDir = ActiveLibDir;
@@ -505,20 +504,6 @@ int main(int argc, char **argv) {
505
504
};
506
505
507
506
raw_ostream &OS = outs ();
508
-
509
- // Render include paths and associated flags
510
- auto RenderFlags = [&](StringRef Flags) {
511
- bool First = true ;
512
- for (auto &Include : ActiveIncludeOptions) {
513
- if (!First)
514
- OS << ' ' ;
515
- OS << " -I" ;
516
- sys::printArg (OS, Include, /* Quote=*/ true );
517
- First = false ;
518
- }
519
- OS << ' ' << Flags << ' \n ' ;
520
- };
521
-
522
507
for (int i = 1 ; i != argc; ++i) {
523
508
StringRef Arg = argv[i];
524
509
@@ -527,30 +512,24 @@ int main(int argc, char **argv) {
527
512
if (Arg == " --version" ) {
528
513
OS << PACKAGE_VERSION << ' \n ' ;
529
514
} else if (Arg == " --prefix" ) {
530
- sys::printArg (OS, ActivePrefix, /* Quote=*/ true );
531
- OS << ' \n ' ;
515
+ OS << ActivePrefix << ' \n ' ;
532
516
} else if (Arg == " --bindir" ) {
533
- sys::printArg (OS, ActiveBinDir, /* Quote=*/ true );
534
- OS << ' \n ' ;
517
+ OS << ActiveBinDir << ' \n ' ;
535
518
} else if (Arg == " --includedir" ) {
536
- sys::printArg (OS, ActiveIncludeDir, /* Quote=*/ true );
537
- OS << ' \n ' ;
519
+ OS << ActiveIncludeDir << ' \n ' ;
538
520
} else if (Arg == " --libdir" ) {
539
- sys::printArg (OS, ActiveLibDir, /* Quote=*/ true );
540
- OS << ' \n ' ;
521
+ OS << ActiveLibDir << ' \n ' ;
541
522
} else if (Arg == " --cmakedir" ) {
542
- sys::printArg (OS, ActiveCMakeDir, /* Quote=*/ true );
543
- OS << ' \n ' ;
523
+ OS << ActiveCMakeDir << ' \n ' ;
544
524
} else if (Arg == " --cppflags" ) {
545
- RenderFlags ( LLVM_CPPFLAGS) ;
525
+ OS << ActiveIncludeOption << ' ' << LLVM_CPPFLAGS << ' \n ' ;
546
526
} else if (Arg == " --cflags" ) {
547
- RenderFlags ( LLVM_CFLAGS) ;
527
+ OS << ActiveIncludeOption << ' ' << LLVM_CFLAGS << ' \n ' ;
548
528
} else if (Arg == " --cxxflags" ) {
549
- RenderFlags ( LLVM_CXXFLAGS) ;
529
+ OS << ActiveIncludeOption << ' ' << LLVM_CXXFLAGS << ' \n ' ;
550
530
} else if (Arg == " --ldflags" ) {
551
- OS << ((HostTriple.isWindowsMSVCEnvironment ()) ? " -LIBPATH:" : " -L" );
552
- sys::printArg (OS, ActiveLibDir, /* Quote=*/ true );
553
- OS << ' ' << LLVM_LDFLAGS << ' \n ' ;
531
+ OS << ((HostTriple.isWindowsMSVCEnvironment ()) ? " -LIBPATH:" : " -L" )
532
+ << ActiveLibDir << ' ' << LLVM_LDFLAGS << ' \n ' ;
554
533
} else if (Arg == " --system-libs" ) {
555
534
PrintSystemLibs = true ;
556
535
} else if (Arg == " --libs" ) {
@@ -611,8 +590,7 @@ int main(int argc, char **argv) {
611
590
} else if (Arg == " --shared-mode" ) {
612
591
PrintSharedMode = true ;
613
592
} else if (Arg == " --obj-root" ) {
614
- sys::printArg (OS, ActivePrefix, /* Quote=*/ true );
615
- OS << ' \n ' ;
593
+ OS << ActivePrefix << ' \n ' ;
616
594
} else if (Arg == " --ignore-libllvm" ) {
617
595
LinkDyLib = false ;
618
596
LinkMode = BuiltSharedLibs ? LinkModeShared : LinkModeAuto;
@@ -717,30 +695,26 @@ int main(int argc, char **argv) {
717
695
718
696
auto PrintForLib = [&](const StringRef &Lib) {
719
697
const bool Shared = LinkMode == LinkModeShared;
720
- std::string LibFileName;
721
698
if (PrintLibNames) {
722
- LibFileName = GetComponentLibraryFileName (Lib, Shared);
699
+ OS << GetComponentLibraryFileName (Lib, Shared);
723
700
} else if (PrintLibFiles) {
724
- LibFileName = GetComponentLibraryPath (Lib, Shared);
701
+ OS << GetComponentLibraryPath (Lib, Shared);
725
702
} else if (PrintLibs) {
726
703
// On Windows, output full path to library without parameters.
727
704
// Elsewhere, if this is a typical library name, include it using -l.
728
705
if (HostTriple.isWindowsMSVCEnvironment ()) {
729
- LibFileName = GetComponentLibraryPath (Lib, Shared);
706
+ OS << GetComponentLibraryPath (Lib, Shared);
730
707
} else {
731
- OS << " -l" ;
732
708
StringRef LibName;
733
709
if (GetComponentLibraryNameSlice (Lib, LibName)) {
734
710
// Extract library name (remove prefix and suffix).
735
- LibFileName = LibName;
711
+ OS << " -l " << LibName;
736
712
} else {
737
713
// Lib is already a library name without prefix and suffix.
738
- LibFileName = Lib;
714
+ OS << " -l " << Lib;
739
715
}
740
716
}
741
717
}
742
- if (!LibFileName.empty ())
743
- sys::printArg (OS, LibFileName, /* Quote=*/ true );
744
718
};
745
719
746
720
if (LinkMode == LinkModeShared && LinkDyLib) {
0 commit comments