Skip to content

Add binary size calculation for dinamically linked iotjs. #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions jstest/builder/modules/iotjs.build.config
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@
"src": "%{testsuite}",
"dst": "%{build-dir}/tests"
},
{
"src": "%{tizen-iotjs-dir}/build/%{target}/%{build-type}/lib",
"dst": "%{build-dir}/tests/lib"
},
{
"src": "%{tizen-rpm-package}",
"dst": "%{build-dir}/iotjs-1.0.0-0.armv7l.rpm"
Expand Down
40 changes: 37 additions & 3 deletions jstest/builder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import re

from jstest.builder import lumpy
from jstest.common import utils
Expand Down Expand Up @@ -49,14 +50,47 @@ def create_build_info(env):
build_info = {
'build-date': utils.current_date('%Y-%m-%dT%H.%M.%SZ'),
'last-commit-date': submodules[env.options.app]['date'],
'bin': calculate_section_sizes(env.paths.builddir),
'bin': calculate_section_sizes(env.options.device, env.paths.builddir),
'submodules': submodules
}

utils.write_json_file(utils.join(env.paths.builddir, 'build.json'), build_info)


def calculate_section_sizes(builddir):
def calculate_section_sizes(target, builddir):
'''
Return the sizes of the main sections.
'''
if target == 'rpi3':
return calculate_section_sizes_dynamic_linking(builddir)

return calculate_section_sizes_static_linking(builddir)


def calculate_section_sizes_dynamic_linking(builddir):
'''
Return the sizes of the main sections.
'''
section_sizes = {
'bss': 0,
'text': 0,
'data': 0,
'rodata': 0
}

output, exitcode = utils.execute(builddir, 'size', ['-A', '%s/lib/libiotjs.so' % builddir], quiet=True)

if exitcode == 0:
for section_name in section_sizes:
match = re.search(r'\.%s[\ ]+([0-9]+)' % section_name, output)

if match:
section_sizes[section_name] = int(match.group(1))

return section_sizes


def calculate_section_sizes_static_linking(builddir):
'''
Return the sizes of the main sections.
'''
Expand All @@ -68,7 +102,7 @@ def calculate_section_sizes(builddir):
}

mapfile = utils.join(builddir, 'linker.map')
libdir = utils.join(builddir, 'libs')
libdir = utils.join(builddir, 'lib')

if not (utils.exists(mapfile) and utils.exists(libdir)):
return section_sizes
Expand Down
2 changes: 1 addition & 1 deletion jstest/resources/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "%{build-path}/%{appname}/%{device}/%{build-type}",
"tizen-build-root": "%{build}/tizen-build-root",
"tizen-iotjs-dir": "%{build}/tizen-build-root/local/BUILD-ROOTS/scratch.armv7l.0/home/abuild/rpmbuild/BUILD/iotjs-1.0.0",
"tizen-rpm-package": "%{build}/tizen-build-root/local/repos/tizen50m2/armv7l/RPMS/iotjs-1.0.0-0.armv7l.rpm",
"tizen-rpm-package": "%{build}/tizen-build-root/local/BUILD-ROOTS/scratch.armv7l.0/home/abuild/rpmbuild/RPMS/armv7l/iotjs-1.0.0-0.armv7l.rpm",
"result": "%{result-path}/%{appname}/%{device}"
},
"modules": {
Expand Down