本文整理汇总了Python中mozbuild.preprocessor.Preprocessor.do_include方法的典型用法代码示例。如果您正苦于以下问题:Python Preprocessor.do_include方法的具体用法?Python Preprocessor.do_include怎么用?Python Preprocessor.do_include使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozbuild.preprocessor.Preprocessor
的用法示例。
在下文中一共展示了Preprocessor.do_include方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
def main():
parser = argparse.ArgumentParser(description='Find duplicate files in directory.')
parser.add_argument('--warning', '-w', action='store_true',
help='Only warn about duplicates, do not exit with an error')
parser.add_argument('--file', '-f', action='append', dest='dupes_files', default=[],
help='Add exceptions to the duplicate list from this file')
parser.add_argument('-D', action=DefinesAction)
parser.add_argument('-U', action='append', default=[])
parser.add_argument('directory',
help='The directory to check for duplicates in')
args = parser.parse_args()
allowed_dupes = []
for filename in args.dupes_files:
pp = Preprocessor()
pp.context.update(buildconfig.defines['ALLDEFINES'])
if args.D:
pp.context.update(args.D)
for undefine in args.U:
if undefine in pp.context:
del pp.context[undefine]
pp.out = StringIO()
pp.do_filter('substitution')
pp.do_include(filename)
allowed_dupes.extend([line.partition('#')[0].rstrip()
for line in pp.out.getvalue().splitlines()])
find_dupes(args.directory, bail=not args.warning, allowed_dupes=allowed_dupes)
示例2: main
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
def main(output, input_file, version):
pp = Preprocessor()
pp.context.update({
'VERSION': version,
})
pp.out = output
pp.do_include(input_file)
示例3: main
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
def main(output, input_file):
pp = Preprocessor()
pp.context.update(buildconfig.defines['ALLDEFINES'])
substs = buildconfig.substs
# Substs taken verbatim.
substs_vars = (
'BIN_SUFFIX',
)
for var in substs_vars:
pp.context[var] = '"%s"' % substs[var]
# Derived values.
for key, condition in (
('IS_MAC', substs['OS_ARCH'] == 'Darwin'),
('IS_LINUX', substs['OS_ARCH'] == 'Linux'),
('IS_TEST_BUILD', substs.get('ENABLE_TESTS') == '1'),
('IS_DEBUG_BUILD', substs.get('MOZ_DEBUG') == '1'),
('CRASHREPORTER', substs.get('MOZ_CRASHREPORTER')),
('IS_ASAN', substs.get('MOZ_ASAN'))):
if condition:
pp.context[key] = '1'
else:
pp.context[key] = '0'
pp.context.update({
'XPC_BIN_PATH': '"%s/dist/bin"' % buildconfig.topobjdir,
'CERTS_SRC_DIR': '"%s/build/pgo/certs"' % buildconfig.topsrcdir,
})
pp.out = output
pp.do_include(input_file)
示例4: main
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
def main(output, input_file):
pp = Preprocessor()
pp.context.update({
'VERSION': 'xul%s' % buildconfig.substs['MOZILLA_SYMBOLVERSION'],
})
pp.out = output
pp.do_include(input_file)
示例5: preprocess
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
def preprocess(input, parser, defines={}):
'''
Preprocess the file-like input with the given defines, and send the
preprocessed output line by line to the given parser.
'''
pp = Preprocessor()
pp.context.update(defines)
pp.do_filter('substitution')
pp.out = PreprocessorOutputWrapper(pp, parser)
pp.do_include(input)
示例6: main
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
def main(output, input_file):
pp = Preprocessor()
pp.context.update({
'FFI_EXEC_TRAMPOLINE_TABLE': '0',
'HAVE_LONG_DOUBLE': '0',
'TARGET': buildconfig.substs['FFI_TARGET'],
'VERSION': '',
})
pp.do_filter('substitution')
pp.setMarker(None)
pp.out = output
pp.do_include(input_file)
示例7: main
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
def main(output, input_file):
pp = Preprocessor()
pp.context.update(
{
"FFI_EXEC_TRAMPOLINE_TABLE": "0",
"HAVE_LONG_DOUBLE": "0",
"TARGET": buildconfig.substs["FFI_TARGET"],
"VERSION": "",
}
)
pp.do_filter("substitution")
pp.setMarker(None)
pp.out = output
pp.do_include(input_file)
示例8: TestLineEndings
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
class TestLineEndings(unittest.TestCase):
"""
Unit tests for the Context class
"""
def setUp(self):
self.pp = Preprocessor()
self.pp.out = StringIO()
self.tempnam = os.tempnam('.')
def tearDown(self):
os.remove(self.tempnam)
def createFile(self, lineendings):
f = open(self.tempnam, 'wb')
for line, ending in zip(['a', '#literal b', 'c'], lineendings):
f.write(line+ending)
f.close()
def testMac(self):
self.createFile(['\x0D']*3)
self.pp.do_include(self.tempnam)
self.assertEquals(self.pp.out.getvalue(), 'a\nb\nc\n')
def testUnix(self):
self.createFile(['\x0A']*3)
self.pp.do_include(self.tempnam)
self.assertEquals(self.pp.out.getvalue(), 'a\nb\nc\n')
def testWindows(self):
self.createFile(['\x0D\x0A']*3)
self.pp.do_include(self.tempnam)
self.assertEquals(self.pp.out.getvalue(), 'a\nb\nc\n')
示例9: JarMaker
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
class JarMaker(object):
'''JarMaker reads jar.mn files and process those into jar files or
flat directories, along with chrome.manifest files.
'''
ignore = re.compile('\s*(\#.*)?$')
jarline = re.compile('(?:(?P<jarfile>[\w\d.\-\_\\\/{}]+).jar\:)|(?:\s*(\#.*)?)\s*$')
relsrcline = re.compile('relativesrcdir\s+(?P<relativesrcdir>.+?):')
regline = re.compile('\%\s+(.*)$')
entryre = '(?P<optPreprocess>\*)?(?P<optOverwrite>\+?)\s+'
entryline = re.compile(entryre
+ '(?P<output>[\w\d.\-\_\\\/\+\@]+)\s*(\((?P<locale>\%?)(?P<source>[\w\d.\-\_\\\/\@\*]+)\))?\s*$'
)
def __init__(self, outputFormat='flat', useJarfileManifest=True,
useChromeManifest=False):
self.outputFormat = outputFormat
self.useJarfileManifest = useJarfileManifest
self.useChromeManifest = useChromeManifest
self.pp = Preprocessor()
self.topsourcedir = None
self.sourcedirs = []
self.localedirs = None
self.l10nbase = None
self.l10nmerge = None
self.relativesrcdir = None
self.rootManifestAppId = None
def getCommandLineParser(self):
'''Get a optparse.OptionParser for jarmaker.
This OptionParser has the options for jarmaker as well as
the options for the inner PreProcessor.
'''
# HACK, we need to unescape the string variables we get,
# the perl versions didn't grok strings right
p = self.pp.getCommandLineParser(unescapeDefines=True)
p.add_option('-f', type='choice', default='jar',
choices=('jar', 'flat', 'symlink'),
help='fileformat used for output',
metavar='[jar, flat, symlink]',
)
p.add_option('-v', action='store_true', dest='verbose',
help='verbose output')
p.add_option('-q', action='store_false', dest='verbose',
help='verbose output')
p.add_option('-e', action='store_true',
help='create chrome.manifest instead of jarfile.manifest'
)
p.add_option('-s', type='string', action='append', default=[],
help='source directory')
p.add_option('-t', type='string', help='top source directory')
p.add_option('-c', '--l10n-src', type='string', action='append'
, help='localization directory')
p.add_option('--l10n-base', type='string', action='store',
help='base directory to be used for localization (requires relativesrcdir)'
)
p.add_option('--locale-mergedir', type='string', action='store'
,
help='base directory to be used for l10n-merge (requires l10n-base and relativesrcdir)'
)
p.add_option('--relativesrcdir', type='string',
help='relativesrcdir to be used for localization')
p.add_option('-j', type='string', help='jarfile directory')
p.add_option('--root-manifest-entry-appid', type='string',
help='add an app id specific root chrome manifest entry.'
)
return p
def processIncludes(self, includes):
'''Process given includes with the inner PreProcessor.
Only use this for #defines, the includes shouldn't generate
content.
'''
self.pp.out = StringIO()
for inc in includes:
self.pp.do_include(inc)
includesvalue = self.pp.out.getvalue()
if includesvalue:
logging.info('WARNING: Includes produce non-empty output')
self.pp.out = None
def finalizeJar(self, jarPath, chromebasepath, register, doZip=True):
'''Helper method to write out the chrome registration entries to
jarfile.manifest or chrome.manifest, or both.
The actual file processing is done in updateManifest.
'''
# rewrite the manifest, if entries given
if not register:
return
chromeManifest = os.path.join(os.path.dirname(jarPath), '..',
'chrome.manifest')
#.........这里部分代码省略.........
示例10: TestPreprocessor
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
class TestPreprocessor(unittest.TestCase):
"""
Unit tests for the Context class
"""
def setUp(self):
self.pp = Preprocessor()
self.pp.out = StringIO()
def do_include_compare(self, content_lines, expected_lines):
content = '%s' % '\n'.join(content_lines)
expected = '%s'.rstrip() % '\n'.join(expected_lines)
with MockedOpen({'dummy': content}):
self.pp.do_include('dummy')
self.assertEqual(self.pp.out.getvalue().rstrip('\n'), expected)
def do_include_pass(self, content_lines):
self.do_include_compare(content_lines, ['PASS'])
def test_conditional_if_0(self):
self.do_include_pass([
'#if 0',
'FAIL',
'#else',
'PASS',
'#endif',
])
def test_no_marker(self):
lines = [
'#if 0',
'PASS',
'#endif',
]
self.pp.setMarker(None)
self.do_include_compare(lines, lines)
def test_string_value(self):
self.do_include_compare([
'#define FOO STRING',
'#if FOO',
'string value is true',
'#else',
'string value is false',
'#endif',
], ['string value is false'])
def test_number_value(self):
self.do_include_compare([
'#define FOO 1',
'#if FOO',
'number value is true',
'#else',
'number value is false',
'#endif',
], ['number value is true'])
def test_conditional_if_0_elif_1(self):
self.do_include_pass([
'#if 0',
'#elif 1',
'PASS',
'#else',
'FAIL',
'#endif',
])
def test_conditional_if_1(self):
self.do_include_pass([
'#if 1',
'PASS',
'#else',
'FAIL',
'#endif',
])
def test_conditional_if_0_or_1(self):
self.do_include_pass([
'#if 0 || 1',
'PASS',
'#else',
'FAIL',
'#endif',
])
def test_conditional_if_1_elif_1_else(self):
self.do_include_pass([
'#if 1',
'PASS',
'#elif 1',
'FAIL',
'#else',
'FAIL',
'#endif',
])
def test_conditional_if_1_if_1(self):
self.do_include_pass([
'#if 1',
#.........这里部分代码省略.........
示例11: _consume_jar_manifest
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
def _consume_jar_manifest(self, obj):
# Ideally, this would all be handled somehow in the emitter, but
# this would require all the magic surrounding l10n and addons in
# the recursive make backend to die, which is not going to happen
# any time soon enough.
# Notably missing:
# - DEFINES from config/config.mk
# - L10n support
# - The equivalent of -e when USE_EXTENSION_MANIFEST is set in
# moz.build, but it doesn't matter in dist/bin.
pp = Preprocessor()
if obj.defines:
pp.context.update(obj.defines.defines)
pp.context.update(self.environment.defines)
pp.context.update(
AB_CD='en-US',
BUILD_FASTER=1,
)
pp.out = JarManifestParser()
try:
pp.do_include(obj.path.full_path)
except DeprecatedJarManifest as e:
raise DeprecatedJarManifest('Parsing error while processing %s: %s'
% (obj.path.full_path, e.message))
self.backend_input_files |= pp.includes
for jarinfo in pp.out:
jar_context = Context(
allowed_variables=VARIABLES, config=obj._context.config)
jar_context.push_source(obj._context.main_path)
jar_context.push_source(obj.path.full_path)
install_target = obj.install_target
if jarinfo.base:
install_target = mozpath.normpath(
mozpath.join(install_target, jarinfo.base))
jar_context['FINAL_TARGET'] = install_target
if obj.defines:
jar_context['DEFINES'] = obj.defines.defines
files = jar_context['FINAL_TARGET_FILES']
files_pp = jar_context['FINAL_TARGET_PP_FILES']
for e in jarinfo.entries:
if e.is_locale:
if jarinfo.relativesrcdir:
src = '/%s' % jarinfo.relativesrcdir
else:
src = ''
src = mozpath.join(src, 'en-US', e.source)
else:
src = e.source
src = Path(jar_context, src)
if '*' not in e.source and not os.path.exists(src.full_path):
if e.is_locale:
raise Exception(
'%s: Cannot find %s' % (obj.path, e.source))
if e.source.startswith('/'):
src = Path(jar_context, '!' + e.source)
else:
# This actually gets awkward if the jar.mn is not
# in the same directory as the moz.build declaring
# it, but it's how it works in the recursive make,
# not that anything relies on that, but it's simpler.
src = Path(obj._context, '!' + e.source)
output_basename = mozpath.basename(e.output)
if output_basename != src.target_basename:
src = RenamedSourcePath(jar_context,
(src, output_basename))
path = mozpath.dirname(mozpath.join(jarinfo.name, e.output))
if e.preprocess:
if '*' in e.source:
raise Exception('%s: Wildcards are not supported with '
'preprocessing' % obj.path)
files_pp[path] += [src]
else:
files[path] += [src]
if files:
self.consume_object(FinalTargetFiles(jar_context, files))
if files_pp:
self.consume_object(
FinalTargetPreprocessedFiles(jar_context, files_pp))
for m in jarinfo.chrome_manifests:
entry = parse_manifest_line(
mozpath.dirname(jarinfo.name),
m.replace('%', mozpath.basename(jarinfo.name) + '/'))
self.consume_object(ChromeManifestEntry(
jar_context, '%s.manifest' % jarinfo.name, entry))
示例12: JarMaker
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
class JarMaker(object):
'''JarMaker reads jar.mn files and process those into jar files or
flat directories, along with chrome.manifest files.
'''
def __init__(self, outputFormat='flat', useJarfileManifest=True,
useChromeManifest=False):
self.outputFormat = outputFormat
self.useJarfileManifest = useJarfileManifest
self.useChromeManifest = useChromeManifest
self.pp = Preprocessor()
self.topsourcedir = None
self.sourcedirs = []
self.localedirs = None
self.l10nbase = None
self.l10nmerge = None
self.relativesrcdir = None
self.rootManifestAppId = None
def getCommandLineParser(self):
'''Get a optparse.OptionParser for jarmaker.
This OptionParser has the options for jarmaker as well as
the options for the inner PreProcessor.
'''
# HACK, we need to unescape the string variables we get,
# the perl versions didn't grok strings right
p = self.pp.getCommandLineParser(unescapeDefines=True)
p.add_option('-f', type='choice', default='jar',
choices=('jar', 'flat', 'symlink'),
help='fileformat used for output',
metavar='[jar, flat, symlink]',
)
p.add_option('-v', action='store_true', dest='verbose',
help='verbose output')
p.add_option('-q', action='store_false', dest='verbose',
help='verbose output')
p.add_option('-e', action='store_true',
help='create chrome.manifest instead of jarfile.manifest'
)
p.add_option('-s', type='string', action='append', default=[],
help='source directory')
p.add_option('-t', type='string', help='top source directory')
p.add_option('-c', '--l10n-src', type='string', action='append'
, help='localization directory')
p.add_option('--l10n-base', type='string', action='store',
help='base directory to be used for localization (requires relativesrcdir)'
)
p.add_option('--locale-mergedir', type='string', action='store'
,
help='base directory to be used for l10n-merge (requires l10n-base and relativesrcdir)'
)
p.add_option('--relativesrcdir', type='string',
help='relativesrcdir to be used for localization')
p.add_option('-d', type='string', help='base directory')
p.add_option('--root-manifest-entry-appid', type='string',
help='add an app id specific root chrome manifest entry.'
)
return p
def processIncludes(self, includes):
'''Process given includes with the inner PreProcessor.
Only use this for #defines, the includes shouldn't generate
content.
'''
self.pp.out = StringIO()
for inc in includes:
self.pp.do_include(inc)
includesvalue = self.pp.out.getvalue()
if includesvalue:
logging.info('WARNING: Includes produce non-empty output')
self.pp.out = None
def finalizeJar(self, jardir, jarbase, jarname, chromebasepath, register, doZip=True):
'''Helper method to write out the chrome registration entries to
jarfile.manifest or chrome.manifest, or both.
The actual file processing is done in updateManifest.
'''
# rewrite the manifest, if entries given
if not register:
return
chromeManifest = os.path.join(jardir, jarbase, 'chrome.manifest')
if self.useJarfileManifest:
self.updateManifest(os.path.join(jardir, jarbase,
jarname + '.manifest'),
chromebasepath.format(''), register)
if jarname != 'chrome':
addEntriesToListFile(chromeManifest,
['manifest {0}.manifest'.format(jarname)])
if self.useChromeManifest:
chromebase = os.path.dirname(jarname) + '/'
#.........这里部分代码省略.........
示例13: JarMaker
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
class JarMaker(object):
"""JarMaker reads jar.mn files and process those into jar files or
flat directories, along with chrome.manifest files.
"""
ignore = re.compile("\s*(\#.*)?$")
jarline = re.compile("(?:(?P<jarfile>[\w\d.\-\_\\\/{}]+).jar\:)|(?:\s*(\#.*)?)\s*$")
relsrcline = re.compile("relativesrcdir\s+(?P<relativesrcdir>.+?):")
regline = re.compile("\%\s+(.*)$")
entryre = "(?P<optPreprocess>\*)?(?P<optOverwrite>\+?)\s+"
entryline = re.compile(
entryre + "(?P<output>[\w\d.\-\_\\\/\+\@]+)\s*(\((?P<locale>\%?)(?P<source>[\w\d.\-\_\\\/\@\*]+)\))?\s*$"
)
def __init__(self, outputFormat="flat", useJarfileManifest=True, useChromeManifest=False):
self.outputFormat = outputFormat
self.useJarfileManifest = useJarfileManifest
self.useChromeManifest = useChromeManifest
self.pp = Preprocessor()
self.topsourcedir = None
self.sourcedirs = []
self.localedirs = None
self.l10nbase = None
self.l10nmerge = None
self.relativesrcdir = None
self.rootManifestAppId = None
def getCommandLineParser(self):
"""Get a optparse.OptionParser for jarmaker.
This OptionParser has the options for jarmaker as well as
the options for the inner PreProcessor.
"""
# HACK, we need to unescape the string variables we get,
# the perl versions didn't grok strings right
p = self.pp.getCommandLineParser(unescapeDefines=True)
p.add_option(
"-f",
type="choice",
default="jar",
choices=("jar", "flat", "symlink"),
help="fileformat used for output",
metavar="[jar, flat, symlink]",
)
p.add_option("-v", action="store_true", dest="verbose", help="verbose output")
p.add_option("-q", action="store_false", dest="verbose", help="verbose output")
p.add_option("-e", action="store_true", help="create chrome.manifest instead of jarfile.manifest")
p.add_option("-s", type="string", action="append", default=[], help="source directory")
p.add_option("-t", type="string", help="top source directory")
p.add_option("-c", "--l10n-src", type="string", action="append", help="localization directory")
p.add_option(
"--l10n-base",
type="string",
action="store",
help="base directory to be used for localization (requires relativesrcdir)",
)
p.add_option(
"--locale-mergedir",
type="string",
action="store",
help="base directory to be used for l10n-merge (requires l10n-base and relativesrcdir)",
)
p.add_option("--relativesrcdir", type="string", help="relativesrcdir to be used for localization")
p.add_option("-j", type="string", help="jarfile directory")
p.add_option(
"--root-manifest-entry-appid", type="string", help="add an app id specific root chrome manifest entry."
)
return p
def processIncludes(self, includes):
"""Process given includes with the inner PreProcessor.
Only use this for #defines, the includes shouldn't generate
content.
"""
self.pp.out = StringIO()
for inc in includes:
self.pp.do_include(inc)
includesvalue = self.pp.out.getvalue()
if includesvalue:
logging.info("WARNING: Includes produce non-empty output")
self.pp.out = None
def finalizeJar(self, jarPath, chromebasepath, register, doZip=True):
"""Helper method to write out the chrome registration entries to
jarfile.manifest or chrome.manifest, or both.
The actual file processing is done in updateManifest.
"""
# rewrite the manifest, if entries given
if not register:
return
chromeManifest = os.path.join(os.path.dirname(jarPath), "..", "chrome.manifest")
#.........这里部分代码省略.........
示例14: parse_defines
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
def parse_defines(paths):
pp = Preprocessor()
for path in paths:
pp.do_include(path)
return pp.context
示例15: generate_symbols_file
# 需要导入模块: from mozbuild.preprocessor import Preprocessor [as 别名]
# 或者: from mozbuild.preprocessor.Preprocessor import do_include [as 别名]
def generate_symbols_file(output, *args):
''' '''
parser = argparse.ArgumentParser()
parser.add_argument('input')
parser.add_argument('-D', action=DefinesAction)
parser.add_argument('-U', action='append', default=[])
args = parser.parse_args(args)
input = os.path.abspath(args.input)
pp = Preprocessor()
pp.context.update(buildconfig.defines)
if args.D:
pp.context.update(args.D)
for undefine in args.U:
if undefine in pp.context:
del pp.context[undefine]
# Hack until MOZ_DEBUG_FLAGS are simply part of buildconfig.defines
if buildconfig.substs['MOZ_DEBUG']:
pp.context['DEBUG'] = '1'
# Ensure @[email protected] works as expected (see the Windows section further below)
if buildconfig.substs['OS_TARGET'] == 'WINNT':
pp.context['DATA'] = 'DATA'
else:
pp.context['DATA'] = ''
pp.out = StringIO()
pp.do_filter('substitution')
pp.do_include(input)
symbols = [s.strip() for s in pp.out.getvalue().splitlines() if s.strip()]
if buildconfig.substs['OS_TARGET'] == 'WINNT':
# A def file is generated for MSVC link.exe that looks like the
# following:
# LIBRARY library.dll
# EXPORTS
# symbol1
# symbol2
# ...
#
# link.exe however requires special markers for data symbols, so in
# that case the symbols look like:
# data_symbol1 DATA
# data_symbol2 DATA
# ...
#
# In the input file, this is just annotated with the following syntax:
# data_symbol1 @[email protected]
# data_symbol2 @[email protected]
# ...
# The DATA variable is "simply" expanded by the preprocessor, to
# nothing on non-Windows, such that we only get the symbol name on
# those platforms, and to DATA on Windows, so that the "DATA" part
# is, in fact, part of the symbol name as far as the symbols variable
# is concerned.
libname, ext = os.path.splitext(os.path.basename(output.name))
assert ext == '.def'
output.write('LIBRARY %s\nEXPORTS\n %s\n'
% (libname, '\n '.join(symbols)))
elif buildconfig.substs['GCC_USE_GNU_LD']:
# A linker version script is generated for GNU LD that looks like the
# following:
# {
# global:
# symbol1;
# symbol2;
# ...
# local:
# *;
# };
output.write('{\nglobal:\n %s;\nlocal:\n *;\n};'
% ';\n '.join(symbols))
elif buildconfig.substs['OS_TARGET'] == 'Darwin':
# A list of symbols is generated for Apple ld that simply lists all
# symbols, with an underscore prefix.
output.write(''.join('_%s\n' % s for s in symbols))
return set(pp.includes)