Pergunta

I would like to apply Gimpel PC-Lint to my source code in an incremental manner using Make. I want it to only run lint against the source file if the source file has changed since the last time lint was run. Is anyone doing this? How are you approaching it?

Foi útil?

Solução

The common pattern is to create output (or create artificial output if there is none).

Edit note that $(LINT) $< > $@ will expand to something like lint test.cpp > test.lint (redirecting output into that file)

E.g.

 %.o: %.cpp | %.lint
      S(CC) -o $@ $(CPPFLAGS) $<

 %.lint: %.cpp
      $(LINT) $< > $@

or for a process without output:

 %.o: %.cpp | %.emailsent
      S(CC) -o $@ $(CPPFLAGS) $<

 %.emailsent: %.cpp
      $(DOEMAIL) $^   # no output from mail sender
      touch $@        # won't be reached DOEMAIL returned error

Outras dicas

You could add the lint compilation to your compilation rules whenever gcc (or whatever) is called. This would immediately bring up any issue with the code before testing or using it. On the other hand this would be far too slow on a larger project.

I am usually linting my projects before checking them in. Thus I made a small script where I lint everything that has been checked out. If you have a gentle platform (e.g. svn on a suitable server) this could even be done by the server thus users could work on without having to wait for lint to finish.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top