Skip to content

Commit df2a18c

Browse files
rtakacsrobertsipka
authored andcommitted
Calculate the mbedtl size into the binary size in case of TizenRT. (#223)
TizenRT has its own mbedtls version that is compiled into a common libexternal.a file. This patch modifies the TizenRT build to move the created object files into a libmbedtls.a static library. In this case, all the mbedtls object files can be used when the linker map file is processed. JSRemoteTest-DCO-1.0-Signed-off-by: Roland Takacs [email protected]
1 parent c27eb40 commit df2a18c

File tree

7 files changed

+166
-80
lines changed

7 files changed

+166
-80
lines changed

jstest/builder/modules/tizenrt.build.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
{
3131
"src": "%{tizenrt}/build/output/bin/tinyara.map",
3232
"dst": "%{build-dir}/linker.map"
33+
},
34+
{
35+
"src": "%{tizenrt}/external/libmbedtls.a",
36+
"dst": "%{build-dir}/libs/libmbedtls.a"
3337
}
3438
]
3539
}

jstest/builder/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ def calculate_section_sizes(builddir):
8989
continue
9090

9191
for entry in section['contents']:
92-
if any(obj in entry['path'] for obj in objlist):
92+
# The objects (from _LIBLIST) have to be at the end of the paths.
93+
# E.g. /home/../libraries/libiotjs.a(iotjs.c.obj)
94+
if any(entry['path'].endswith('(%s)' % obj) for obj in objlist):
9395
section_sizes[section_name] += entry['size']
9496

9597
return section_sizes

jstest/resources/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,9 @@ def patch_modules(env, revert=False):
5252
'''
5353
Modify the source code of the required modules.
5454
'''
55-
if not env.options.patches:
56-
return
57-
5855
for module in env.modules.values():
59-
for patch in module.get('patches', []):
56+
# Get patches that belong to the current job.
57+
for patch in module.get('patches', {}).get(env.options.id, []):
6058
# Do not patch if the result of the condition is false.
6159
condition = patch.get('condition', 'True')
6260

jstest/resources/patches/tizenrt-coverage.diff

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
diff --git a/os/FlatLibs.mk b/os/FlatLibs.mk
2-
index b68dd05..1fb130e 100644
2+
index de0ec9c..65211e3 100644
33
--- a/os/FlatLibs.mk
44
+++ b/os/FlatLibs.mk
5-
@@ -149,6 +149,7 @@ TINYARALIBS += $(LIBRARIES_DIR)$(DELIM)libiotjs$(LIBEXT)
5+
@@ -153,6 +153,7 @@ TINYARALIBS += $(LIBRARIES_DIR)$(DELIM)libiotjs$(LIBEXT)
66
TINYARALIBS += $(LIBRARIES_DIR)$(DELIM)libjerry-core$(LIBEXT)
77
TINYARALIBS += $(LIBRARIES_DIR)$(DELIM)libtuv$(LIBEXT)
88
TINYARALIBS += $(LIBRARIES_DIR)$(DELIM)libjerry-libm$(LIBEXT)
99
+TINYARALIBS += $(LIBRARIES_DIR)$(DELIM)libjerry-port-default$(LIBEXT)
1010
endif
1111

12-
# Export all libraries
12+
# Add library for external bcm support.
1313
diff --git a/os/LibTargets.mk b/os/LibTargets.mk
14-
index 6633428..cdaae4a 100644
14+
index 95be375..3a41a1f 100644
1515
--- a/os/LibTargets.mk
1616
+++ b/os/LibTargets.mk
17-
@@ -233,6 +233,9 @@ $(LIBRARIES_DIR)$(DELIM)libtuv$(LIBEXT): $(IOTJS_LIB_DIR)$(DELIM)libtuv$(LIBEXT)
17+
@@ -242,6 +242,9 @@ $(LIBRARIES_DIR)$(DELIM)libtuv$(LIBEXT): $(IOTJS_LIB_DIR)$(DELIM)libtuv$(LIBEXT)
1818

1919
$(LIBRARIES_DIR)$(DELIM)libjerry-libm$(LIBEXT): $(IOTJS_LIB_DIR)$(DELIM)libjerry-libm$(LIBEXT)
2020
$(Q) install $(IOTJS_LIB_DIR)$(DELIM)libjerry-libm$(LIBEXT) $(LIBRARIES_DIR)$(DELIM)libjerry-libm$(LIBEXT)
@@ -25,10 +25,10 @@ index 6633428..cdaae4a 100644
2525

