yaml ã£ã¦ Makefile ãæ¸ãã®ã«åãã¦ãããããªããï¼
è¨å®ãã¡ã¤ã«ã¨ãã¦ãç§ã¯ yaml ããæ°ã«å ¥ãã§ãã
ãªãã¨ãã£ã¦ãè¨è¿°éãå°ãªããDSL ãããã§ããããã£ã±ãç¹ååã«ã¯æµããªãã¨æãã¾ããã¾ããã©ã¤ãã©ãªãè±å¯ã§ä¸»è¦ãªããã°ã©ãã³ã°è¨èªã®ã»ã¨ãã©ã§ä½¿ããã¨ããã®ãé åã§ãã
話ã¯å¤ãã£ã¦「C/C++ 開発のストレスを軽減する」ã§è§¦ããã¨ããããã«ããã¼ã«ã¨ã㦠SConsãCMake ããæ°ã«å ¥ãã§ãããã ããSCons 㯠Python ãªã®ã§ã©ããã¦ãæååãä½ããã®å¼ç¨ç¬¦ã§æ¬ãå¿ è¦ãããã¨ãããã¨ã«ä¸æºãããã¾ããCMake ã¯å°ç¨ã®æ¸å¼ã§æ¸ããªããã°ãªããªãã¨ãããã¨ã«ä¸æºãããã¾ãã
ä¾ãã°ãSCons 㨠CMake 㧠hello world ããã«ãããã¨ããèãã¦ã¿ã¾ãã
# Scons Program(target = "hello", source = ["helloworld.c"])
# CMake project(hello c) add_executable(hello helloworld.c)
ãããããã ã¨ã©ã£ã¡ãååã«ã·ã³ãã«ãªã®ã§ãã©ã£ã¡ã§æ¸ãã¦ãããããªãã¨ããæ°ããã¾ãããä»®ã«ããã®ããã°ã©ã ãé 調ã«è²ã¡ã½ã¼ã¹ã³ã¼ããå¢ãã¦ãã£ãã¨ãã¾ãããã
# Scons Program(target = "hello", source = ["helloworld.c", "helloearth.c", "hellouniverse.c"])
# CMake project(hello c) add_executable(hello helloworld.c helloearth.c hellouniverse.c)
ã¾ã 大ä¸å¤«ã§ããã次ã«ããã©ãããã©ã¼ã æ¯ã«ç°ãªãã½ã¼ã¹ã³ã¼ããã³ã³ãã¤ã«ããããªã£ãã¨ãã¾ãããã
# Scons import os env = Environment() platform = env['PLATFORM'] sources = ["helloworld.c", "helloearth.c", "hellouniverse.c"] if platform == 'posix': sources.append('helloposx.c') elif platform == 'darwin': sources.append('hellodarwin.c') elif platform == 'win32': sources.append('hellowin32.c') env.Program(target = "hello", source = sources)
# CMake project(hello c) set(sources) if (UNIX) set(sources helloworld.c helloearth.c hellouniverse.c helloposix.c) elseif (APPLE) set(sources helloworld.c helloearth.c hellouniverse.c hellodarwin.c) elseif (WIN32) set(sources helloworld.c helloearth.c hellouniverse.c hellowin32.c) endif add_executable(hello ${sources})
ã©ã¡ããä¸æ°ã«éæ®ã£ãããªãã¾ããã*1ãããã§ãã©ããã風ã«æ¸ãããããèãã¦ã¿ã¾ãããã
project: name: hello type: executable source: general: [helloworld.c, helloearth.c, hellouniverse.c] posix: [helloposix.c] darwin: [hellodarwin.c] win32: [hellowin32.c]
ã½ã¼ã¹ã³ã¼ãããã£ã¨å¢ãã¦ãããã¨ãèããã¨ã次ã®ããã«æ¸ãã¹ãããããã¾ããã
project: name: hello type: executable source: general: - helloworld.c - helloearth.c - hellouniverse.c posix: - helloposix.c darwin: - hellodarwin.c win32: - hellowin32.c
ããã ã¨ãã£ãããã¾ãããã½ã¼ã¹ã³ã¼ãã²ã¨ã¤ã«ã¤ããã¤ãã³ãããã®ãåä»ã§ãããå¼ç¨ç¬¦ã§æ¬ãããã楽ã ã¨æãã¾ãã
ããã«ããã°ã©ã ã大ãããªãã¨ãä»ã®ã©ã¤ãã©ãªã使ããããªãããããã¾ãããããããã¨ãinclude ãã£ã¬ã¯ããªã®è¿½å ã¨ããlib ãã£ã¬ã¯ããªã追å ããå¿ è¦ãåºã¦ãã¾ãã
project: name: hello type: executable source: general: - helloworld.c - helloearth.c - hellouniverse.c posix: - helloposix.c darwin: - hellodarwin.c win32: - hellowin32.c incdir: - contrib/include libdir: - contrib/lib lib: - foo
æ¡ä»¶ä»ãã³ã³ãã¤ã«ããã£ã¦ã¿ã¾ãããã
project: name: hello type: executable source: general: - helloworld.c - helloearth.c - hellouniverse.c posix: - helloposix.c darwin: - hellodarwin.c win32: - hellowin32.c ENABLE_XXX: - xxx.c incdir: - contrib/include libdir: - contrib/lib lib: - foo
ãã«ããã©ãããã©ã¼ã åãã«éçºããã¨ãã«ã¯ããªã³ã¯ããã©ã¤ãã©ãªãã³ã³ãã¤ã«ããã½ã¼ã¹ã³ã¼ãã¯ãã©ãããã©ã¼ã ãã¨ã«ç°ãªãã®ã§ãããå°ãæ¸ãæ¹ã工夫ãã¦ã¿ã¾ãã
project: name: hello type: executable source: - helloworld.c - helloearth.c - hellouniverse.c incdir: - contrib/include libdir: - contrib/lib lib: - foo platform_posix: source: - helloposix.c platform_darwin: source: - hellodarwin.c platform_win32: source: - hellowin32.c
platform_xxx ã§ã¯ããããã¬ãã«ã§ã® incdirãlibdirãlib ã使ããã¨ããã¤ã¡ã¼ã¸ã§ããã
ããã ã¨ã解æãç°¡åãªã®ã§ãããã Autotools ç¨ã®ãã¡ã¤ã«ãä½ã£ãããSCons ç¨ã®ãã¡ã¤ã«ãä½ã£ãããVisual Studio ç¨ã®ããã¸ã§ã¯ããã¡ã¤ã«ãä½ã£ãããnmake ç¨ã®ã¡ã¤ã¯ãã¡ã¤ã«ãä½ã£ããã¨ã夢ãåºããã¾ããæ¢åã®ãã«ããã¼ã«ããã®ç§»è¡ãèããã¨ãããã§æãããããªä½ãã ãã§ã¯å°åºæ©è½ã足ãã¾ããããã¾ããªãã¨ããªãããããªãããªãã¨æãã¾ãã
ããã§æãã YAML ã¯「Rubyist Magazine - プログラマーのための YAML 入門 (初級編)」ã® print-yaml.rb ã§åºåã確èªããã®ã§å¤åæ§æçã«ééãã¯ãªãã¨æãã¾ãã
*1:ãã£ã¨ããæ¸ãæ¹ããåç¥ã®æ¹ã¯æ¯éãææãã»ã»ã»