Google Coding Style ã¨ãããã®ãããã¾ããã³ã¼ãã£ã³ã°è¦ç´ã¯ä¸ã®ä¸ã«ããããããã¨æãã¾ãããããã¯Google社ãçºè¡¨ãã¦ãããã®ã§ãã
ãã®ã³ã¼ãã£ã³ã°è¦ç´ãæ¡ç¨ããä¸ã§ããã¤ã便å©ãªãã¼ã«ãããã¾ããä¸ã¤ã¯ãemacsç¨ã®google-c-style.elã§ããããã¯ãã¤ã³ãã³ãçã®åä½ã Google Coding Style ã«æ²¿ã£ã¦ã«ã¹ã¿ãã¤ãºãã¦ããããã®ã§ãã
次ã«ãèªåã®ã³ã¼ããCoding Styleã«æºæ ãã¦ããããããã§ãã¯ãã¦ããã cpplint.py ã¨ããã³ãã³ããããã¾ããããã使ãã°ãéåãã¦ããå ´æã¨çç±ãå ·ä½çã«ææãã¦ãããã®ã§ãè¦ç´ã«ãããã£ã¦ããªãç¹ãä¿®æ£ã§ãã¾ã
ãããããã¡ãã¡ã³ãã³ãã©ã¤ã³ããæå㧠cpplint.py èµ·åããã®ã¯è³¢ãããã¾ããã第ä¸ã«é¢åããããããã¡ãã¡è©²å½ç®æãè¦ãã¦ã¨ãã£ã¿ã§éãã®ãé ãæªãã§ããããã§ãCMakeçµç±ã§cpplint.pyãå®è¡ã§ããããã«ãã¦ã¿ã¾ããã
ã¾ããCMakeã§ç¬èªã®ã³ãã³ããå®è¡ããæ¹æ³ã§ããããã㯠ADD_CUSTOM_TARGET ã使ãã°ããã§ããcpplint.py ã ${PROJECT_SOURCE_DIR}/bin/cpplint.py ã«ãããã¨ãã¦ãä¾ãã°ãããªå ·åã«æ¸ãã¾ãã
ADD_CUSTOM_TARGET(cpplint python ${PROJECT_SOURCE_DIR}/bin/cpplint.py --filter=-runtime/rtti,-build/include_order ${PROJECT_SOURCE_DIR}/src/* )
"--filter" ã®é ã¯ããã«ããè¦ã¦é©å½ã«èª¿æ´ãã¦ãã ããã
ããã¦ãé常ã¨åãããã«Makefileãçæããã°ãmake cpplint ã§å®è¡ã§ãã¾ããC/C++ããã°ã©ã 以å¤ã®ãã¡ã¤ã«ã¯è¯ãæãã«ç¡è¦ãã¦ããã¾ãã
$ mkdir build $ cd build $ cmake .. $ make cpplint
ããã§å®è¡ã§ããã¯ãã§ãã
æå¾ã«ãcpplintã¯emacsã解éå¯è½ãªå½¢å¼ã§ã¨ã©ã¼ç®æãåºåãã¦ãããã®ã§ãemacsããå®è¡ããã°ã³ã³ãã¤ã«ã¨ã©ã¼çã¨åãããã«ã¨ã©ã¼ç®æã«é£ã¶ãã¨ãã§ãã¾ããããã¯ã
M-x compile
㧠make -k -C ~/xxx/yyy/zzz/build ãæå®ããã°ãç¡äºã«emacsçµç±ã§cpplintãèµ·åãããã¨ãã§ãã¾ããã