aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/adhoc-rule-buildscript.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-11-02 16:56:35 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-11-02 20:38:57 +0300
commita1d00de1408b36b6b68d18d1c1e1fba7df1add49 (patch)
treec6add78f6380f9325648be5698da10c311ed2e9b /libbuild2/adhoc-rule-buildscript.cxx
parent809123f03100ee9ed90d31424304c22ba28e842c (diff)
Set executable bit for ad hoc buildscript rule executable target on POSIX
Diffstat (limited to 'libbuild2/adhoc-rule-buildscript.cxx')
-rw-r--r--libbuild2/adhoc-rule-buildscript.cxx22
1 files changed, 22 insertions, 0 deletions
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 <libbuild2/target.hxx>
#include <libbuild2/context.hxx>
#include <libbuild2/algorithm.hxx>
+#include <libbuild2/filesystem.hxx> // path_perms()
#include <libbuild2/diagnostics.hxx>
#include <libbuild2/parser.hxx> // 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<exe> ())
+ chmod (p->path ());
+ }
+#endif
dd.check_mtime (tp);
+ }
}
}