MCPcopy Create free account
hub / github.com/Kitware/CMake / ExecuteLinkScript

Method ExecuteLinkScript

Source/cmcmd.cxx:2611–2690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2609}
2610
2611int cmcmd::ExecuteLinkScript(std::vector<std::string> const& args)
2612{
2613 // The arguments are
2614 // args[0] == <cmake-executable>
2615 // args[1] == cmake_link_script
2616 // args[2] == <link-script-name>
2617 // args[3] == --verbose=?
2618 bool verbose = false;
2619 if (args.size() >= 4) {
2620 if (cmHasLiteralPrefix(args[3], "--verbose=")) {
2621 if (!cmIsOff(args[3].substr(10))) {
2622 verbose = true;
2623 }
2624 }
2625 }
2626
2627 // Read command lines from the script.
2628 cmsys::ifstream fin(args[2].c_str());
2629 if (!fin) {
2630 std::cerr << "Error opening link script \"" << args[2] << "\"\n";
2631 return 1;
2632 }
2633
2634 // Run one command at a time.
2635 std::string command;
2636 int result = 0;
2637 while (result == 0 && cmSystemTools::GetLineFromStream(fin, command)) {
2638 // Skip empty command lines.
2639 if (command.find_first_not_of(" \t") == std::string::npos) {
2640 continue;
2641 }
2642
2643 // Allocate a process instance.
2644 cmUVProcessChainBuilder builder;
2645
2646 // Children should share stdout and stderr with this process.
2647 builder.SetExternalStream(cmUVProcessChainBuilder::Stream_OUTPUT, stdout)
2648 .SetExternalStream(cmUVProcessChainBuilder::Stream_ERROR, stderr);
2649
2650 // Setup this command line.
2651 std::vector<std::string> args2;
2652#ifdef _WIN32
2653 cmSystemTools::ParseWindowsCommandLine(command.c_str(), args2);
2654#else
2655 cmSystemTools::ParseUnixCommandLine(command.c_str(), args2);
2656#endif
2657 builder.AddCommand(args2);
2658
2659 // Report the command if verbose output is enabled.
2660 if (verbose) {
2661 std::cout << command << '\n';
2662 }
2663
2664 // Run the command and wait for it to exit.
2665 auto chain = builder.Start();
2666 chain.Wait();
2667
2668 // Report failure if any.

Callers

nothing calls this directly

Calls 11

cmHasLiteralPrefixFunction · 0.85
cmIsOffFunction · 0.85
c_strMethod · 0.80
find_first_not_ofMethod · 0.80
GetStatusMethod · 0.80
GetExceptionMethod · 0.80
sizeMethod · 0.45
substrMethod · 0.45
AddCommandMethod · 0.45
StartMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected