Skip to content

Commit

Permalink
qipkg: add stripping feature
Browse files Browse the repository at this point in the history
Change-Id: Id45b5ae47216cbc32d7d8416ecd5948367319334
  • Loading branch information
houssemkouki committed Dec 15, 2016
1 parent a394072 commit 3780236
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 21 deletions.
12 changes: 8 additions & 4 deletions python/qibuild/breakpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def gen_dsym(binary):
qisys.command.call(cmd)
return binary + ".dSYM"

def dump_symbols_from_directory(root_dir, pool_dir, strip=True):
def dump_symbols_from_directory(root_dir, pool_dir, strip=True,
strip_exe=None, strip_args=None):
""" Dump symbols for every binary in the root dir.
Assumes that dump_syms is in $PATH.
If strip is True, also strip the binaries. (assumes that strip is
Expand All @@ -143,15 +144,18 @@ def dump_symbols_from_directory(root_dir, pool_dir, strip=True):
else:
strip_args = list()
ui.info("stripping", full_path)
strip_binary(full_path, strip_args=strip_args)
strip_binary(full_path, strip_executable=strip_exe,
strip_args=strip_args)
return pool_dir

def gen_symbol_archive(base_dir=None, output=None, strip=True):
def gen_symbol_archive(base_dir=None, output=None, strip=True,
strip_exe=None, strip_args=None):
""" Generate a symbol archive from all the
binaries in the base_dir
"""
with qisys.sh.TempDir() as pool_dir:
dump_symbols_from_directory(base_dir, pool_dir, strip=strip)
dump_symbols_from_directory(base_dir, pool_dir, strip=strip,
strip_exe=strip_exe, strip_args=strip_args)
qisys.archive.compress(pool_dir, output=output, flat=True)
return output
44 changes: 27 additions & 17 deletions python/qipkg/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
## found in the COPYING file.
""" Builder for pml files """
import os
import sys
import tempfile
import zipfile

from qisys import ui
import qisys.qixml
Expand Down Expand Up @@ -95,7 +93,7 @@ def load_pml(self, pml_path):
def _load_pml(self, pml_path):
for builder in self.builders:
builder.projects = list()
tree= qisys.qixml.read(pml_path)
tree = qisys.qixml.read(pml_path)
root = tree.getroot()
qibuild_elems = root.findall("qibuild")
if qibuild_elems and not self.worktree:
Expand All @@ -122,7 +120,8 @@ def _load_pml(self, pml_path):
project = self.linguist_worktree.get_linguist_project(name, raises=True)
self.linguist_builder.projects.append(project)

# For top, ressource, dialog, behavior, add stuff to self.pml_extra_files
# For top, ressource, dialog, behavior
# add stuff to self.pml_extra_files
behaviors = root.find("BehaviorDescriptions")
if behaviors is not None:
for child in behaviors.findall("BehaviorDescription"):
Expand Down Expand Up @@ -166,15 +165,15 @@ def configure(self):
""" Configure every project """
for builder in self.builders:
if isinstance(builder, qibuild.cmake_builder.CMakeBuilder):
builder.dep_types=["build", "runtime", "test"]
builder.dep_types = ["build", "runtime", "test"]
builder.configure()

def build(self):
""" Build every project """
for builder in self.builders:
builder.build()

def install(self, destination):
def install(self, destination, install_tc_packages=False):
""" Install every project to the given destination """
qisys.sh.mkdir(destination, recursive=True)
# Copy the manifest
Expand All @@ -186,8 +185,9 @@ def install(self, destination):
if builder.projects:
ui.info(ui.bold, "-> Adding %s ..." % desc)
if isinstance(builder, qibuild.cmake_builder.CMakeBuilder):
builder.dep_types=["runtime"]
builder.install(destination, components=["runtime"])
builder.dep_types = ["runtime"]
builder.install(destination, components=["runtime"],
install_tc_packages=install_tc_packages)
else:
builder.install(destination)

Expand All @@ -211,7 +211,7 @@ def deploy(self, url):
""" Deploy every project to the given url """
qisys.remote.deploy(self.stage_path, url)

def package(self, output=None, with_breakpad=False, force=False):
def package(self, *args, **kwargs):
""" Generate a package containing every project.
:param: with_breakpad generate debug symbols for usage
Expand All @@ -221,7 +221,13 @@ def package(self, output=None, with_breakpad=False, force=False):
default package requirements
"""

output = kwargs.get('output', None)
force = kwargs.get('force', False)
with_breakpad = kwargs.get('with_breakpad', False)
strip = kwargs.get('strip', True)
install_tc_packages = kwargs.get('install_tc_packages', False)
strip_args = kwargs.get('strip_args', None)
strip_exe = kwargs.get('strip_exe', None)
# If the package is not valid, do not go further
if not self.validator.is_valid and not force:
raise Exception("Given package does not satisfy "
Expand All @@ -237,21 +243,24 @@ def package(self, output=None, with_breakpad=False, force=False):


# Add everything from the staged path
self.install(self.stage_path)

ui.info(ui.bold, "-> Compressing package ...")
qisys.archive.compress(self.stage_path, output=output, flat=True,
display_progress=True)
self.install(self.stage_path, install_tc_packages=install_tc_packages)

symbols_archive = None
if with_breakpad and self.build_project:
ui.info(ui.bold, "-> Generating breakpad symbols ...")
dirname = os.path.dirname(output)
symbols_archive = os.path.join(dirname, self.pkg_name + "-symbols.zip")
qibuild.breakpad.gen_symbol_archive(base_dir=self.stage_path,
output=symbols_archive)
output=symbols_archive,
strip=strip,
strip_exe=strip_exe,
strip_args=strip_args)
ui.info(ui.bold, "-> Symbols generated in", symbols_archive)
ui.info(ui.bold, "-> Package generated in", output, "\n")

ui.info(ui.bold, "-> Compressing package ...")
qisys.archive.compress(self.stage_path, output=output, flat=True,
display_progress=True)
qisys.sh.rm(self.stage_path)
if symbols_archive:
return [output, symbols_archive]
Expand All @@ -265,7 +274,8 @@ def pkg_name(manifest_xml):
"Return a string name-version"
root = qisys.qixml.read(manifest_xml).getroot()
uuid = qisys.qixml.parse_required_attr(root, "uuid", xml_path=manifest_xml)
version = qisys.qixml.parse_required_attr(root, "version", xml_path=manifest_xml)
version = qisys.qixml.parse_required_attr(root, "version",
xml_path=manifest_xml)
output_name = "%s-%s" % (uuid, version)
return output_name

Expand Down

0 comments on commit 3780236

Please sign in to comment.