fixex #2559
--create-debug opsiyonu ile build esnasında oluşturulacak debug dosyaları on-the-fly oluşturulan bir PAKET-debug.pisi paketine doldurulacak. sonra oynarsınız onla işte. daha sonra tekrar dönülüp temizlenecek bir iki FIXME var kod içerisinde, hemen kızmayın ;)
This commit is contained in:
+37
-3
@@ -75,8 +75,9 @@ def check_path_collision(package, pkgList):
|
||||
# collide. Exp:
|
||||
# pinfo.path: /usr/share
|
||||
# path.path: /usr/share/doc
|
||||
if path.path.endswith(ctx.const.ar_file_suffix) and ctx.get_option('create_static'):
|
||||
# don't throw collision error for ar files.
|
||||
if (path.path.endswith(ctx.const.ar_file_suffix) and ctx.get_option('create_static')) or \
|
||||
(path.path.endswith(ctx.const.debug_file_suffix) and ctx.get_option('create_debug')):
|
||||
# don't throw collision error for these files.
|
||||
# we'll handle this in gen_files_xml..
|
||||
continue
|
||||
if util.subpath(pinfo.path, path.path):
|
||||
@@ -488,6 +489,28 @@ class Builder:
|
||||
|
||||
return static_package_obj
|
||||
|
||||
def generate_debug_package_object(self):
|
||||
debug_files = []
|
||||
for root, dirs, files in os.walk(self.pkg_install_dir()):
|
||||
for f in files:
|
||||
if f.endswith(ctx.const.debug_file_suffix):
|
||||
debug_files.append(util.join_path(root, f))
|
||||
|
||||
if not len(debug_files):
|
||||
return None
|
||||
|
||||
static_package_obj = pisi.specfile.Package()
|
||||
static_package_obj.name = self.spec.source.name + ctx.const.debug_name_suffix
|
||||
# FIXME: find a better way to deal with the summary and description constants.
|
||||
static_package_obj.summary['en'] = u'Debug files for %s' % (self.spec.source.name)
|
||||
static_package_obj.description['en'] = u'Debug files for %s' % (self.spec.source.name)
|
||||
static_package_obj.partOf = 'library:debug'
|
||||
for f in debug_files:
|
||||
static_package_obj.files.append(pisi.specfile.Path(path = f[len(self.pkg_install_dir()):], fileType = "debug"))
|
||||
static_package_obj.packageDependencies.append(pisi.dependency.Dependency(package = self.spec.source.name))
|
||||
|
||||
return static_package_obj
|
||||
|
||||
def strip_install_dir(self):
|
||||
"""strip install directory"""
|
||||
ctx.ui.action(_("Stripping files.."))
|
||||
@@ -559,7 +582,13 @@ class Builder:
|
||||
and fpath.endswith(ctx.const.ar_file_suffix) \
|
||||
and not package.name.endswith(ctx.const.static_name_suffix) \
|
||||
and util.is_ar_file(fpath):
|
||||
# if this is an ar file, and this package is not a -static package,
|
||||
# if this is an ar file, and this package is not a static package,
|
||||
# don't include this file into the package.
|
||||
continue
|
||||
if ctx.get_option('create_debug') \
|
||||
and fpath.endswith(ctx.const.debug_file_suffix) \
|
||||
and not package.name.endswith(ctx.const.debug_name_suffix):
|
||||
# if this is a debug file, and this package is not a debug package,
|
||||
# don't include this file into the package.
|
||||
continue
|
||||
frpath = util.removepathprefix(install_dir, fpath) # relative path
|
||||
@@ -672,6 +701,11 @@ class Builder:
|
||||
if obj:
|
||||
self.spec.packages.append(obj)
|
||||
|
||||
if ctx.get_option('create_debug'):
|
||||
obj = self.generate_debug_package_object()
|
||||
if obj:
|
||||
self.spec.packages.append(obj)
|
||||
|
||||
package_names = []
|
||||
old_package_names = []
|
||||
|
||||
|
||||
@@ -361,7 +361,9 @@ unpack, setup, build, install, package
|
||||
self.parser.add_option("-B", "--ignore-comar", action="store_true",
|
||||
default=False, help=_("bypass comar configuration agent"))
|
||||
self.parser.add_option("-S", "--create-static", action="store_true",
|
||||
default=False, help=_("automatically create a *-static package with ar files"))
|
||||
default=False, help=_("automatically create a static package with ar files"))
|
||||
self.parser.add_option("-g", "--create-debug", action="store_true",
|
||||
default=False, help=_("automatically create a debug package with debug files"))
|
||||
|
||||
|
||||
def run(self):
|
||||
|
||||
@@ -49,6 +49,10 @@ class Constants:
|
||||
self.__c.package_suffix = ".pisi"
|
||||
self.__c.xdelta_suffix = ".xdelta"
|
||||
|
||||
# suffix for auto generated debug packages
|
||||
self.__c.debug_name_suffix = "-debug"
|
||||
self.__c.debug_file_suffix = ".debug"
|
||||
|
||||
# suffix for auto generated ar packages
|
||||
self.__c.static_name_suffix = "-static" # an admissible use of constant
|
||||
self.__c.ar_file_suffix = ".a"
|
||||
|
||||
+4
-4
@@ -525,13 +525,13 @@ def strip_file(filepath):
|
||||
|
||||
def save_elf_debug(f):
|
||||
"""copy debug info into file.debug file"""
|
||||
p = os.popen("objcopy --only-keep-debug %s %s.debug" % (f, f))
|
||||
p = os.popen("objcopy --only-keep-debug %s %s%s" % (f, f, ctx.const.debug_file_suffix))
|
||||
ret = p.close()
|
||||
if ret:
|
||||
ctx.ui.warning(_("objcopy (keep-debug) command failed for file '%s'!") % f)
|
||||
|
||||
"""mark binary/shared objects to use file.debug"""
|
||||
p = os.popen("objcopy --add-gnu-debuglink=%s.debug %s" % (f, f))
|
||||
p = os.popen("objcopy --add-gnu-debuglink=%s%s %s" % (f, ctx.const.debug_file_suffix, f))
|
||||
ret = p.close()
|
||||
if ret:
|
||||
ctx.ui.warning(_("objcopy (add-debuglink) command failed for file '%s'!") % f)
|
||||
@@ -541,13 +541,13 @@ def strip_file(filepath):
|
||||
return True
|
||||
|
||||
elif "SB executable" in o:
|
||||
if ctx.config.values.build.debug == "True":
|
||||
if ctx.get_option('create_debug'):
|
||||
save_elf_debug(filepath)
|
||||
run_strip(filepath)
|
||||
return True
|
||||
|
||||
elif "SB shared object" in o:
|
||||
if ctx.config.values.build.debug == "True":
|
||||
if ctx.get_option('create_debug'):
|
||||
save_elf_debug(filepath)
|
||||
run_strip(filepath, "--strip-unneeded")
|
||||
# FIXME: warn for TEXTREL
|
||||
|
||||
Reference in New Issue
Block a user