【问题标题】:Make Directory path with spaces in Makefile Windows Environment在 Makefile Windows 环境中使用空格制作目录路径
【发布时间】:2016-09-22 21:47:34
【问题描述】:

我通常在 linux 环境中工作,并使用 Makefiles 编译我的项目。在makefile中它创建目录。当我在 Windows 上使用这个 makefile 时,路径中有空格,因为用户名是“John Doe”。

我试过的是:

MAKEPATHCMD = mkdir
build:
@( \
    echo -e "Building...\n"; \
    $(MAKEPATHCMD) "$(NEW_PATH)"; \
    .
    .
    .

错误如下...

/usr/bin/mkdir: cannot create directory '/c/Users/John Doe/Desktop/new': No such file or directory

我尝试过的其他事情:

$(MAKEPATHCMD) "\"$(NEW_PATH)\""; \

$(MAKEPATHCMD) "'$(NEW_PATH)'"; \

如何让 makefile 在 Windows 上创建包含空格的目录路径?

【问题讨论】:

  • 你能在命令行上做,不用 Make 吗?也许通过在空格前面插入斜杠或反斜杠或其他东西? (我不做 Windows。)

标签: windows makefile mkdir


【解决方案1】:

在不包含空格的目录中工作,例如 c:\work。

或者,通过将目录名称转换为“短名称”来消除目录名称中的空格。

使用以下脚本:

rem Pass path to sanitize as arg 1 @echo off echo Original path=[%~1] call :chkspaces "%~1"

如果 /I NOT "%_sp%" == "%~1" 调用 :shrt "%~1" 回声丑化=[%_sp%] 转到:EOF

:chkspaces 设置 _sp=%1 设置_sp=%_sp:=% 转到:EOF

:shrt 回声 arg=[%1] 设置_sp=%~s1 转到:EOF

这将为您的目录生成一个短名称。然后就在cd那里。

【讨论】:

    猜你喜欢
    • 2015-02-17
    • 2012-07-02
    • 1970-01-01
    • 1970-01-01
    • 2010-09-24
    • 2014-05-21
    • 1970-01-01
    • 1970-01-01
    • 2021-12-05
    相关资源
    最近更新 更多