diff --git a/Makefile b/Makefile index 348bec8b376f03..475043ceae7eb6 100644 --- a/Makefile +++ b/Makefile @@ -1439,7 +1439,6 @@ FORMAT_CPP_FILES += $(LINT_CPP_FILES) # C source codes. FORMAT_CPP_FILES += $(wildcard \ benchmark/napi/*/*.c \ - test/embedding/*.c \ test/js-native-api/*.h \ test/js-native-api/*/*.c \ test/js-native-api/*/*.h \ diff --git a/node.gyp b/node.gyp index 10d43a183a0435..2d951c6d95bacc 100644 --- a/node.gyp +++ b/node.gyp @@ -1152,6 +1152,7 @@ 'include_dirs': [ 'src', + 'tools', 'tools/msvs/genfiles', 'deps/v8/include', 'deps/cares/include', @@ -1163,7 +1164,6 @@ 'sources': [ 'src/node_snapshot_stub.cc', 'test/embedding/embedtest.cc', - 'test/embedding/utf8_args.c', ], 'conditions': [ diff --git a/test/embedding/embedtest.cc b/test/embedding/embedtest.cc index 32e23bf078bcec..32ad72b20cb932 100644 --- a/test/embedding/embedtest.cc +++ b/test/embedding/embedtest.cc @@ -2,9 +2,8 @@ #undef NDEBUG #endif #include +#include "executable_wrapper.h" #include "node.h" -#include "utf8_args.h" -#include "uv.h" #include @@ -28,10 +27,10 @@ static int RunNodeInstance(MultiIsolatePlatform* platform, const std::vector& args, const std::vector& exec_args); -int main(int argc, char** argv) { - GetUtf8CommandLineArgs(&argc, &argv); +NODE_MAIN(int argc, node::argv_type raw_argv[]) { + char** argv = nullptr; + node::FixupMain(argc, raw_argv, &argv); - argv = uv_setup_args(argc, argv); std::vector args(argv, argv + argc); std::unique_ptr result = node::InitializeOncePerProcess( @@ -57,8 +56,6 @@ int main(int argc, char** argv) { V8::DisposePlatform(); node::TearDownOncePerProcess(); - - FreeUtf8CommandLineArgs(argc, argv); return ret; } diff --git a/test/embedding/utf8_args.c b/test/embedding/utf8_args.c deleted file mode 100644 index ef0004a042d2ca..00000000000000 --- a/test/embedding/utf8_args.c +++ /dev/null @@ -1,47 +0,0 @@ -#include "utf8_args.h" - -#ifdef _WIN32 - -#include -#include -#include - -void GetUtf8CommandLineArgs(int* argc, char*** argv) { - int wargc; - wchar_t** wargv = CommandLineToArgvW(GetCommandLineW(), &wargc); - if (wargv == NULL) { - *argc = 0; - *argv = NULL; - return; - } - - *argc = wargc; - *argv = (char**)malloc(wargc * sizeof(char*)); - for (int i = 0; i < wargc; ++i) { - int len = - WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, NULL, 0, NULL, NULL); - (*argv)[i] = malloc(len); - WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, (*argv)[i], len, NULL, NULL); - } - - LocalFree(wargv); -} - -void FreeUtf8CommandLineArgs(int argc, char** argv) { - for (int i = 0; i < argc; ++i) { - free(argv[i]); - } - free(argv); -} - -#else - -void GetUtf8CommandLineArgs(int* /*argc*/, char*** /*argv*/) { - // Do nothing on non-Windows platforms. -} - -void FreeUtf8CommandLineArgs(int /*argc*/, char** /*argv*/) { - // Do nothing on non-Windows platforms. -} - -#endif diff --git a/test/embedding/utf8_args.h b/test/embedding/utf8_args.h deleted file mode 100644 index 53cd6d18dcd255..00000000000000 --- a/test/embedding/utf8_args.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef TEST_EMBEDDING_UTF8_ARGS_H_ -#define TEST_EMBEDDING_UTF8_ARGS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -// Windows does not support UTF-8 command line arguments. -// We must get them using an alternative way. -// This function does nothing on non-Windows platforms. -void GetUtf8CommandLineArgs(int* argc, char*** argv); - -// Free the memory allocated by GetUtf8CommandLineArgs. -void FreeUtf8CommandLineArgs(int argc, char** argv); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // TEST_EMBEDDING_UTF8_ARGS_H_