makedepend 相当于与 nmake 一起使用吗?

发布于 2024-07-23 06:46:31 字数 81 浏览 7 评论 0原文

只是想知道是否有一个与 Visual Studio 一起提供的“makedepends”等效项,我可以将其与 nmake 一起使用。 有人知道吗?

Just wondering if there is a 'makedepends' equivalent that ships with visual studio that I can use with nmake. Does anyone know?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

笑饮青盏花 2024-07-30 06:46:31

您可以使用 /showIncludes 开关到 cl.exe 以列出源文件的 #include 标头。 嵌套包含由带空格的缩进表示。 您还可以使用 /Zs 开关打开语法检查模式,以提高速度并避免创建 .obj 文件。

如果您安装了 Perl 和 uniq 版本(例如来自 GnuWin32),以下单行代码将转储 myfile.cpp 使用的唯一标头列表:

cl /Zs /showIncludes /EHsc myfile.cpp | perl -ne "print if s/^Note: including file: *//" | sort | uniq

通过创建相关 nmake 规则的另一个脚本进行管道传输应该不会太困难。

You can use the /showIncludes switch to cl.exe to list the headers #included by your source files. Nested includes are indicated by indentation with spaces. You can also turn on syntax-checking mode with the /Zs switch, to increase speed and avoid creation of .obj files.

If you have Perl and a version of uniq (e.g. from GnuWin32) installed, the following one-liner will dump the list of unique headers used by myfile.cpp:

cl /Zs /showIncludes /EHsc myfile.cpp | perl -ne "print if s/^Note: including file: *//" | sort | uniq

It should not be too difficult to pipe this through another script that creates the relevant nmake rules.

不美如何 2024-07-30 06:46:31

我假设你像我一样使用 NMAKE 来构建项目。 我也需要 Windows 中类似 makedepend 的工具。 因此,我使用 MinGW 生成标头依赖项。 首先创建 Makefile 来生成依赖项,我将其命名为 Makedepends,如下所示:

    OBJS=... list object files in your project...

    all: Makefile.deps

    Makefile.deps: $(OBJS:.obj=.dep)
        cat $+ > $@
        rm -f $+

    %.dep: %.cpp
        g++ -MM -MG -MT$(@:.dep=.obj) -o$@ 
lt;

在 NMAKE 将使用的 Makefile 中,在底部添加这一行:

    !INCLUDE Makefile.deps

当您想要创建依赖项时,像这样运行 GMAKE:

    make -fMakedepends

然后,您可以构建像往常一样使用 NMAKE 进行你的项目:

    nmake

PS:抱歉语言不好,我不擅长写作。 -_-

I assume you use NMAKE to build project like me. I'm in need of makedepend-like tool in Windows, too. So, I use MinGW to generate header dependencies. First create Makefile to generate dependencies, which I named it Makedepends, like this:

    OBJS=... list object files in your project...

    all: Makefile.deps

    Makefile.deps: $(OBJS:.obj=.dep)
        cat $+ > $@
        rm -f $+

    %.dep: %.cpp
        g++ -MM -MG -MT$(@:.dep=.obj) -o$@ 
lt;

In your Makefile that will be used by NMAKE, add this line at bottom:

    !INCLUDE Makefile.deps

When you want to create dependencies, run GMAKE like this:

    make -fMakedepends

And then, you can build your project with NMAKE as usual:

    nmake

PS: Sorry for poor language, I'm suck at writing. -_-

腻橙味 2024-07-30 06:46:31
.SUFFIXES:
.SUFFIXES: .c

all: x.obj

# Sample batch-mode rule which both compiles and produces .dep files suitable for NMAKE.
# Also works around the fact that CL.EXE spits diagnostics in stdout instead of stderr.
# This is equivalent to -MD -MP -MT$@ -MF$(@R).dep in GNU Make + GCC.
CCOMMAND = $(CC) $(CFLAGS) /c 
lt;
.c.obj::
!IF "$(MAKEFLAGS:S=)" == "$(MAKEFLAGS)"
    @echo " $(CCOMMAND)"
!ENDIF
    @$(COMSPEC) /E:ON /V:ON /C "$(CCOMMAND) /showIncludes & echo Exit: !ERRORLEVEL!" | \
        $(COMSPEC) /E:ON /V:ON /C "for /f "tokens=1,* delims=]" %%A in ('find /v /n ""') do \
        @if %%~xB == .c (set _=%%~nB&rem.>!_!.dep&echo %%B) else for /f "tokens=1,2,3,*" %%C in ("%%B") do \
        @if %%C == Note: ((echo !_!.obj: "%%F"&echo "%%F":) >> !_!.dep) \
        else if %%C == Exit: (exit /b %%D) else echo %%B"

# Include the generated deps.
!IF ![(for %i in (*.dep) do @echo !INCLUDE %i) >Build.tmp]
!       INCLUDE Build.tmp
!       IF ![del Build.tmp]
!       ENDIF
!ENDIF
.SUFFIXES:
.SUFFIXES: .c

all: x.obj

# Sample batch-mode rule which both compiles and produces .dep files suitable for NMAKE.
# Also works around the fact that CL.EXE spits diagnostics in stdout instead of stderr.
# This is equivalent to -MD -MP -MT$@ -MF$(@R).dep in GNU Make + GCC.
CCOMMAND = $(CC) $(CFLAGS) /c 
lt;
.c.obj::
!IF "$(MAKEFLAGS:S=)" == "$(MAKEFLAGS)"
    @echo " $(CCOMMAND)"
!ENDIF
    @$(COMSPEC) /E:ON /V:ON /C "$(CCOMMAND) /showIncludes & echo Exit: !ERRORLEVEL!" | \
        $(COMSPEC) /E:ON /V:ON /C "for /f "tokens=1,* delims=]" %%A in ('find /v /n ""') do \
        @if %%~xB == .c (set _=%%~nB&rem.>!_!.dep&echo %%B) else for /f "tokens=1,2,3,*" %%C in ("%%B") do \
        @if %%C == Note: ((echo !_!.obj: "%%F"&echo "%%F":) >> !_!.dep) \
        else if %%C == Exit: (exit /b %%D) else echo %%B"

# Include the generated deps.
!IF ![(for %i in (*.dep) do @echo !INCLUDE %i) >Build.tmp]
!       INCLUDE Build.tmp
!       IF ![del Build.tmp]
!       ENDIF
!ENDIF
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文