【问题标题】:GMake Echo Not Working Correctly, Dropping Backslash ( \ )GMake Echo 无法正常工作,删除反斜杠 (\)
【发布时间】:2015-05-07 16:53:37
【问题描述】:

我在让 GMake 正常工作时遇到问题。上周晚些时候还好。我将我的编译器重新安装到这台机器上的一个新位置并运行了一个快速(成功)的构建,但从那以后没有构建任何东西。

目前,GMake 的输出如下所示

IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt
IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt Cleaning Build Folders IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt
IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt
IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt
IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt Cleaning Dependencies Folder...

...并以以下错误结束

process_begin: CreateProcess(NULL, del \F .\Output\dep*.dep, ...) failed.
make (e=2): The system cannot find the file specified.
gmake: *** [clean_files] Error 2

我的makefile的相关部分如下。

@echo *********************************************
@echo ****      Cleaning Build Folders         ****
@echo *********************************************
@echo **
@echo ** Cleaning Dependencies Folder...
@$(REMOVE) .\Output\dep\*.dep
@echo ** Cleaning Objects Folder...
@$(REMOVE) .\Output\obj\*.o
@echo ** Cleaning Generated Assembly Files Folder...
@$(REMOVE) .\Output\asm\*.asm    
@echo ** Cleaning Release Folder...
@$(REMOVE) .\Release\*.elf
@echo ** Cleaning Finished
@echo **
@echo **
@echo *********************************************

我相信这可能与我的系统配置有关,因为这是我见过的唯一一个此类问题的系统,并且相同的 makefile/设置正在为其他用户工作。 Echo 可以自己正常工作(当我在标准命令提示符下键入 'echo test' 时,IE 'test' 会回显到窗口)

【问题讨论】:

  • 看起来您只是没有任何与.\Output\dep\*.dep 匹配的文件,而del 在这种情况下会出错。
  • 请注意,它出错的路径是“.\Output\dep*.dep”,这不是传递给它的路径。如果 del 没有找到任何文件,它通常只会说“Could Not Find ...”,对吧?
  • @$(REMOVE) 应该做什么?它看起来不像是有效的 Windows 批处理。
  • 有趣。 del 当 glob 匹配失败并且组件目录不存在时返回不同的错误消息。所以看起来你可能没有Output 目录。我确实在错误中看到了丢失的 ``,但我还不确定该怎么做。
  • @aphoria @ 是“silent”的 make 前缀,$(REMOVE) 是 make 变量(这里显然包含 del \F 给出错误输出)。

标签: windows gnu-make


【解决方案1】:

你的输出中有两件事很奇怪。

制作配方行:

@echo *********************************************
@echo ****      Cleaning Build Folders         ****
@echo *********************************************
@echo **
@echo ** Cleaning Dependencies Folder...

正在产生以下输出:

IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt
IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt Cleaning Build Folders IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt
IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt
IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt
IDE LSL Lib MCAL_CA MCAL_DB Output Release Source build buildall.bat cleanall.bat compile_window.bat config_ca intro.bat project.pj test.txt Cleaning Dependencies Folder...

还有一行:

@$(REMOVE) .\Output\dep\*.dep

正在触发包含del \F .\Output\dep*.dep 的错误。 (假设$(REMOVE) 包含del \F。)

shell 将** glob 扩展为文件名列表来解释第一个输出异常。

第二个奇怪的原因是外壳删除了转义的反斜杠(即echo foo\*bar 产生foo*bar 作为输出等)。

makefile 显然没有考虑到这些行为。

鉴于这是 Windows,假设要使用的 SHELLcmd.exe 而不是任何 shell(例如 sh/bash)似乎正在运行命令似乎是合理的。

确认那是,事实上,这种情况意味着在makefile中设置SHELL=cmd.exe应该可以解决问题。手册在 Choosing the Shell 部分讨论了 Windows 上 shell 的选择。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-19
    • 1970-01-01
    • 1970-01-01
    • 2015-07-23
    • 2017-04-30
    • 2019-01-13
    • 1970-01-01
    • 2018-07-26
    相关资源
    最近更新 更多