Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def set_library_order (manager, sources, prop_set, result):
used_libraries = []
deps = prop_set.dependency ()
sources.extend(d.value for d in deps)
sources = sequence.unique(sources)
for l in sources:
if l.type () and type.is_derived (l.type (), 'LIB'):
used_libraries.append (l)
created_libraries = []
for l in result:
if l.type () and type.is_derived (l.type (), 'LIB'):
created_libraries.append (l)
created_libraries = set.difference (created_libraries, used_libraries)
set_library_order_aux (created_libraries, used_libraries)
Might return:
boost_thread-vc80-mt-gd-1_33.dll, or
boost_regex-vc80-gd-1_33.dll
The returned name also has the target type specific prefix and suffix which
puts it in a ready form to use as the value from a custom tag rule.
"""
if __debug__:
from ..build.property_set import PropertySet
assert is_iterable_typed(format, basestring)
assert isinstance(name, basestring)
assert isinstance(target_type, basestring)
assert isinstance(prop_set, PropertySet)
# assert(isinstance(prop_set, property_set.PropertySet))
if type.is_derived(target_type, 'LIB'):
result = "" ;
for f in format:
grist = get_grist(f)
if grist == '':
result += os.path.basename(name)
elif grist == '':
result += join_tag(get_value(f),
toolset_tag(name, target_type, prop_set))
elif grist == '':
result += join_tag(get_value(f),
threading_tag(name, target_type, prop_set))
elif grist == '':
result += join_tag(get_value(f),
runtime_tag(name, target_type, prop_set))
elif grist.startswith('
def run_pch(self, project, name, prop_set, sources):
# Find the header in sources. Ignore any CPP sources.
pch_header = None
pch_source = None
for s in sources:
if type.is_derived(s.type(), 'H'):
pch_header = s
elif type.is_derived(s.type(), 'CPP') or type.is_derived(s.type(), 'C'):
pch_source = s
if not pch_header:
raise RuntimeError( "can not build pch without pch-header" )
# If we do not have the PCH source - that is fine. We will just create a
# temporary .cpp file in the action.
properties = prop_set.all()
# Passing of is a dirty trick, needed because
# non-composing generators with multiple inputs are subtly
# broken. For more detailed information see:
# https://zigzag.cs.msu.su:7813/boost.build/ticket/111
if pch_source:
properties.append(Property('pch-source',pch_source))
generated = Generator.run(self,project,name,property_set.create(properties),[pch_header])
pch_file = None
def run_pch(self, project, name, prop_set, sources):
# Find the header in sources. Ignore any CPP sources.
pch_header = None
pch_source = None
for s in sources:
if type.is_derived(s.type(), 'H'):
pch_header = s
elif type.is_derived(s.type(), 'CPP') or type.is_derived(s.type(), 'C'):
pch_source = s
if not pch-header:
raise RuntimeError( "can not build pch without pch-header" )
# If we do not have the PCH source - that is fine. We will just create a
# temporary .cpp file in the action.
temp_prop_set = property_set.create([Property('pch-source',pch_source)]+prop_set.all())
generated = Generator.run(project,name,temp_prop_set,pch_header)
pch_file = None
for g in generated:
if type.is_derived(g.type(), 'PCH'):
pch_file = g
return property_set.create([Property('pch-header',pch_header),Property('pch-file',pch_file)]+generated)
##FIXME: what does this mean?
## {
## switch [ modules.peek : JAMUNAME ]
## {
## case * : no-static-link = true ;
## }
## }
reason = None
if no_static_link and ps.get('runtime-link') == 'static':
if ps.get('link') == 'shared':
reason = "On gcc, DLL can't be build with 'static'."
elif type.is_derived(self.target_types[0], 'EXE'):
for s in sources:
source_type = s.type()
if source_type and type.is_derived(source_type, 'SHARED_LIB'):
reason = "On gcc, using DLLS together with the " +\
"static options is not possible "
if reason:
print 'warning:', reason
print 'warning:',\
"It is suggested to use 'static' together",\
"with 'static'." ;
return
else:
generated_targets = unix.UnixLinkingGenerator.run(self, project,
name, ps, sources)
return generated_targets
def compute_target_directories(self, target_type=None):
assert isinstance(target_type, (basestring, type(None)))
result = []
for t in self.created_targets():
if not target_type or b2.build.type.is_derived(t.type(), target_type):
result.append(t.path())
for d in self.other_dg_:
result.extend(d.all_target_directories(target_type))
result = unique(result)
return result
# for such target, but still need to add proper dll-path properties.
extra_xdll_path = []
for s in sources:
if type.is_derived (s.type (), 'SHARED_LIB') and not s.action ():
# Unfortunately, we don't have a good way to find the path
# to a file, so use this nasty approach.
p = s.project()
location = path.root(s.name(), p.get('source-location')[0])
extra_xdll_path.append(os.path.dirname(location))
# Hardcode DLL paths only when linking executables.
# Pros: do not need to relink libraries when installing.
# Cons: "standalone" libraries (plugins, python extensions) can not
# hardcode paths to dependent libraries.
if prop_set.get('') == ['true'] \
and type.is_derived(self.target_types_ [0], 'EXE'):
xdll_path = prop_set.get('')
extra.extend(property.Property('', sp) \
for sp in extra_xdll_path)
extra.extend(property.Property('', sp) \
for sp in xdll_path)
if extra:
prop_set = prop_set.add_raw (extra)
result = generators.Generator.run(self, project, name, prop_set, sources)
if result:
ur = self.extra_usage_requirements(result, prop_set)
ur = ur.add(property_set.create(['' + p for p in extra_xdll_path]))
else:
return None
return (ur, result)
def run_pch(self, project, name, prop_set, sources):
# Find the header in sources. Ignore any CPP sources.
pch_header = None
pch_source = None
for s in sources:
if type.is_derived(s.type(), 'H'):
pch_header = s
elif type.is_derived(s.type(), 'CPP') or type.is_derived(s.type(), 'C'):
pch_source = s
if not pch-header:
raise RuntimeError( "can not build pch without pch-header" )
# If we do not have the PCH source - that is fine. We will just create a
# temporary .cpp file in the action.
temp_prop_set = property_set.create([Property('pch-source',pch_source)]+prop_set.all())
generated = Generator.run(project,name,temp_prop_set,pch_header)
pch_file = None
for g in generated:
if type.is_derived(g.type(), 'PCH'):
pch_file = g
return property_set.create([Property('pch-header',pch_header),Property('pch-file',pch_file)]+generated)
assert is_iterable_typed(sources, virtual_target.VirtualTarget)
assert isinstance(prop_set, property_set.PropertySet)
assert isinstance(project, targets.ProjectTarget)
assert isinstance(name, basestring)
# sources to pass to inherited rule
sources2 = []
# sources which are libraries
libraries = []
# Searched libraries are not passed as argument to linker
# but via some option. So, we pass them to the action
# via property.
fsa = []
fst = []
for s in sources:
if type.is_derived(s.type(), 'SEARCHED_LIB'):
n = s.name()
if s.shared():
fsa.append(n)
else:
fst.append(n)
else:
sources2.append(s)
add = []
if fsa:
add.append("" + '&&'.join(fsa))
if fst:
add.append("" + '&&'.join(fst))