MCPcopy Create free account
hub / github.com/boostorg/build / Order

Class Order

v2/util/order.py:6–121  ·  view source on GitHub ↗

Allows ordering arbitrary objects with regard to arbitrary binary relation. The primary use case is the gcc toolset, which is sensitive to library order: if library 'a' uses symbols from library 'b', then 'a' must be present before 'b' on the linker's command line.

Source from the content-addressed store, hash-verified

4# at http://www.boost.org/LICENSE_1_0.txt)
5
6class Order:
7 """Allows ordering arbitrary objects with regard to arbitrary binary relation.
8
9 The primary use case is the gcc toolset, which is sensitive to
10 library order: if library 'a' uses symbols from library 'b',
11 then 'a' must be present before 'b' on the linker's command line.
12
13 This requirement can be lifted for gcc with GNU ld, but for gcc with
14 Solaris LD (and for Solaris toolset as well), the order always matters.
15
16 So, we need to store order requirements and then order libraries
17 according to them. It it not possible to use dependency graph as
18 order requirements. What we need is "use symbols" relationship
19 while dependency graph provides "needs to be updated" relationship.
20
21 For example::
22 lib a : a.cpp b;
23 lib b ;
24
25 For static linking, the 'a' library need not depend on 'b'. However, it
26 still should come before 'b' on the command line.
27 """
28
29 def __init__ (self):
30 self.constraints_ = []
31
32 def add_pair (self, first, second):
33 """ Adds the constraint that 'first' should precede 'second'.
34 """
35 self.constraints_.append ((first, second))
36
37 def order (self, objects):
38 """ Given a list of objects, reorder them so that the constains specified
39 by 'add_pair' are satisfied.
40
41 The algorithm was adopted from an awk script by Nikita Youshchenko
42 (yoush at cs dot msu dot su)
43 """
44 # The algorithm used is the same is standard transitive closure,
45 # except that we're not keeping in-degree for all vertices, but
46 # rather removing edges.
47 result = []
48
49 if not objects:
50 return result
51
52 constraints = self.__eliminate_unused_constraits (objects)
53
54 # Find some library that nobody depends upon and add it to
55 # the 'result' array.
56 obj = None
57 while objects:
58 new_objects = []
59 while objects:
60 obj = objects [0]
61
62 if self.__has_no_dependents (obj, constraints):
63 # Emulate break ;

Callers 1

unix.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected