From 6a242a8050edd0a33ea0e770a6eca4823a98b8d1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 6 Jan 2022 06:59:31 +0200 Subject: Factor reusable code to target_key::effective_name() --- libbuild2/variable.cxx | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) (limited to 'libbuild2/variable.cxx') diff --git a/libbuild2/variable.cxx b/libbuild2/variable.cxx index 6f2812c..8ed9605 100644 --- a/libbuild2/variable.cxx +++ b/libbuild2/variable.cxx @@ -1857,39 +1857,8 @@ namespace build2 { if (!oname) { - const target_type& tt (*tk.type); - - // Note that if the name is not empty, then we always use that, even - // if the type is dir/fsdir. - // - if (tk.name->empty () && (tt.is_a () || tt.is_a ())) - { - oname = tk.dir->leaf ().string (); - } - // If we have the extension and the type expects the extension to be - // always specified explicitly by the user, then add it to the name. - // - // Overall, we have the following cases: - // - // 1. Extension is fixed: man1{}. - // - // 2. Extension is always specified by the user: file{}. - // - // 3. Default extension that may be overridden by the user: hxx{}. - // - // 4. Extension assigned by the rule but may be overridden by the - // user: obje{}. - // - // By default we only match the extension for (2). - // - else if (tk.ext && !tk.ext->empty () && - (tt.fixed_extension == &target_extension_none || - tt.fixed_extension == &target_extension_must)) - { - oname = *tk.name + '.' + *tk.ext; - } - else - oname = string (); // Use tk.name as is. + oname = string (); + tk.effective_name (*oname); } return oname->empty () ? *tk.name : *oname; -- cgit v1.1