I believe that using CPP files in core Wine code is not a good idea. But it would be nice to have the option to compile C++ modules. For example, lsteamclient from Proton is written partially in C++.
Based on @rbernon patch.
-- v2: tools/makedep: Allow building modules with C++ sources.
From: Grigory Vasilyev h0tc0d3@gmail.com
Initially make_makefiles removed cpp files from Makefile.in. --- tools/make_makefiles | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/make_makefiles b/tools/make_makefiles index 646a70d18f4..1cf78b47c10 100755 --- a/tools/make_makefiles +++ b/tools/make_makefiles @@ -298,7 +298,7 @@ sub assign_sources_to_makefiles(@) { next unless $dir eq "dlls/winewayland.drv"; } - elsif ($name !~ /.(c|in|inl|l|m|mc|po|rc|rh|sfd|svg|x|y)$/) + elsif ($name !~ /.(c|cpp|in|inl|l|m|mc|po|rc|rh|sfd|svg|x|y)$/) { next unless $dir eq "loader"; # loader dir contains misc files }
From: Grigory Vasilyev h0tc0d3@gmail.com
--- tools/makedep.c | 62 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 18 deletions(-)
diff --git a/tools/makedep.c b/tools/makedep.c index c185030ea66..01365896690 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -207,6 +207,7 @@ struct makefile int data_only; int is_win16; int is_exe; + int has_cxx; int disabled[MAX_ARCHS];
/* values generated at output time */ @@ -1221,6 +1222,7 @@ static const struct } parse_functions[] = { { ".c", parse_c_file }, + { ".cpp", parse_c_file }, { ".h", parse_c_file }, { ".inl", parse_c_file }, { ".l", parse_c_file }, @@ -2436,9 +2438,12 @@ static const char *cmd_prefix( const char *cmd ) /******************************************************************* * output_winegcc_command */ -static void output_winegcc_command( struct makefile *make, unsigned int arch ) +static void output_winegcc_command( struct makefile *make, unsigned int arch, int is_cxx ) { - output( "\t%s%s -o $@", cmd_prefix( "CCLD" ), tools_path( make, "winegcc" )); + const char *tool = tools_path( make, "winegcc" ); + if (is_cxx) + strcpy( strrchr( tool, 'w' ), "wineg++" ); + output( "\t%s%s -o $@", cmd_prefix( "CCLD" ), tool ); output_filename( "--wine-objdir ." ); if (tools_dir) { @@ -3158,7 +3163,7 @@ static void output_source_testdll( struct makefile *make, struct incl_file *sour output_filename( tools_path( make, "winebuild" )); output_filename( tools_path( make, "winegcc" )); output( "\n" ); - output_winegcc_command( make, link_arch ); + output_winegcc_command( make, link_arch, 0 ); output_filename( "-s" ); output_filenames( dll_flags ); if (link_arch) output_filenames( get_expanded_arch_var_array( make, "EXTRADLLFLAGS", link_arch )); @@ -3198,10 +3203,12 @@ static void output_source_one_arch( struct makefile *make, struct incl_file *sou struct strarray defines, struct strarray *targets, unsigned int arch ) { - const char *obj_name, *var_cc, *var_cflags; + const int is_cxx = strendswith( source->name, ".cpp" ); + const char *obj_name, *var_cc, *var_cflags, *var_cxx, *var_cxxflags; struct strarray cflags = empty_strarray;
if (make->disabled[arch] && !(source->file->flags & FLAG_C_IMPLIB)) return; + make->has_cxx |= is_cxx;
if (arch) { @@ -3233,16 +3240,20 @@ static void output_source_one_arch( struct makefile *make, struct incl_file *sou if (!source->use_msvcrt) strarray_addall( &cflags, make->unix_cflags ); if ((source->file->flags & FLAG_ARM64EC_X64) && !strcmp( archs.str[arch], "arm64ec" )) { - var_cc = "$(x86_64_CC)"; - var_cflags = "$(x86_64_CFLAGS)"; + var_cc = "$(x86_64_CC)"; + var_cflags = "$(x86_64_CFLAGS)"; + var_cxx = "$(x86_64_CXX)"; + var_cxxflags = "$(x86_64_CXXFLAGS)"; strarray_add( &cflags, "-D__arm64ec_x64__" ); strarray_addall( &cflags, get_expanded_make_var_array( top_makefile, "x86_64_EXTRACFLAGS" )); } else { - var_cc = arch_make_variable( "CC", arch ); - var_cflags = arch_make_variable( "CFLAGS", arch ); - strarray_addall( &cflags, make->extlib ? extra_cflags_extlib[arch] : extra_cflags[arch] ); + var_cc = arch_make_variable( "CC", arch ); + var_cflags = arch_make_variable( "CFLAGS", arch ); + var_cxx = arch_make_variable( "CXX", arch ); + var_cxxflags = arch_make_variable( "CXXFLAGS", arch ); + strarray_addall( &cflags, make->extlib || is_cxx ? extra_cflags_extlib[arch] : extra_cflags[arch] ); }
if (!arch) @@ -3267,10 +3278,16 @@ static void output_source_one_arch( struct makefile *make, struct incl_file *sou strarray_addall( &cflags, cpp_flags );
output( "%s: %s\n", obj_dir_path( make, obj_name ), source->filename ); - output( "\t%s%s -c -o $@ %s", cmd_prefix( "CC" ), var_cc, source->filename ); + if (is_cxx) + output( "\t%s%s -c -o $@ %s", cmd_prefix( "CXX" ), var_cxx, source->filename ); + else + output( "\t%s%s -c -o $@ %s", cmd_prefix( "CC" ), var_cc, source->filename ); output_filenames( defines ); output_filenames( cflags ); - output_filename( var_cflags ); + if (is_cxx) + output_filename( var_cxxflags ); + else + output_filename( var_cflags ); output( "\n" );
if (make->testdll && strendswith( source->name, ".c" ) && @@ -3399,7 +3416,7 @@ static void output_fake_module( struct makefile *make, const char *spec_file ) output_filename( tools_path( make, "winebuild" )); output_filename( tools_path( make, "winegcc" )); output( "\n" ); - output_winegcc_command( make, arch ); + output_winegcc_command( make, arch, 0 ); output_filename( "-Wb,--fake-module" ); if (!make->is_exe) output_filename( "-shared" ); if (spec_file) output_filename( spec_file ); @@ -3420,7 +3437,7 @@ static void output_module( struct makefile *make, unsigned int arch ) struct strarray imports = make->imports; const char *module_name; const char *debug_file; - char *spec_file = NULL; + char *tool, *spec_file = NULL; unsigned int i, link_arch;
if (!make->is_exe) @@ -3481,9 +3498,15 @@ static void output_module( struct makefile *make, unsigned int arch ) output_filenames_obj_dir( make, make->res_files[arch] ); output_filenames( dep_libs ); output_filename( tools_path( make, "winebuild" )); - output_filename( tools_path( make, "winegcc" )); + tool = tools_path( make, "winegcc" ); + output_filename( tool ); + if (make->has_cxx) + { + strcpy( strrchr( tool, 'w' ), "wineg++" ); + output_filename( tool ); + } output( "\n" ); - output_winegcc_command( make, link_arch ); + output_winegcc_command( make, link_arch, make->has_cxx ); if (arch) output_filename( "-Wl,--wine-builtin" ); if (!make->is_exe) output_filename( "-shared" ); if (spec_file) output_filename( spec_file ); @@ -3558,7 +3581,10 @@ static void output_unix_lib( struct makefile *make ) output_filenames_obj_dir( make, make->unixobj_files ); output_filenames( unix_deps ); output( "\n" ); - output( "\t%s$(CC) -o $@", cmd_prefix( "CCLD" )); + if (make->has_cxx) + output( "\t%s$(CXX) -o $@", cmd_prefix( "CCLD" )); + else + output( "\t%s$(CC) -o $@", cmd_prefix( "CCLD" )); output_filenames( get_expanded_make_var_array( make, "UNIXLDFLAGS" )); output_filenames_obj_dir( make, make->unixobj_files ); output_filenames( unix_libs ); @@ -3618,7 +3644,7 @@ static void output_test_module( struct makefile *make, unsigned int arch ) strarray_add( &make->all_targets[arch], testmodule ); strarray_add( &make->clean_files, stripped ); output( "%s:\n", obj_dir_path( make, testmodule )); - output_winegcc_command( make, link_arch ); + output_winegcc_command( make, link_arch, 0 ); output_filenames( make->extradllflags ); output_filenames_obj_dir( make, make->object_files[arch] ); if (link_arch != arch) output_filenames_obj_dir( make, make->object_files[link_arch] ); @@ -3629,7 +3655,7 @@ static void output_test_module( struct makefile *make, unsigned int arch ) output_filename( arch_make_variable( "LDFLAGS", link_arch )); output( "\n" ); output( "%s:\n", obj_dir_path( make, stripped )); - output_winegcc_command( make, link_arch ); + output_winegcc_command( make, link_arch, 0 ); output_filename( "-s" ); output_filename( strmake( "-Wb,-F,%s_test.exe", basemodule )); output_filenames( make->extradllflags );
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=146869
Your paranoid android.
=== debian11b (64 bit WoW report) ===
user32: input.c:4305: Test succeeded inside todo block: button_down_hwnd_todo 1: got MSG_TEST_WIN hwnd 00000000005600E4, msg WM_LBUTTONDOWN, wparam 0x1, lparam 0x320032 win.c:4037: Test failed: Expected active window 0000000005DA0178, got 000000000033017E. win.c:4038: Test failed: Expected focus window 0000000005DA0178, got 000000000033017E.
This merge request was closed by Alexandre Julliard.
Since there are no C++ source files upstream, this would all be dead code.