From a933cdeb0c674409bbd52757bcef314fd8bddb46 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 9 May 2023 15:22:52 +0200 Subject: Make quoted/display target names in JSON structured result consistent with dump Specifically, before we had `target` (display) and `quoted_target` and now we have `target` (quoted) and `display_target`. --- build2/b.cxx | 10 +++++----- libbuild2/b-options.cxx | 39 +++++++++++++++++++++------------------ libbuild2/b.cli | 36 +++++++++++++++++++----------------- 3 files changed, 45 insertions(+), 40 deletions(-) diff --git a/build2/b.cxx b/build2/b.cxx index 72c49e9..f0c9338 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -148,15 +148,15 @@ namespace build2 s.begin_object (); - // Display target. + // Quoted target. // s.member_name ("target"); - dump_display_target_name (s, t); + dump_quoted_target_name (s, t); - // Quoted target. + // Display target. // - s.member_name ("quoted_target"); - dump_quoted_target_name (s, t); + s.member_name ("display_target"); + dump_display_target_name (s, t); s.member ("target_type", t.type ().name, false /* check */); diff --git a/libbuild2/b-options.cxx b/libbuild2/b-options.cxx index 8258dea..c107b44 100644 --- a/libbuild2/b-options.cxx +++ b/libbuild2/b-options.cxx @@ -930,8 +930,9 @@ namespace build2 << " the outer operation is specified in parenthesis. For" << ::std::endl << " example:" << ::std::endl << ::std::endl - << " unchanged perform update(test) /tmp/dir{hello/}" << ::std::endl - << " changed perform test /tmp/hello/exe{test}" << ::std::endl + << " unchanged perform update(test)" << ::std::endl + << " /tmp/hello/hello/exe{hello}" << ::std::endl + << " changed perform test /tmp/hello/hello/exe{hello}" << ::std::endl << ::std::endl << " If the output format is \033[1mjson\033[0m, then the output is a JSON" << ::std::endl << " array of objects which are the serialized" << ::std::endl @@ -941,7 +942,7 @@ namespace build2 << " struct target_action_result" << ::std::endl << " {" << ::std::endl << " string target;" << ::std::endl - << " string quoted_target;" << ::std::endl + << " string display_target;" << ::std::endl << " string target_type;" << ::std::endl << " optional target_path;" << ::std::endl << " string meta_operation;" << ::std::endl @@ -954,20 +955,20 @@ namespace build2 << ::std::endl << " [" << ::std::endl << " {" << ::std::endl - << " \"target\": \"/tmp/dir{hello/}\"," << ::std::endl - << " \"quoted_target\": \"/tmp/dir{hello/}\"," << ::std::endl - << " \"target_type\": \"dir\"," << ::std::endl - << " \"target_path\": \"/tmp/hello\"," << ::std::endl + << " \"target\": \"/tmp/hello/hello/exe{hello.}\"," << ::std::endl + << " \"display_target\": \"/tmp/hello/hello/exe{hello}\"," << ::std::endl + << " \"target_type\": \"exe\"," << ::std::endl + << " \"target_path\": \"/tmp/hello/hello/hello\"," << ::std::endl << " \"meta_operation\": \"perform\"," << ::std::endl << " \"operation\": \"update\"," << ::std::endl << " \"outer_operation\": \"test\"," << ::std::endl << " \"state\": \"unchanged\"" << ::std::endl << " }," << ::std::endl << " {" << ::std::endl - << " \"target\": \"/tmp/dir{hello/}\"," << ::std::endl - << " \"quoted_target\": \"/tmp/dir{hello/}\"," << ::std::endl - << " \"target_type\": \"dir\"," << ::std::endl - << " \"target_path\": \"/tmp/hello\"," << ::std::endl + << " \"target\": \"/tmp/hello/hello/exe{hello.}\"," << ::std::endl + << " \"display_target\": \"/tmp/hello/hello/exe{hello}\"," << ::std::endl + << " \"target_type\": \"exe\"," << ::std::endl + << " \"target_path\": \"/tmp/hello/hello/hello\"," << ::std::endl << " \"meta_operation\": \"perform\"," << ::std::endl << " \"operation\": \"test\"," << ::std::endl << " \"state\": \"changed\"" << ::std::endl @@ -978,13 +979,15 @@ namespace build2 << " overall properties of this format and the semantics of" << ::std::endl << " the \033[1mstruct\033[0m serialization." << ::std::endl << ::std::endl - << " The \033[1mtarget\033[0m member is a \"display\" target name, the same" << ::std::endl - << " as in the \033[1mlines\033[0m format. The \033[1mquoted_target\033[0m member is a" << ::std::endl - << " target name that, if required, is quoted so that it can" << ::std::endl - << " be passed back to the driver on the command line. The" << ::std::endl - << " \033[1mtarget_type\033[0m member is the type of target. The" << ::std::endl - << " \033[1mtarget_path\033[0m member is an absolute path to the target if" << ::std::endl - << " the target type is path-based or \033[1mdir\033[0m." << ::std::endl; + << " The \033[1mtarget\033[0m member is the target name that is qualified" << ::std::endl + << " with the extension (if applicable) and, if required, is" << ::std::endl + << " quoted so that it can be passed back to the build" << ::std::endl + << " system driver on the command line. The \033[1mdisplay_target\033[0m" << ::std::endl + << " member is the unqualified and unquoted \"display\" target" << ::std::endl + << " name, the same as in the \033[1mlines\033[0m format. The \033[1mtarget_type\033[0m" << ::std::endl + << " member is the type of target. The \033[1mtarget_path\033[0m member" << ::std::endl + << " is an absolute path to the target if the target type is" << ::std::endl + << " path-based or \033[1mdir\033[0m." << ::std::endl; os << std::endl << "\033[1m--mtime-check\033[0m Perform file modification time sanity checks. These" << ::std::endl diff --git a/libbuild2/b.cli b/libbuild2/b.cli index 1c994df..f58b869 100644 --- a/libbuild2/b.cli +++ b/libbuild2/b.cli @@ -706,8 +706,8 @@ namespace build2 outer operation is specified in parenthesis. For example: \ - unchanged perform update(test) /tmp/dir{hello/} - changed perform test /tmp/hello/exe{test} + unchanged perform update(test) /tmp/hello/hello/exe{hello} + changed perform test /tmp/hello/hello/exe{hello} \ If the output format is \cb{json}, then the output is a JSON array of @@ -718,7 +718,7 @@ namespace build2 struct target_action_result { string target; - string quoted_target; + string display_target; string target_type; optional target_path; string meta_operation; @@ -733,20 +733,20 @@ namespace build2 \ [ { - \"target\": \"/tmp/dir{hello/}\", - \"quoted_target\": \"/tmp/dir{hello/}\", - \"target_type\": \"dir\", - \"target_path\": \"/tmp/hello\", + \"target\": \"/tmp/hello/hello/exe{hello.}\", + \"display_target\": \"/tmp/hello/hello/exe{hello}\", + \"target_type\": \"exe\", + \"target_path\": \"/tmp/hello/hello/hello\", \"meta_operation\": \"perform\", \"operation\": \"update\", \"outer_operation\": \"test\", \"state\": \"unchanged\" }, { - \"target\": \"/tmp/dir{hello/}\", - \"quoted_target\": \"/tmp/dir{hello/}\", - \"target_type\": \"dir\", - \"target_path\": \"/tmp/hello\", + \"target\": \"/tmp/hello/hello/exe{hello.}\", + \"display_target\": \"/tmp/hello/hello/exe{hello}\", + \"target_type\": \"exe\", + \"target_path\": \"/tmp/hello/hello/hello\", \"meta_operation\": \"perform\", \"operation\": \"test\", \"state\": \"changed\" @@ -758,12 +758,14 @@ namespace build2 properties of this format and the semantics of the \cb{struct} serialization. - The \cb{target} member is a \"display\" target name, the same as in the - \cb{lines} format. The \cb{quoted_target} member is a target name that, - if required, is quoted so that it can be passed back to the driver on - the command line. The \cb{target_type} member is the type of target. - The \cb{target_path} member is an absolute path to the target if the - target type is path-based or \cb{dir}. + The \cb{target} member is the target name that is qualified with the + extension (if applicable) and, if required, is quoted so that it can be + passed back to the build system driver on the command line. The + \cb{display_target} member is the unqualified and unquoted \"display\" + target name, the same as in the \cb{lines} format. The \cb{target_type} + member is the type of target. The \cb{target_path} member is an + absolute path to the target if the target type is path-based or + \cb{dir}. " } -- cgit v1.1