2626
# Possible non-kernel builds
2727
diff --git a/os/ProtectedLibs.mk b/os/ProtectedLibs.mk
28-
index 874b809..8341513 100644
28+
index 42b5fd8..62bbb58 100644
2929
--- a/os/ProtectedLibs.mk
3030
+++ b/os/ProtectedLibs.mk
31-
@@ -147,6 +147,7 @@ USERLIBS += $(LIBRARIES_DIR)$(DELIM)libiotjs$(LIBEXT)
31+
@@ -148,6 +148,7 @@ USERLIBS += $(LIBRARIES_DIR)$(DELIM)libiotjs$(LIBEXT)
3232
USERLIBS += $(LIBRARIES_DIR)$(DELIM)libjerry-core$(LIBEXT)
3333
USERLIBS += $(LIBRARIES_DIR)$(DELIM)libtuv$(LIBEXT)
3434
USERLIBS += $(LIBRARIES_DIR)$(DELIM)libjerry-libm$(LIBEXT)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
diff --git a/external/mbedtls/Makefile b/external/mbedtls/Makefile
2+
index 5e321e3..fb174a7 100644
3+
--- a/external/mbedtls/Makefile
4+
+++ b/external/mbedtls/Makefile
5+
@@ -99,12 +99,12 @@ SRCS = $(ASRCS) $(CSRCS)
6+
OBJS = $(AOBJS) $(COBJS)
7+
8+
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
9+
- BIN = ..\libexternal$(LIBEXT)
10+
+ BIN = ..\libmbedtls$(LIBEXT)
11+
else
12+
ifeq ($(WINTOOL),y)
13+
- BIN = ..\\libexternal$(LIBEXT)
14+
+ BIN = ..\\libmbedtls$(LIBEXT)
15+
else
16+
- BIN = ../libexternal$(LIBEXT)
17+
+ BIN = ../libmbedtls$(LIBEXT)
18+
endif
19+
endif
20+
21+
diff --git a/os/FlatLibs.mk b/os/FlatLibs.mk
22+
index 00c6716..de0ec9c 100644
23+
--- a/os/FlatLibs.mk
24+
+++ b/os/FlatLibs.mk
25+
@@ -88,6 +88,10 @@ endif
26+
27+
TINYARALIBS += $(LIBRARIES_DIR)$(DELIM)libexternal$(LIBEXT)
28+
29+
+# Add library for mbedtls support.
30+
+
31+
+TINYARALIBS += $(LIBRARIES_DIR)$(DELIM)libmbedtls$(LIBEXT)
32+
+
33+
# Add libraries for network support
34+
35+
ifeq ($(CONFIG_NET),y)
36+
diff --git a/os/LibTargets.mk b/os/LibTargets.mk
37+
index ccb5d2c..95be375 100644
38+
--- a/os/LibTargets.mk
39+
+++ b/os/LibTargets.mk
40+
@@ -178,6 +178,12 @@ $(EXTDIR)$(DELIM)libexternal$(LIBEXT): context
41+
$(LIBRARIES_DIR)$(DELIM)libexternal$(LIBEXT): $(EXTDIR)$(DELIM)libexternal$(LIBEXT)
42+
$(Q) install $(EXTDIR)$(DELIM)libexternal$(LIBEXT) $(LIBRARIES_DIR)$(DELIM)libexternal$(LIBEXT)
43+
44+
+$(EXTDIR)$(DELIM)libmbedtls$(LIBEXT): context
45+
+ $(Q) $(MAKE) -C $(EXTDIR) TOPDIR="$(TOPDIR)" EXTDIR="$(EXTDIR)" libmbedtls$(LIBEXT) KERNEL=n
46+
+
47+
+$(LIBRARIES_DIR)$(DELIM)libmbedtls$(LIBEXT): $(EXTDIR)$(DELIM)libmbedtls$(LIBEXT)
48+
+ $(Q) install $(EXTDIR)$(DELIM)libmbedtls$(LIBEXT) $(LIBRARIES_DIR)$(DELIM)libmbedtls$(LIBEXT)
49+
+
50+
#Iotivity Libs
51+
52+
ifeq ($(CONFIG_ENABLE_IOTIVITY),y)
53+
diff --git a/os/ProtectedLibs.mk b/os/ProtectedLibs.mk
54+
index 874b809..42b5fd8 100644
55+
--- a/os/ProtectedLibs.mk
56+
+++ b/os/ProtectedLibs.mk
57+
@@ -92,6 +92,7 @@ endif
58+
59+
60+
USERLIBS += $(LIBRARIES_DIR)$(DELIM)libexternal$(LIBEXT)
61+
+USERLIBS += $(LIBRARIES_DIR)$(DELIM)libmbedtls$(LIBEXT)
62+
63+
# Add libraries for iotivity support
64+

