mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
StdIo: Replace uses of KWSys ConsoleBuf with StdIo::Console
Issue: #26924
This commit is contained in:
@@ -24,7 +24,6 @@
|
|||||||
#include "cmCPackGeneratorFactory.h"
|
#include "cmCPackGeneratorFactory.h"
|
||||||
#include "cmCPackLog.h"
|
#include "cmCPackLog.h"
|
||||||
#include "cmCommandLineArgument.h"
|
#include "cmCommandLineArgument.h"
|
||||||
#include "cmConsoleBuf.h"
|
|
||||||
#include "cmDocumentation.h"
|
#include "cmDocumentation.h"
|
||||||
#include "cmDocumentationEntry.h"
|
#include "cmDocumentationEntry.h"
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
@@ -33,6 +32,7 @@
|
|||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmState.h"
|
#include "cmState.h"
|
||||||
#include "cmStateSnapshot.h"
|
#include "cmStateSnapshot.h"
|
||||||
|
#include "cmStdIoConsole.h"
|
||||||
#include "cmStdIoInit.h"
|
#include "cmStdIoInit.h"
|
||||||
#include "cmStringAlgorithms.h"
|
#include "cmStringAlgorithms.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
@@ -92,9 +92,7 @@ int main(int argc, char const* const* argv)
|
|||||||
{
|
{
|
||||||
cm::StdIo::Init();
|
cm::StdIo::Init();
|
||||||
|
|
||||||
// Replace streambuf so we can output Unicode to console
|
cm::StdIo::Console console;
|
||||||
cmConsoleBuf consoleBuf;
|
|
||||||
consoleBuf.SetUTF8Pipes();
|
|
||||||
|
|
||||||
cmsys::Encoding::CommandLineArguments args =
|
cmsys::Encoding::CommandLineArguments args =
|
||||||
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <cm/memory>
|
|
||||||
#include <cm/optional>
|
#include <cm/optional>
|
||||||
#include <cmext/algorithm>
|
#include <cmext/algorithm>
|
||||||
|
|
||||||
@@ -24,7 +23,6 @@
|
|||||||
|
|
||||||
#include "cmBuildOptions.h"
|
#include "cmBuildOptions.h"
|
||||||
#include "cmCommandLineArgument.h"
|
#include "cmCommandLineArgument.h"
|
||||||
#include "cmConsoleBuf.h"
|
|
||||||
#include "cmDocumentationEntry.h"
|
#include "cmDocumentationEntry.h"
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
#include "cmInstallScriptHandler.h"
|
#include "cmInstallScriptHandler.h"
|
||||||
@@ -35,6 +33,7 @@
|
|||||||
#include "cmMessageMetadata.h"
|
#include "cmMessageMetadata.h"
|
||||||
#include "cmState.h"
|
#include "cmState.h"
|
||||||
#include "cmStateTypes.h"
|
#include "cmStateTypes.h"
|
||||||
|
#include "cmStdIoConsole.h"
|
||||||
#include "cmStdIoInit.h"
|
#include "cmStdIoInit.h"
|
||||||
#include "cmStringAlgorithms.h"
|
#include "cmStringAlgorithms.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
@@ -139,13 +138,13 @@ cmDocumentationEntry const cmDocumentationOptions[35] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int do_command(int ac, char const* const* av,
|
int do_command(int ac, char const* const* av,
|
||||||
std::unique_ptr<cmConsoleBuf> consoleBuf)
|
cm::optional<cm::StdIo::Console> console)
|
||||||
{
|
{
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
args.reserve(ac - 1);
|
args.reserve(ac - 1);
|
||||||
args.emplace_back(av[0]);
|
args.emplace_back(av[0]);
|
||||||
cm::append(args, av + 2, av + ac);
|
cm::append(args, av + 2, av + ac);
|
||||||
return cmcmd::ExecuteCMakeCommand(args, std::move(consoleBuf));
|
return cmcmd::ExecuteCMakeCommand(args, std::move(console));
|
||||||
}
|
}
|
||||||
|
|
||||||
cmMakefile* cmakemainGetMakefile(cmake* cm)
|
cmMakefile* cmakemainGetMakefile(cmake* cm)
|
||||||
@@ -1145,9 +1144,7 @@ int main(int ac, char const* const* av)
|
|||||||
{
|
{
|
||||||
cm::StdIo::Init();
|
cm::StdIo::Init();
|
||||||
|
|
||||||
// Replace streambuf so we can output Unicode to console
|
cm::optional<cm::StdIo::Console> console = cm::StdIo::Console();
|
||||||
auto consoleBuf = cm::make_unique<cmConsoleBuf>();
|
|
||||||
consoleBuf->SetUTF8Pipes();
|
|
||||||
|
|
||||||
cmsys::Encoding::CommandLineArguments args =
|
cmsys::Encoding::CommandLineArguments args =
|
||||||
cmsys::Encoding::CommandLineArguments::Main(ac, av);
|
cmsys::Encoding::CommandLineArguments::Main(ac, av);
|
||||||
@@ -1170,7 +1167,7 @@ int main(int ac, char const* const* av)
|
|||||||
return do_workflow(ac, av);
|
return do_workflow(ac, av);
|
||||||
}
|
}
|
||||||
if (strcmp(av[1], "-E") == 0) {
|
if (strcmp(av[1], "-E") == 0) {
|
||||||
return do_command(ac, av, std::move(consoleBuf));
|
return do_command(ac, av, std::move(console));
|
||||||
}
|
}
|
||||||
if (strcmp(av[1], "--print-config-dir") == 0) {
|
if (strcmp(av[1], "--print-config-dir") == 0) {
|
||||||
std::cout << cmSystemTools::ConvertToOutputPath(
|
std::cout << cmSystemTools::ConvertToOutputPath(
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "cmCommandLineArgument.h"
|
#include "cmCommandLineArgument.h"
|
||||||
#include "cmConsoleBuf.h"
|
|
||||||
#include "cmCryptoHash.h"
|
#include "cmCryptoHash.h"
|
||||||
#include "cmDuration.h"
|
#include "cmDuration.h"
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
@@ -26,6 +25,7 @@
|
|||||||
#include "cmState.h"
|
#include "cmState.h"
|
||||||
#include "cmStateDirectory.h"
|
#include "cmStateDirectory.h"
|
||||||
#include "cmStateSnapshot.h"
|
#include "cmStateSnapshot.h"
|
||||||
|
#include "cmStdIoConsole.h"
|
||||||
#include "cmStringAlgorithms.h"
|
#include "cmStringAlgorithms.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmTransformDepfile.h"
|
#include "cmTransformDepfile.h"
|
||||||
@@ -689,7 +689,7 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string> const& args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
||||||
std::unique_ptr<cmConsoleBuf> consoleBuf)
|
cm::optional<cm::StdIo::Console> console)
|
||||||
{
|
{
|
||||||
// IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx
|
// IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx
|
||||||
if (args.size() > 1) {
|
if (args.size() > 1) {
|
||||||
@@ -1191,7 +1191,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
|||||||
if (arg == "-") {
|
if (arg == "-") {
|
||||||
doing_options = false;
|
doing_options = false;
|
||||||
// Destroy console buffers to drop cout/cerr encoding transform.
|
// Destroy console buffers to drop cout/cerr encoding transform.
|
||||||
consoleBuf.reset();
|
console.reset();
|
||||||
cmCatFile(arg);
|
cmCatFile(arg);
|
||||||
} else if (doing_options && cmHasLiteralPrefix(arg, "-")) {
|
} else if (doing_options && cmHasLiteralPrefix(arg, "-")) {
|
||||||
if (arg == "--") {
|
if (arg == "--") {
|
||||||
@@ -1215,7 +1215,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
|||||||
// Ignore empty files, this is not an error
|
// Ignore empty files, this is not an error
|
||||||
} else {
|
} else {
|
||||||
// Destroy console buffers to drop cout/cerr encoding transform.
|
// Destroy console buffers to drop cout/cerr encoding transform.
|
||||||
consoleBuf.reset();
|
console.reset();
|
||||||
cmCatFile(arg);
|
cmCatFile(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1464,11 +1464,11 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args[1] == "vs_link_exe") {
|
if (args[1] == "vs_link_exe") {
|
||||||
return cmcmd::VisualStudioLink(args, 1, std::move(consoleBuf));
|
return cmcmd::VisualStudioLink(args, 1, std::move(console));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1] == "vs_link_dll") {
|
if (args[1] == "vs_link_dll") {
|
||||||
return cmcmd::VisualStudioLink(args, 2, std::move(consoleBuf));
|
return cmcmd::VisualStudioLink(args, 2, std::move(console));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1] == "cmake_llvm_rc") {
|
if (args[1] == "cmake_llvm_rc") {
|
||||||
@@ -2221,7 +2221,7 @@ private:
|
|||||||
// exe and dll's. This code does that in such a way that incremental linking
|
// exe and dll's. This code does that in such a way that incremental linking
|
||||||
// still works.
|
// still works.
|
||||||
int cmcmd::VisualStudioLink(std::vector<std::string> const& args, int type,
|
int cmcmd::VisualStudioLink(std::vector<std::string> const& args, int type,
|
||||||
std::unique_ptr<cmConsoleBuf> consoleBuf)
|
cm::optional<cm::StdIo::Console> console)
|
||||||
{
|
{
|
||||||
// MSVC tools print output in the language specified by the VSLANG
|
// MSVC tools print output in the language specified by the VSLANG
|
||||||
// environment variable, and encoded in the console output code page.
|
// environment variable, and encoded in the console output code page.
|
||||||
@@ -2229,7 +2229,7 @@ int cmcmd::VisualStudioLink(std::vector<std::string> const& args, int type,
|
|||||||
// RunCommand tells RunSingleCommand to *not* convert encoding, so
|
// RunCommand tells RunSingleCommand to *not* convert encoding, so
|
||||||
// we buffer the output in its original encoding instead of UTF-8.
|
// we buffer the output in its original encoding instead of UTF-8.
|
||||||
// Drop our output encoding conversion so we print with original encoding.
|
// Drop our output encoding conversion so we print with original encoding.
|
||||||
consoleBuf.reset();
|
console.reset();
|
||||||
|
|
||||||
if (args.size() < 2) {
|
if (args.size() < 2) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -4,15 +4,20 @@
|
|||||||
|
|
||||||
#include "cmConfigure.h" // IWYU pragma: keep
|
#include "cmConfigure.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <cm/optional>
|
||||||
|
|
||||||
#include "cmsys/Status.hxx"
|
#include "cmsys/Status.hxx"
|
||||||
|
|
||||||
#include "cmCryptoHash.h"
|
#include "cmCryptoHash.h"
|
||||||
|
|
||||||
class cmConsoleBuf;
|
namespace cm {
|
||||||
|
namespace StdIo {
|
||||||
|
class Console;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class cmcmd
|
class cmcmd
|
||||||
{
|
{
|
||||||
@@ -22,7 +27,7 @@ public:
|
|||||||
* as echo, remove file etc.
|
* as echo, remove file etc.
|
||||||
*/
|
*/
|
||||||
static int ExecuteCMakeCommand(std::vector<std::string> const&,
|
static int ExecuteCMakeCommand(std::vector<std::string> const&,
|
||||||
std::unique_ptr<cmConsoleBuf> consoleBuf);
|
cm::optional<cm::StdIo::Console> console);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static int HandleCoCompileCommands(std::vector<std::string> const& args);
|
static int HandleCoCompileCommands(std::vector<std::string> const& args);
|
||||||
@@ -40,5 +45,5 @@ protected:
|
|||||||
std::string const& intermediate_file);
|
std::string const& intermediate_file);
|
||||||
static int RunLLVMRC(std::vector<std::string> const& args);
|
static int RunLLVMRC(std::vector<std::string> const& args);
|
||||||
static int VisualStudioLink(std::vector<std::string> const& args, int type,
|
static int VisualStudioLink(std::vector<std::string> const& args, int type,
|
||||||
std::unique_ptr<cmConsoleBuf> consoleBuf);
|
cm::optional<cm::StdIo::Console> console);
|
||||||
};
|
};
|
||||||
|
@@ -9,11 +9,11 @@
|
|||||||
#include "cmsys/Encoding.hxx"
|
#include "cmsys/Encoding.hxx"
|
||||||
|
|
||||||
#include "cmCTest.h"
|
#include "cmCTest.h"
|
||||||
#include "cmConsoleBuf.h"
|
|
||||||
#include "cmDocumentation.h"
|
#include "cmDocumentation.h"
|
||||||
#include "cmDocumentationEntry.h"
|
#include "cmDocumentationEntry.h"
|
||||||
#include "cmInstrumentation.h"
|
#include "cmInstrumentation.h"
|
||||||
#include "cmInstrumentationQuery.h"
|
#include "cmInstrumentationQuery.h"
|
||||||
|
#include "cmStdIoConsole.h"
|
||||||
#include "cmStdIoInit.h"
|
#include "cmStdIoInit.h"
|
||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
|
|
||||||
@@ -169,9 +169,7 @@ int main(int argc, char const* const* argv)
|
|||||||
{
|
{
|
||||||
cm::StdIo::Init();
|
cm::StdIo::Init();
|
||||||
|
|
||||||
// Replace streambuf so we can output Unicode to console
|
cm::StdIo::Console console;
|
||||||
cmConsoleBuf consoleBuf;
|
|
||||||
consoleBuf.SetUTF8Pipes();
|
|
||||||
|
|
||||||
cmsys::Encoding::CommandLineArguments encoding_args =
|
cmsys::Encoding::CommandLineArguments encoding_args =
|
||||||
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
|
||||||
|
Reference in New Issue
Block a user