通常我們在 Visual C++ 裡開發,是以其圖形介面的 IDE 為主要操作環境。若為了要把一些工作自動化,就必須要找到方法,在 console mode 下編譯建置專案。

因為工作氛圍之故,無法擺脫 Visual C++ IDE 那一套 build configuration 機制,所以只好寫了這一個 vc-build.bat 的批次檔,直接在 console mode 下進行原本要按按鈕、點選單,才能做的事。

程式碼在此:vc-build.bat on github,使用起來很簡單:

------------------------------------------------------------------------------
Usage: vc-build.bat [vc] [solution] [project] [configuration]
Usage: vc-build.bat [vc] [solution] [project] [configuration] [action]
------------------------------------------------------------------------------
            [vc] could be vc6, vc8, or vc9.
      [solution] is the .dsw or .sln file.
       [project] is the project to build.
 [configuration] could be Debug or Release, normally.
        [action] could be BUILD, REBUILD, or CLEAN (case insentively).

依據以上的參數說明,執行即可。包括於 project 檔裡設定好的 pre/post events 的外部程式,都會正確執行。除了可以與 buildbot 這類 continuous integration 工具整合之外,設定進 vimmakeprg 參數,亦是擺脫 IDE 的好方法。

參考資料: