wscript 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. from waflib import Task, TaskGen
  4. top = '.'
  5. out = 'build'
  6. APPNAME = 'TestProject'
  7. VERSION = '1.0'
  8. """
  9. To create the xcode project files:
  10. waf configure xcode6
  11. To configure and build using Waf:
  12. waf configure build
  13. This demo will create an XCode project containing
  14. an App bundle target, a dynamic library target,
  15. a static library target and an executable target.
  16. The generated XCode project can then be opened
  17. and XCode can then build those targets.
  18. Tested with XCode 8.
  19. """
  20. def options(opt):
  21. opt.load('compiler_cxx xcode6')
  22. def configure(conf):
  23. # Use environment variables to set default project configuration
  24. # settings
  25. conf.env.FRAMEWORK_VERSION = '1.0'
  26. conf.env.ARCHS = 'x86_64'
  27. conf.env.INSTALL_PATH = '/my/install/path'
  28. # The xcode6 tool will also pick up any c config files generated by
  29. # the c_config tool, and it'll be added to your project's include path
  30. conf.load('c_config')
  31. conf.define('NUMBER', 10)
  32. conf.write_config_header('config.h')
  33. # This must be called at the end of configure()
  34. conf.load('compiler_cxx xcode6')
  35. conf.env.append_value('CXXFLAGS', ['-O2'])
  36. conf.check(cxxflags='-std=c++11', uselib_store='STD11', mandatory=False)
  37. def build(bld):
  38. # Make .framework targets
  39. tg = bld.framework(
  40. includes='include',
  41. # Source files
  42. source=bld.path.ant_glob('src/MyLib/*.cpp'),
  43. # If you don't want the source files to appear in a default
  44. # 'Source' folder, you can define your own folder structure
  45. # using a dictionary, where the key is the desired name of the folder
  46. # and the value are the files.
  47. group_files={
  48. 'Source files': bld.path.ant_glob('src/MyLib/*.cpp|*.m|*.mm'),
  49. 'Include': bld.path.ant_glob(incl=['include/MyLib/*.h'], dir=True),
  50. 'Help': ['src/sample.txt']
  51. },
  52. # If you want to ship your header files with your .framework, then
  53. # specify them using the 'export_headers' param
  54. export_headers=bld.path.ant_glob(incl=['include/MyLib/*.h', 'include/MyLib/SupportLib/*.h']),
  55. target='MyLib',
  56. # The 'install' param will set the INSTALL_PATH for the
  57. # binary, and will also trigger XCode to copy the target to that
  58. # path
  59. install='~/Library/Frameworks'
  60. )
  61. # Make .a static library targets
  62. bld.stlib(
  63. source=bld.path.ant_glob('src/MyLib/*.cpp'),
  64. includes = 'include',
  65. target='MyStaticLib',
  66. )
  67. # Make standard executable target
  68. bld.program(
  69. source=['src/test.cpp'],
  70. includes='include',
  71. target='MyExe',
  72. use='MyDynLib STD11'
  73. )
  74. # Make .dylib shared libraries
  75. bld.shlib(
  76. source=bld.path.ant_glob('src/MyLib/*.cpp'),
  77. includes='include',
  78. target='MyDynLib',
  79. )
  80. # Make an app bundle target
  81. tg2 = bld.app(
  82. source=bld.path.ant_glob('src/*.cpp'),
  83. includes='include',
  84. target='MyApp',
  85. use='MyLib',
  86. uselib='SDL2',
  87. cxxflags='-DSOME_DEFINE',
  88. framework='Cocoa',
  89. # Override default setting in a target
  90. settings={"Debug": {"CONFIG_NAME": 'Debug'}}
  91. )