aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-11-23 23:58:46 -0500
committerEli Schwartz <eschwartz@archlinux.org>2022-04-14 18:37:04 -0400
commit6a287fae5d10d4c46277e2533aaa3093de05acf1 (patch)
tree25b5bbf535a50718042fcbfb865ad118bd7a5820
parent19de032d207a847b9dc6f872cda7da1c91021037 (diff)
downloadmeson-6a287fae5d10d4c46277e2533aaa3093de05acf1.zip
meson-6a287fae5d10d4c46277e2533aaa3093de05acf1.tar.gz
meson-6a287fae5d10d4c46277e2533aaa3093de05acf1.tar.bz2
simplify destdir_join for readability
We can immediately short-circuit if there is no destdir, as we simply return the prefix unchanged. If there is some kind of destdir and the prefix contains a drive letter, then no matter what we need to remove the drive letter before joining. Technically, if the destdir is a relative path e.g. `destdir\` and `C:\prefix`, we should still install to `destdir\prefix` without the drive letter. But... we also guarantee that destdir is an absolute path (or empty) anyway. And even if we didn't, non-absolute destdir is a broken concept for a variety of complicated reasons. So none of this matters in practice. One way or another, we don't need to actually check whether destdir is an absolute path before cutting off the prefix drive letter.
-rw-r--r--mesonbuild/scripts/__init__.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/mesonbuild/scripts/__init__.py b/mesonbuild/scripts/__init__.py
index 2edbe88..476a28a 100644
--- a/mesonbuild/scripts/__init__.py
+++ b/mesonbuild/scripts/__init__.py
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# TODO: consider switching to pathlib for this
def destdir_join(d1: str, d2: str) -> str:
+ if not d1:
+ return d2
# c:\destdir + c:\prefix must produce c:\destdir\prefix
- if len(d1) > 1 and d1[1] == ':' \
- and len(d2) > 1 and d2[1] == ':':
+ if len(d2) > 1 and d2[1] == ':':
return d1 + d2[2:]
return d1 + d2