Add toolchain for cxx modules in TestWithScope This is a preparation CL changing test for behavior around dependency from rust executable to cxx modules. Bug: 400872290 Change-Id: Icc24d7c0018895700bb515cb1fa7c09e0071185e Reviewed-on: https://gn-review.googlesource.com/c/gn/+/18380 Reviewed-by: David Turner <digit@google.com> Commit-Queue: Takuto Ikuta <tikuta@google.com>
diff --git a/src/gn/json_project_writer_unittest.cc b/src/gn/json_project_writer_unittest.cc index a026b40..0481d1a 100644 --- a/src/gn/json_project_writer_unittest.cc +++ b/src/gn/json_project_writer_unittest.cc
@@ -129,6 +129,15 @@ "outputs": [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ], "weak_framework_switch": "-weak_framework " }, + "cxx_module": { + "command": "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} -o {{output}}", + "framework_dir_switch": "-F", + "framework_switch": "-framework ", + "lib_dir_switch": "-L", + "lib_switch": "-l", + "outputs": [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.pcm" ], + "weak_framework_switch": "-weak_framework " + }, "link": { "command": "ld -o {{target_output_name}} {{source}} {{ldflags}} {{libs}}", "framework_dir_switch": "-F", @@ -360,6 +369,15 @@ "outputs": [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ], "weak_framework_switch": "-weak_framework " }, + "cxx_module": { + "command": "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} -o {{output}}", + "framework_dir_switch": "-F", + "framework_switch": "-framework ", + "lib_dir_switch": "-L", + "lib_switch": "-l", + "outputs": [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.pcm" ], + "weak_framework_switch": "-weak_framework " + }, "link": { "command": "ld -o {{target_output_name}} {{source}} {{ldflags}} {{libs}}", "framework_dir_switch": "-F", @@ -615,6 +633,15 @@ "outputs": [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ], "weak_framework_switch": "-weak_framework " }, + "cxx_module": { + "command": "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} -o {{output}}", + "framework_dir_switch": "-F", + "framework_switch": "-framework ", + "lib_dir_switch": "-L", + "lib_switch": "-l", + "outputs": [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.pcm" ], + "weak_framework_switch": "-weak_framework " + }, "link": { "command": "ld -o {{target_output_name}} {{source}} {{ldflags}} {{libs}}", "framework_dir_switch": "-F",
diff --git a/src/gn/ninja_c_binary_target_writer_unittest.cc b/src/gn/ninja_c_binary_target_writer_unittest.cc index 8d2a388..5bfd2a4 100644 --- a/src/gn/ninja_c_binary_target_writer_unittest.cc +++ b/src/gn/ninja_c_binary_target_writer_unittest.cc
@@ -2266,12 +2266,6 @@ TestWithScope setup; Err err; - std::unique_ptr<Tool> cxx_module_tool = - Tool::CreateTool(CTool::kCToolCxxModule); - cxx_module_tool->set_outputs(SubstitutionList::MakeForTest( - "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.pcm")); - setup.toolchain()->SetTool(std::move(cxx_module_tool)); - TestTarget target(setup, "//foo:bar", Target::STATIC_LIBRARY); target.sources().push_back(SourceFile("//foo/bar.cc")); target.sources().push_back(SourceFile("//foo/bar.modulemap"));
diff --git a/src/gn/test_with_scope.cc b/src/gn/test_with_scope.cc index 1fae377..98a021f 100644 --- a/src/gn/test_with_scope.cc +++ b/src/gn/test_with_scope.cc
@@ -109,6 +109,17 @@ cxx_tool->set_command_launcher("launcher"); toolchain->SetTool(std::move(cxx_tool)); + // CXX_MODULE + std::unique_ptr<Tool> cxx_module_tool = + Tool::CreateTool(CTool::kCToolCxxModule); + SetCommandForTool( + "c++ {{source}} {{cflags}} {{cflags_cc}} {{defines}} {{include_dirs}} " + "-o {{output}}", + cxx_module_tool.get()); + cxx_module_tool->set_outputs(SubstitutionList::MakeForTest( + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.pcm")); + toolchain->SetTool(std::move(cxx_module_tool)); + // OBJC std::unique_ptr<Tool> objc_tool = Tool::CreateTool(CTool::kCToolObjC); SetCommandForTool(