jstest/resources/resources.json

Lines changed: 85 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,34 @@
5555
"dst": "%{tizenrt}/build/configs/artik053/%{appname}/defconfig"
5656
}
5757
],
58-
"patches": [
59-
{ "file": "%{patches}/tizenrt-openocd.diff", "revert": false},
60-
{
61-
"condition": "'%{appname}' == 'iotjs' and %{coverage}",
62-
"file": "%{patches}/tizenrt-coverage.diff"
63-
}
64-
]
58+
"patches": {
59+
"profiles/minimal-profile-build": [
60+
{
61+
"condition": "'%{appname}' == 'iotjs'",
62+
"file": "%{patches}/tizenrt-mbedtls.diff"
63+
}
64+
],
65+
"profiles/target-profile-build": [
66+
{
67+
"condition": "'%{appname}' == 'iotjs'",
68+
"file": "%{patches}/tizenrt-mbedtls.diff"
69+
}
70+
],
71+
"test-build": [
72+
{
73+
"condition": "'%{appname}' == 'iotjs'",
74+
"file": "%{patches}/tizenrt-mbedtls.diff"
75+
},
76+
{
77+
"condition": "'%{appname}' == 'iotjs' and %{coverage}",
78+
"file": "%{patches}/tizenrt-coverage.diff"
79+
},
80+
{
81+
"file": "%{patches}/tizenrt-openocd.diff",
82+
"revert": false
83+
}
84+
]
85+
}
6586
},
6687
"nuttx": {
6788
"url": "https://bitbucket.org/nuttx/nuttx.git",
@@ -73,8 +94,6 @@
7394
"include": "%{nuttx}/include",
7495
"linker-map": "%{nuttx}/arch/arm/src/nuttx.map"
7596
},
76-
"patches": [
77-
],
7897
"config": [
7998
{
8099
"condition": "'%{appname}' == 'iotjs'",
@@ -106,8 +125,6 @@
106125
"src": "%{jerryscript}/targets/nuttx-stm32f4/",
107126
"dst": "%{nuttx-apps}/interpreters/jerryscript/"
108127
}
109-
],
110-
"patches": [
111128
]
112129
},
113130
"jerryscript": {
@@ -131,20 +148,22 @@
131148
"artik053-toolchain": "%{jerryscript}/cmake/toolchain_mcu_artik053.cmake",
132149
"rpi2-toolchain": "%{jerryscript}/cmake/toolchain_linux_armv7l.cmake"
133150
},
134-
"patches": [
135-
{
136-
"condition": "'%{device}' == 'rpi2' and %{memstat}",
137-
"file": "%{patches}/linux-jerryscript-stack.diff"
138-
},
139-
{
140-
"condition": "'%{device}' == 'stm32f4dis' and %{memstat}",
141-
"file": "%{patches}/nuttx-jerryscript-stack.diff"
142-
},
143-
{
144-
"condition": "'%{device}' == 'artik053'",
145-
"file": "%{patches}/tizenrt-jerryscript-%{use-stack}.diff"
146-
}
147-
]
151+
"patches": {
152+
"test-build": [
153+
{
154+
"condition": "'%{device}' == 'rpi2' and %{memstat}",
155+
"file": "%{patches}/linux-jerryscript-stack.diff"
156+
},
157+
{
158+
"condition": "'%{device}' == 'stm32f4dis' and %{memstat}",
159+
"file": "%{patches}/nuttx-jerryscript-stack.diff"
160+
},
161+
{
162+
"condition": "'%{device}' == 'artik053'",
163+
"file": "%{patches}/tizenrt-jerryscript-%{use-stack}.diff"
164+
}
165+
]
166+
}
148167
},
149168
"iotjs": {
150169
"url": "https://github.com/Samsung/iotjs.git",
@@ -170,45 +189,47 @@
170189
"coverage-client": "%{iotjs}/deps/jerry/jerry-debugger/jerry-client-ws.py",
171190
"js-sources" : "%{iotjs}/src/js/"
172191
},
173-
"patches": [
174-
{
175-
"condition": "'%{device}' == 'stm32f4dis' and %{memstat}",
176-
"file": "%{patches}/nuttx-iotjs-stack.diff"
177-
},
178-
{
179-
"condition": "'%{device}' == 'artik053'",
180-
"file": "%{patches}/tizenrt-iotjs-%{use-stack}.diff"
181-
},
182-
{
183-
"condition": "'%{device}' in ['stm32f4dis', 'artik053'] and %{memstat}",
184-
"file": "%{patches}/iotjs-system-heap.diff"
185-
},
186-
{
187-
"condition": "'%{device}' in ['stm32f4dis', 'artik053'] and %{memstat}",
188-
"file": "%{patches}/libtuv-system-heap.diff",
189-
"submodule": "%{iotjs}/deps/libtuv/"
190-
},
191-
{
192-
"condition": "'%{device}' in ['stm32f4dis', 'artik053', 'artik530', 'rpi2'] and %{memstat}",
193-
"file": "%{patches}/jerryscript-jerry-heap.diff",
194-
"submodule": "%{iotjs}/deps/jerry/"
195-
},
196-
{
197-
"condition": "'%{device}' in ['artik053', 'artik530', 'rpi2'] and %{coverage}",
198-
"file": "%{patches}/jerryscript-coverage.diff",
199-
"submodule": "%{iotjs}/deps/jerry/"
200-
},
201-
{
202-
"condition": "'%{device}' in ['artik053', 'artik530', 'rpi2'] and %{coverage}",
203-
"file": "%{patches}/coverage-client.diff",
204-
"submodule": "%{iotjs}/deps/jerry/",
205-
"revert": false
206-
},
207-
{
208-
"condition": "'%{device}' in ['artik530', 'rpi2'] and %{memstat}",
209-
"file": "%{patches}/linux-iotjs-stack.diff"
210-
}
211-
]
192+
"patches": {
193+
"test-build": [
194+
{
195+
"condition": "'%{device}' == 'stm32f4dis' and %{memstat}",
196+
"file": "%{patches}/nuttx-iotjs-stack.diff"
197+
},
198+
{
199+
"condition": "'%{device}' == 'artik053'",
200+
"file": "%{patches}/tizenrt-iotjs-%{use-stack}.diff"
201+
},
202+
{
203+
"condition": "'%{device}' in ['stm32f4dis', 'artik053'] and %{memstat}",
204+
"file": "%{patches}/iotjs-system-heap.diff"
205+
},
206+
{
207+
"condition": "'%{device}' in ['stm32f4dis', 'artik053'] and %{memstat}",
208+
"file": "%{patches}/libtuv-system-heap.diff",
209+
"submodule": "%{iotjs}/deps/libtuv/"
210+
},
211+
{
212+
"condition": "'%{device}' in ['stm32f4dis', 'artik053', 'artik530', 'rpi2'] and %{memstat}",
213+
"file": "%{patches}/jerryscript-jerry-heap.diff",
214+
"submodule": "%{iotjs}/deps/jerry/"
215+
},
216+
{
217+
"condition": "'%{device}' in ['artik053', 'artik530', 'rpi2'] and %{coverage}",
218+
"file": "%{patches}/jerryscript-coverage.diff",
219+
"submodule": "%{iotjs}/deps/jerry/"
220+
},
221+
{
222+
"condition": "'%{device}' in ['artik053', 'artik530', 'rpi2'] and %{coverage}",
223+
"file": "%{patches}/coverage-client.diff",
224+
"submodule": "%{iotjs}/deps/jerry/",
225+
"revert": false
226+
},
227+
{
228+
"condition": "'%{device}' in ['artik530', 'rpi2'] and %{memstat}",
229+
"file": "%{patches}/linux-iotjs-stack.diff"
230+
}
231+
]
232+
}
212233
},
213234
"freya": {
214235
"url": "https://github.com/szeged/Freya.git",

jstest/runnable.jobs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
[
22
{
33
"id": "profiles/minimal-profile-build",
4-
"patches": false,
54
"coverage": false,
65
"no_memstat": true,
76
"no_flash": true,
87
"no_test": true
98
},
109
{
1110
"id": "profiles/target-profile-build",
12-
"patches": false,
1311
"coverage": false,
1412
"no_memstat": true,
1513
"no_flash": true,
1614
"no_test": true
1715
},
1816
{
19-
"id": "test-build",
20-
"patches": true
17+
"id": "test-build"
2118
}
2219
]

0 commit comments

Comments
 (0)