Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 719742 - Make expandlibs properly handle the case where OBJ_SUFFI…
…X is .i_o on Linux PGO first pass. r=ted
  • Loading branch information
glandium committed Jan 25, 2012
1 parent 77a3f1f commit a84cacd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
5 changes: 5 additions & 0 deletions config/expandlibs.py
Expand Up @@ -86,6 +86,11 @@ def splitpath(path):
return relpath
return path

def isObject(path):
'''Returns whether the given path points to an object file, that is,
ends with OBJ_SUFFIX or .i_o'''
return os.path.splitext(path)[1] in [conf.OBJ_SUFFIX, '.i_o']

class LibDescriptor(dict):
KEYS = ['OBJS', 'LIBS']

Expand Down
10 changes: 5 additions & 5 deletions config/expandlibs_exec.py
Expand Up @@ -56,7 +56,7 @@
from __future__ import with_statement
import sys
import os
from expandlibs import ExpandArgs, relativize
from expandlibs import ExpandArgs, relativize, isObject
import expandlibs_config as conf
from optparse import OptionParser
import subprocess
Expand Down Expand Up @@ -97,7 +97,7 @@ def _extract(self, args):
subprocess.call(ar_extract + [os.path.abspath(arg)], cwd=tmp)
objs = []
for root, dirs, files in os.walk(tmp):
objs += [relativize(os.path.join(root, f)) for f in files if os.path.splitext(f)[1] in [conf.OBJ_SUFFIX, '.i_o']]
objs += [relativize(os.path.join(root, f)) for f in files if isObject(f)]
newlist += objs
else:
newlist += [arg]
Expand All @@ -109,7 +109,7 @@ def makelist(self):
'''Replaces object file names with a temporary list file, using a
list format depending on the EXPAND_LIBS_LIST_STYLE variable
'''
objs = [o for o in self if os.path.splitext(o)[1] == conf.OBJ_SUFFIX]
objs = [o for o in self if isObject(o)]
if not len(objs): return
fd, tmp = tempfile.mkstemp(suffix=".list",dir=os.curdir)
if conf.EXPAND_LIBS_LIST_STYLE == "linkerscript":
Expand All @@ -134,15 +134,15 @@ def reorder(self, order_list):
so that the object file names it contains are ordered according to
that list.
'''
objs = [o for o in self if o.endswith(conf.OBJ_SUFFIX)]
objs = [o for o in self if isObject(o)]
if not objs: return
idx = self.index(objs[0])
# Keep everything before the first object, then the ordered objects,
# then any other objects, then any non-objects after the first object
objnames = dict([(os.path.splitext(os.path.basename(o))[0], o) for o in objs])
self[0:] = self[0:idx] + [objnames[o] for o in order_list if o in objnames] + \
[o for o in objs if os.path.splitext(os.path.basename(o))[0] not in order_list] + \
[x for x in self[idx:] if not x.endswith(conf.OBJ_SUFFIX)]
[x for x in self[idx:] if not isObject(x)]


def main():
Expand Down
4 changes: 2 additions & 2 deletions config/expandlibs_gen.py
Expand Up @@ -41,12 +41,12 @@
import sys
import os
import expandlibs_config as conf
from expandlibs import LibDescriptor
from expandlibs import LibDescriptor, isObject

def generate(args):
desc = LibDescriptor()
for arg in args:
if os.path.splitext(arg)[1] in [conf.OBJ_SUFFIX, '.i_o']:
if isObject(arg):
desc['OBJS'].append(os.path.abspath(arg))
elif os.path.splitext(arg)[1] == conf.LIB_SUFFIX and \
(os.path.exists(arg) or os.path.exists(arg + conf.LIBS_DESC_SUFFIX)):
Expand Down
5 changes: 5 additions & 0 deletions js/src/config/expandlibs.py
Expand Up @@ -86,6 +86,11 @@ def splitpath(path):
return relpath
return path

def isObject(path):
'''Returns whether the given path points to an object file, that is,
ends with OBJ_SUFFIX or .i_o'''
return os.path.splitext(path)[1] in [conf.OBJ_SUFFIX, '.i_o']

class LibDescriptor(dict):
KEYS = ['OBJS', 'LIBS']

Expand Down
10 changes: 5 additions & 5 deletions js/src/config/expandlibs_exec.py
Expand Up @@ -56,7 +56,7 @@
from __future__ import with_statement
import sys
import os
from expandlibs import ExpandArgs, relativize
from expandlibs import ExpandArgs, relativize, isObject
import expandlibs_config as conf
from optparse import OptionParser
import subprocess
Expand Down Expand Up @@ -97,7 +97,7 @@ def _extract(self, args):
subprocess.call(ar_extract + [os.path.abspath(arg)], cwd=tmp)
objs = []
for root, dirs, files in os.walk(tmp):
objs += [relativize(os.path.join(root, f)) for f in files if os.path.splitext(f)[1] in [conf.OBJ_SUFFIX, '.i_o']]
objs += [relativize(os.path.join(root, f)) for f in files if isObject(f)]
newlist += objs
else:
newlist += [arg]
Expand All @@ -109,7 +109,7 @@ def makelist(self):
'''Replaces object file names with a temporary list file, using a
list format depending on the EXPAND_LIBS_LIST_STYLE variable
'''
objs = [o for o in self if os.path.splitext(o)[1] == conf.OBJ_SUFFIX]
objs = [o for o in self if isObject(o)]
if not len(objs): return
fd, tmp = tempfile.mkstemp(suffix=".list",dir=os.curdir)
if conf.EXPAND_LIBS_LIST_STYLE == "linkerscript":
Expand All @@ -134,15 +134,15 @@ def reorder(self, order_list):
so that the object file names it contains are ordered according to
that list.
'''
objs = [o for o in self if o.endswith(conf.OBJ_SUFFIX)]
objs = [o for o in self if isObject(o)]
if not objs: return
idx = self.index(objs[0])
# Keep everything before the first object, then the ordered objects,
# then any other objects, then any non-objects after the first object
objnames = dict([(os.path.splitext(os.path.basename(o))[0], o) for o in objs])
self[0:] = self[0:idx] + [objnames[o] for o in order_list if o in objnames] + \
[o for o in objs if os.path.splitext(os.path.basename(o))[0] not in order_list] + \
[x for x in self[idx:] if not x.endswith(conf.OBJ_SUFFIX)]
[x for x in self[idx:] if not isObject(x)]


def main():
Expand Down
4 changes: 2 additions & 2 deletions js/src/config/expandlibs_gen.py
Expand Up @@ -41,12 +41,12 @@
import sys
import os
import expandlibs_config as conf
from expandlibs import LibDescriptor
from expandlibs import LibDescriptor, isObject

def generate(args):
desc = LibDescriptor()
for arg in args:
if os.path.splitext(arg)[1] in [conf.OBJ_SUFFIX, '.i_o']:
if isObject(arg):
desc['OBJS'].append(os.path.abspath(arg))
elif os.path.splitext(arg)[1] == conf.LIB_SUFFIX and \
(os.path.exists(arg) or os.path.exists(arg + conf.LIBS_DESC_SUFFIX)):
Expand Down

0 comments on commit a84cacd

Please sign in to comment.