waf/playground/xcode6/wscript

112 lines
2.8 KiB
Python

#! /usr/bin/env python
# encoding: utf-8
from waflib import Task, TaskGen
top = '.'
out = 'build'
APPNAME = 'TestProject'
VERSION = '1.0'
"""
To create the xcode project files:
waf configure xcode6
To configure and build using Waf:
waf configure build
This demo will create an XCode project containing
an App bundle target, a dynamic library target,
a static library target and an executable target.
The generated XCode project can then be opened
and XCode can then build those targets.
Tested with XCode 8.
"""
def options(opt):
opt.load('compiler_cxx xcode6')
def configure(conf):
# Use environment variables to set default project configuration
# settings
conf.env.FRAMEWORK_VERSION = '1.0'
conf.env.ARCHS = 'x86_64'
conf.env.INSTALL_PATH = '/my/install/path'
# The xcode6 tool will also pick up any c config files generated by
# the c_config tool, and it'll be added to your project's include path
conf.load('c_config')
conf.define('NUMBER', 10)
conf.write_config_header('config.h')
# This must be called at the end of configure()
conf.load('compiler_cxx xcode6')
conf.check(cxxflags='-std=c++11', uselib_store='STD11', mandatory=False)
def build(bld):
# Make .framework targets
tg = bld.framework(
includes='include',
# Source files
source=bld.path.ant_glob('src/MyLib/*.cpp'),
# If you don't want the source files to appear in a default
# 'Source' folder, you can define your own folder structure
# using a dictionary, where the key is the desired name of the folder
# and the value are the files.
group_files={
'Source files': bld.path.ant_glob('src/MyLib/*.cpp|*.m|*.mm'),
'Include': bld.path.ant_glob(incl=['include/MyLib/*.h'], dir=True),
'Help': ['src/sample.txt']
},
# If you want to ship your header files with your .framework, then
# specify them using the 'export_headers' param
export_headers=bld.path.ant_glob(incl=['include/MyLib/*.h', 'include/MyLib/SupportLib/*.h']),
target='MyLib',
# The 'install' param will set the INSTALL_PATH for the
# binary, and will also trigger XCode to copy the target to that
# path
install='~/Library/Frameworks'
)
# Make .a static library targets
bld.stlib(
source=bld.path.ant_glob('src/MyLib/*.cpp'),
includes = 'include',
target='MyStaticLib',
)
# Make standard executable target
bld.program(
source=['src/test.cpp'],
includes='include',
target='MyExe',
use='MyDynLib'
)
# Make .dylib shared libraries
bld.shlib(
source=bld.path.ant_glob('src/MyLib/*.cpp'),
includes='include',
target='MyDynLib',
)
# Make an app bundle target
tg2 = bld.app(
source=bld.path.ant_glob('src/*.cpp'),
includes='include',
target='MyApp',
use='MyLib',
uselib='SDL2',
cxxflags='-O3',
framework='Cocoa',
# Override default setting in a target
settings={"Debug": {"CONFIG_NAME": 'Debug'}}
)