2016-10-27 18:04:25 +02:00
|
|
|
# Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
|
|
|
# reserved. Use of this source code is governed by a BSD-style license that
|
|
|
|
# can be found in the LICENSE file.
|
|
|
|
#
|
|
|
|
# Resort order of object files in libcef.ninja file.
|
|
|
|
#
|
|
|
|
# See: https://bitbucket.org/chromiumembedded/cef/issues/1999
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# import issue_1999
|
|
|
|
# issue_1999.apply(output_path)
|
|
|
|
#
|
2020-01-12 16:48:13 +01:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import print_function
|
|
|
|
from io import open
|
2016-10-27 18:04:25 +02:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
module_order = [
|
2017-05-28 15:04:18 +02:00
|
|
|
"_sse",
|
|
|
|
"-sse",
|
|
|
|
"_ssse",
|
|
|
|
"-ssse",
|
|
|
|
"_sse2",
|
|
|
|
"-sse2",
|
|
|
|
"_ssse2",
|
|
|
|
"-ssse2",
|
|
|
|
"_sse3",
|
|
|
|
"-sse3",
|
|
|
|
"_ssse3",
|
|
|
|
"-ssse3",
|
|
|
|
"_sse4",
|
|
|
|
"-sse4",
|
|
|
|
"_ssse4",
|
|
|
|
"-ssse4",
|
|
|
|
"_avx",
|
|
|
|
"-avx",
|
|
|
|
"_savx",
|
|
|
|
"-savx",
|
|
|
|
"_avx1",
|
|
|
|
"-avx1",
|
|
|
|
"_savx1",
|
|
|
|
"-savx1",
|
|
|
|
"_avx2",
|
|
|
|
"-avx2",
|
|
|
|
"_savx2",
|
|
|
|
"-savx2",
|
|
|
|
]
|
|
|
|
|
2016-10-27 18:04:25 +02:00
|
|
|
|
|
|
|
def get_obj_class(item):
|
|
|
|
item = item.lower()
|
|
|
|
for i in range(len(module_order) - 1, -1, -1):
|
|
|
|
x = module_order[i]
|
|
|
|
if x in item:
|
|
|
|
return 1 + i
|
|
|
|
return 0
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-10-27 18:04:25 +02:00
|
|
|
def obj_compare(x, y):
|
|
|
|
xc = get_obj_class(x)
|
|
|
|
yc = get_obj_class(y)
|
2017-05-28 15:04:18 +02:00
|
|
|
if xc < yc:
|
|
|
|
return -1
|
|
|
|
elif xc > yc:
|
|
|
|
return 1
|
|
|
|
else:
|
|
|
|
return 0
|
2016-10-27 18:04:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
def process_line(line):
|
|
|
|
if line.startswith("build ./libcef.dll ./libcef.dll.lib: solink "):
|
|
|
|
index = line.find("solink")
|
|
|
|
if index >= 0:
|
|
|
|
part1 = line[0:index + 6]
|
|
|
|
part2 = line[index + 6:]
|
|
|
|
stampsIndex = part2.find("||")
|
|
|
|
stamps = part2[stampsIndex:]
|
|
|
|
objects = part2[:stampsIndex]
|
|
|
|
|
|
|
|
objects_list = objects.split()
|
2017-05-28 15:04:18 +02:00
|
|
|
objects_list = sorted(objects_list, cmp=obj_compare)
|
2016-10-27 18:04:25 +02:00
|
|
|
return part1 + " " + " ".join(objects_list) + " " + stamps
|
|
|
|
return line
|
|
|
|
|
|
|
|
|
|
|
|
def process_file(path):
|
2020-01-12 16:48:13 +01:00
|
|
|
print("Applying issue #1999 fix to " + path)
|
2016-10-27 18:04:25 +02:00
|
|
|
|
2020-01-12 16:48:13 +01:00
|
|
|
with open(path, 'r', encoding='utf-8') as f:
|
2016-10-27 18:04:25 +02:00
|
|
|
content = f.read().splitlines()
|
|
|
|
|
|
|
|
result = []
|
|
|
|
|
|
|
|
for line in content:
|
|
|
|
result.append(process_line(line))
|
|
|
|
|
2020-01-12 16:48:13 +01:00
|
|
|
with open(path, 'w', encoding='utf-8') as fp:
|
|
|
|
str = "\n".join(result) + "\n"
|
2020-01-13 11:53:36 +01:00
|
|
|
if sys.version_info.major == 2:
|
2020-01-12 16:48:13 +01:00
|
|
|
fp.write(str.decode('utf-8'))
|
2020-01-13 11:53:36 +01:00
|
|
|
else:
|
2020-01-12 16:48:13 +01:00
|
|
|
fp.write(str)
|
2016-10-27 18:04:25 +02:00
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2016-10-27 18:04:25 +02:00
|
|
|
def apply(confpath):
|
2016-10-27 20:22:56 +02:00
|
|
|
process_file(os.path.join(confpath, "obj", "cef", "libcef.ninja"))
|