mirror of https://gitlab.com/ita1024/waf.git
Added more target types. Added bld wrappers
This commit is contained in:
parent
7d50934a8e
commit
3924f60974
|
@ -39,4 +39,23 @@ def build(bld):
|
||||||
framework='Cocoa',
|
framework='Cocoa',
|
||||||
settings={"Debug": {"CONFIG_NAME": 'Debug'}}
|
settings={"Debug": {"CONFIG_NAME": 'Debug'}}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
bld.dylib(
|
||||||
|
source=tg.source,
|
||||||
|
includes=tg.includes,
|
||||||
|
target='MyDynLibYo',
|
||||||
|
)
|
||||||
|
|
||||||
|
bld.exe(
|
||||||
|
source=tg.source,
|
||||||
|
includes=tg.includes,
|
||||||
|
target='MyExe',
|
||||||
|
)
|
||||||
|
|
||||||
|
bld.program(
|
||||||
|
source=tg.source,
|
||||||
|
includes=tg.includes,
|
||||||
|
target='MyStaticLib',
|
||||||
|
target_type='stlib'
|
||||||
|
)
|
||||||
|
|
|
@ -17,6 +17,7 @@ $ waf configure xcode
|
||||||
# TODO: support iOS projects
|
# TODO: support iOS projects
|
||||||
|
|
||||||
from waflib import Context, TaskGen, Build, Utils, ConfigSet, Configure, Errors
|
from waflib import Context, TaskGen, Build, Utils, ConfigSet, Configure, Errors
|
||||||
|
from waflib.Build import BuildContext
|
||||||
import os, sys, random, time
|
import os, sys, random, time
|
||||||
|
|
||||||
@TaskGen.extension('.m', '.mm')
|
@TaskGen.extension('.m', '.mm')
|
||||||
|
@ -59,7 +60,7 @@ MAP_EXT = {
|
||||||
# Used in PBXNativeTarget elements
|
# Used in PBXNativeTarget elements
|
||||||
PRODUCT_TYPE_APPLICATION = 'com.apple.product-type.application'
|
PRODUCT_TYPE_APPLICATION = 'com.apple.product-type.application'
|
||||||
PRODUCT_TYPE_FRAMEWORK = 'com.apple.product-type.framework'
|
PRODUCT_TYPE_FRAMEWORK = 'com.apple.product-type.framework'
|
||||||
PRODUCT_TYPE_TOOL = 'com.apple.product-type.tool'
|
PRODUCT_TYPE_EXECUTABLE = 'com.apple.product-type.tool'
|
||||||
PRODUCT_TYPE_LIB_STATIC = 'com.apple.product-type.library.static'
|
PRODUCT_TYPE_LIB_STATIC = 'com.apple.product-type.library.static'
|
||||||
PRODUCT_TYPE_LIB_DYNAMIC = 'com.apple.product-type.library.dynamic'
|
PRODUCT_TYPE_LIB_DYNAMIC = 'com.apple.product-type.library.dynamic'
|
||||||
PRODUCT_TYPE_EXTENSION = 'com.apple.product-type.kernel-extension'
|
PRODUCT_TYPE_EXTENSION = 'com.apple.product-type.kernel-extension'
|
||||||
|
@ -68,17 +69,42 @@ PRODUCT_TYPE_IOKIT = 'com.apple.product-type.kernel-extension.iokit'
|
||||||
# Used in PBXFileReference elements
|
# Used in PBXFileReference elements
|
||||||
FILE_TYPE_APPLICATION = 'wrapper.cfbundle'
|
FILE_TYPE_APPLICATION = 'wrapper.cfbundle'
|
||||||
FILE_TYPE_FRAMEWORK = 'wrapper.framework'
|
FILE_TYPE_FRAMEWORK = 'wrapper.framework'
|
||||||
|
FILE_TYPE_LIB_DYNAMIC = 'compiled.mach-o.dylib'
|
||||||
|
FILE_TYPE_LIB_STATIC = 'archive.ar'
|
||||||
|
FILE_TYPE_EXECUTABLE = 'compiled.mach-o.executable'
|
||||||
|
|
||||||
# Tuple packs of the above
|
# Tuple packs of the above
|
||||||
TARGET_TYPE_FRAMEWORK = (PRODUCT_TYPE_FRAMEWORK, FILE_TYPE_FRAMEWORK, '.framework')
|
TARGET_TYPE_FRAMEWORK = (PRODUCT_TYPE_FRAMEWORK, FILE_TYPE_FRAMEWORK, '.framework')
|
||||||
TARGET_TYPE_APPLICATION = (PRODUCT_TYPE_APPLICATION, FILE_TYPE_APPLICATION, '.app')
|
TARGET_TYPE_APPLICATION = (PRODUCT_TYPE_APPLICATION, FILE_TYPE_APPLICATION, '.app')
|
||||||
|
TARGET_TYPE_DYNAMIC_LIB = (PRODUCT_TYPE_LIB_DYNAMIC, FILE_TYPE_LIB_DYNAMIC, '.dylib')
|
||||||
|
TARGET_TYPE_STATIC_LIB = (PRODUCT_TYPE_LIB_STATIC, FILE_TYPE_LIB_STATIC, '.a')
|
||||||
|
TARGET_TYPE_EXECUTABLE = (PRODUCT_TYPE_EXECUTABLE, FILE_TYPE_EXECUTABLE, '')
|
||||||
|
|
||||||
# Maps target type string to its data
|
# Maps target type string to its data
|
||||||
TARGET_TYPES = {
|
TARGET_TYPES = {
|
||||||
'framework': TARGET_TYPE_FRAMEWORK,
|
'framework': TARGET_TYPE_FRAMEWORK,
|
||||||
'app': TARGET_TYPE_APPLICATION
|
'app': TARGET_TYPE_APPLICATION,
|
||||||
|
'dylib': TARGET_TYPE_DYNAMIC_LIB,
|
||||||
|
'stlib': TARGET_TYPE_STATIC_LIB,
|
||||||
|
'exe' :TARGET_TYPE_EXECUTABLE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
""" Provide user-friendly methods to build different target types
|
||||||
|
E.g. bld.framework(source='..', ...) to build a Framework target.
|
||||||
|
E.g. bld.dylib(source='..', ...) to build a Dynamic library target.
|
||||||
|
etc...
|
||||||
|
"""
|
||||||
|
def build_target(self, tgtype, *k, **kw):
|
||||||
|
kw['features'] = 'cxx cxxprogram'
|
||||||
|
kw['target_type'] = tgtype
|
||||||
|
return self(*k, **kw)
|
||||||
|
|
||||||
|
BuildContext.app = lambda self, *k, **kw: build_target(self, 'app', *k, **kw)
|
||||||
|
BuildContext.framework = lambda self, *k, **kw: build_target(self, 'framework', *k, **kw)
|
||||||
|
BuildContext.dylib = lambda self, *k, **kw: build_target(self, 'dylib', *k, **kw)
|
||||||
|
BuildContext.stlib = lambda self, *k, **kw: build_target(self, 'stlib', *k, **kw)
|
||||||
|
BuildContext.exe = lambda self, *k, **kw: build_target(self, 'exe', *k, **kw)
|
||||||
|
|
||||||
class XcodeConfiguration(Configure.ConfigurationContext):
|
class XcodeConfiguration(Configure.ConfigurationContext):
|
||||||
""" Configuration of the global project settings. Sets an environment variable 'PROJ_CONFIGURATION'
|
""" Configuration of the global project settings. Sets an environment variable 'PROJ_CONFIGURATION'
|
||||||
which is a dictionary of configuration name and buildsettings pair.
|
which is a dictionary of configuration name and buildsettings pair.
|
||||||
|
@ -100,11 +126,9 @@ class XcodeConfiguration(Configure.ConfigurationContext):
|
||||||
self.init_dirs()
|
self.init_dirs()
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
|
|
||||||
# Run user configure()
|
# Run user configure()
|
||||||
Configure.ConfigurationContext.execute(self)
|
Configure.ConfigurationContext.execute(self)
|
||||||
|
|
||||||
|
|
||||||
if not self.env.PROJ_CONFIGURATION:
|
if not self.env.PROJ_CONFIGURATION:
|
||||||
self.to_log("A default project configuration was created since no custom one was given in the configure(conf) stage. Define your custom project settings by adding PROJ_CONFIGURATION to env. The env.PROJ_CONFIGURATION must be a dictionary with at least one key, where each key is the configuration name, and the value is a dictionary of key/value settings.\n")
|
self.to_log("A default project configuration was created since no custom one was given in the configure(conf) stage. Define your custom project settings by adding PROJ_CONFIGURATION to env. The env.PROJ_CONFIGURATION must be a dictionary with at least one key, where each key is the configuration name, and the value is a dictionary of key/value settings.\n")
|
||||||
|
|
||||||
|
@ -348,7 +372,7 @@ class PBXProject(XCodeNode):
|
||||||
XCodeNode.__init__(self)
|
XCodeNode.__init__(self)
|
||||||
|
|
||||||
if not isinstance(env.PROJ_CONFIGURATION, dict):
|
if not isinstance(env.PROJ_CONFIGURATION, dict):
|
||||||
raise Errors.WafError("env.PROJ_CONFIGURATION is not a dictionary. Did you import the xcode module in your wscript?")
|
raise Errors.WafError("Error: env.PROJ_CONFIGURATION must be a dictionary. This is done for you if you do not define one yourself. However, did you load the xcode module in your wscript configure() ?")
|
||||||
|
|
||||||
# Retreive project configuration
|
# Retreive project configuration
|
||||||
configurations = []
|
configurations = []
|
||||||
|
|
Loading…
Reference in New Issue