Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyword for setting the mode of a file copied by fs.copyfile in the build directory #10744

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dcbaker
Copy link
Member

@dcbaker dcbaker commented Aug 26, 2022

There are cases where users need to set the mode of a copied file in the build directory. This is actually rather painful to do in a cross platform way, so it would be nice if meson just provided this functionality. Since we already have everything in place to do this for install_mode, it's rather trivial to add support.

See https://gitea.treehouse.systems/ariadne/pkgconf/pulls/246, for an example of where this is useful.

This is ground work for more complex handling
This can be done by setting the `--file-mode` argument, and passing a
numeric value suitable for passing to `os.chmod`.

This will be used to allow `fs.copyfile` to set the mode of a file in
the build directory, which is sometimes useful.
There are cases where scripts need to be copied into the build directory
with specific file modes set. This allows this to be done in a platform
agnostic way, without having to figure out chmod vs something else.

See https://gitea.treehouse.systems/ariadne/pkgconf/pulls/246 for an
example of this.
@dcbaker dcbaker requested a review from jpakkane as a code owner August 26, 2022 17:59
@dcbaker dcbaker added this to the 0.64.0 milestone Aug 26, 2022
@codecov
Copy link

codecov bot commented Aug 26, 2022

Codecov Report

Merging #10744 (21d1b66) into master (47a0ed5) will decrease coverage by 1.54%.
The diff coverage is 73.68%.

@@            Coverage Diff             @@
##           master   #10744      +/-   ##
==========================================
- Coverage   68.93%   67.39%   -1.55%     
==========================================
  Files         406      406              
  Lines       88402    88436      +34     
  Branches    19607    19615       +8     
==========================================
- Hits        60944    59602    -1342     
- Misses      22870    24288    +1418     
+ Partials     4588     4546      -42     
Impacted Files Coverage Δ
mesonbuild/modules/fs.py 82.06% <28.57%> (-2.12%) ⬇️
mesonbuild/scripts/copy.py 89.47% <100.00%> (+11.69%) ⬆️
mesonbuild/mesonlib/win32.py 0.00% <0.00%> (-100.00%) ⬇️
modules/cuda.py 0.00% <0.00%> (-72.64%) ⬇️
mesonbuild/modules/windows.py 0.00% <0.00%> (-72.00%) ⬇️
templates/cudatemplates.py 37.50% <0.00%> (-62.50%) ⬇️
compilers/cuda.py 19.63% <0.00%> (-45.40%) ⬇️
dependencies/cuda.py 20.19% <0.00%> (-42.79%) ⬇️
mesonbuild/mesonlib/vsenv.py 19.23% <0.00%> (-42.31%) ⬇️
mesonbuild/_pathlib.py 63.15% <0.00%> (-26.32%) ⬇️
... and 64 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@xclaesse
Copy link
Member

@dcbaker just thinking out loud, but is there a use-case for install_mode != build_mode? Wondering if we should just set install_mode in the builddir and avoid adding extra kwarg?

@dcbaker
Copy link
Member Author

dcbaker commented Aug 26, 2022

The biggest thing I can think of is that while you may want the mode to be the same, you may not want (or may not be able to) set the ownership the same (say because you expect ninja build && sudo ninja install. This series explicitly errors out of if you try to set the owner or group in the the build mode, it's basically just to let you set executable bits

@eli-schwartz
Copy link
Member

eli-schwartz commented Aug 26, 2022

Why not just change the executable bit in the source tree and check that into git? The rationale here seems weak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants