From a1d00de1408b36b6b68d18d1c1e1fba7df1add49 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 2 Nov 2020 16:56:35 +0300 Subject: Set executable bit for ad hoc buildscript rule executable target on POSIX --- libbuild2/adhoc-rule-buildscript.cxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libbuild2/adhoc-rule-buildscript.cxx') diff --git a/libbuild2/adhoc-rule-buildscript.cxx b/libbuild2/adhoc-rule-buildscript.cxx index ed53c95..3dbe817 100644 --- a/libbuild2/adhoc-rule-buildscript.cxx +++ b/libbuild2/adhoc-rule-buildscript.cxx @@ -10,6 +10,7 @@ #include #include #include +#include // path_perms() #include #include // attributes @@ -553,7 +554,28 @@ namespace build2 p.execute (*rs, *bs, e, script, r); if (!ctx.dry_run) + { + // If this is an executable, let's be helpful to the user and set + // the executable bit on POSIX. + // +#ifndef _WIN32 + auto chmod = [] (const path& p) + { + path_perms (p, + (path_perms (p) | + permissions::xu | + permissions::xg | + permissions::xo)); + }; + + for (const target* m (&t); m != nullptr; m = m->adhoc_member) + { + if (auto* p = m->is_a ()) + chmod (p->path ()); + } +#endif dd.check_mtime (tp); + } } } -- cgit v1.1