Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 1f3b3f3

Browse files
authored
Merge pull request #6999 from montegoulding/iosmodulec-develop
[[ Module Lcext ]] Generate shim file for C foreign bindings
2 parents 04be442 + 1337bb5 commit 1f3b3f3

File tree

20 files changed

+977
-458
lines changed

20 files changed

+977
-458
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# LiveCode Builder Tools
2+
## lc-compile
3+
### Command-line interface
4+
5+
* The new `--forcebuiltins` command line flag can be used in combination with
6+
the `--outputauxc OUTFILE` option to generate shims for C foreign bindings.
7+
Use the output file to link with any static libraries used by modules on iOS
8+
to create a lcext binary and the shims will ensure that required objects from
9+
the static libraries are included in the resulting binary.

docs/notes/feature-modulelcext.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Static linked code libraries for iOS device builds
2+
3+
The standalone builder now supports `.lcext` compiled objects that link static
4+
libraries used by a LCB module to the module compiled as C++ using lc-compile's
5+
`--forcebuiltins --outputauxc` options. Additionaly, a new section named
6+
Foreign Code Libraries has been added to the LiveCode Builder Language Reference
7+
describing the creation of `.lcext` objects and use of code libraries in general.

engine/src/mode_standalone.cpp

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -389,28 +389,56 @@ bool MCStandaloneCapsuleCallback(void *p_self, const uint8_t *p_digest, MCCapsul
389389
return false;
390390
}
391391

392-
MCAutoValueRefBase<MCStreamRef> t_stream;
393-
if (!MCMemoryInputStreamCreate(t_module_data.Bytes(),
394-
p_length, &t_stream))
392+
// This section is raw file data either a module or a name to resolve which should
393+
// have been added as a builtin
394+
bool t_is_module = true;
395+
if (p_length >= 4 &&
396+
!(t_module_data.Bytes()[0] == 'L' &&
397+
t_module_data.Bytes()[1] == 'C' &&
398+
t_module_data.Bytes()[2] == ((kMCScriptCurrentModuleVersion >> 0) & 0xFF) &&
399+
t_module_data.Bytes()[3] == ((kMCScriptCurrentModuleVersion >> 8) & 0xFF)))
395400
{
396-
MCresult -> sets("out of memory");
397-
return false;
401+
t_is_module = false;
398402
}
399403

400404
MCAutoScriptModuleRefArray t_modules;
401-
if (!MCScriptCreateModulesFromStream(*t_stream, t_modules))
405+
MCScriptModuleRef t_main;
406+
407+
if (t_is_module)
402408
{
403-
MCAutoErrorRef t_error;
404-
if (MCErrorCatch(&t_error))
405-
MCresult->setvalueref(MCErrorGetMessage(*t_error));
406-
else
407-
MCresult->sets("out of memory");
409+
MCAutoValueRefBase<MCStreamRef> t_stream;
410+
if (!MCMemoryInputStreamCreate(t_module_data.Bytes(),
411+
p_length, &t_stream))
412+
{
413+
MCresult -> sets("out of memory");
414+
return false;
415+
}
408416

409-
return false;
417+
if (!MCScriptCreateModulesFromStream(*t_stream, t_modules))
418+
{
419+
MCAutoErrorRef t_error;
420+
if (MCErrorCatch(&t_error))
421+
MCresult->setvalueref(MCErrorGetMessage(*t_error));
422+
else
423+
MCresult->sets("out of memory");
424+
425+
return false;
426+
}
427+
428+
t_main = t_modules[0];
429+
}
430+
else
431+
{
432+
MCNewAutoNameRef t_name;
433+
if (!MCNameCreateWithNativeChars(t_module_data.Bytes(), p_length, &t_name) ||
434+
!MCScriptLookupModule(*t_name, t_main) ||
435+
!t_modules.Push(t_main))
436+
{
437+
MCresult->sets("out of memory");
438+
return false;
439+
}
410440
}
411441

412-
MCScriptModuleRef t_main = t_modules[0];
413-
414442
MCAutoStringRef t_module_resources;
415443
if (!MCStringFormat(&t_module_resources, "%@/resources",
416444
MCScriptGetNameOfModule(t_main)))

extensions/libraries/ini/inih/ini.ios

Whitespace-only changes.

extensions/libraries/ini/inih/inih.gyp

Lines changed: 86 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,23 @@
1111
'target_name': 'inih',
1212
'type': 'none',
1313

14-
'dependencies':
15-
[
16-
'inih-build',
17-
],
18-
1914
'conditions':
2015
[
2116
[
2217
'OS == "ios" and "iphoneos" in target_sdk',
2318
{
24-
'copies':
19+
'dependencies':
2520
[
26-
{
27-
'destination': '<(PRODUCT_DIR)/packaged_extensions/com.livecode.library.ini/code/<(platform_id)/',
28-
'files':
29-
[
30-
'<(PRODUCT_DIR)/inih<(STATIC_LIB_SUFFIX)',
31-
],
32-
},
21+
'inih-lcext',
3322
],
3423
},
3524
{
36-
25+
26+
'dependencies':
27+
[
28+
'inih-build',
29+
],
30+
3731
'copies':
3832
[
3933
{
@@ -76,6 +70,84 @@
7670
],
7771
],
7872
},
73+
{
74+
'target_name': 'inih-lcext',
75+
'product_prefix': '',
76+
'product_name': 'inih',
77+
'dependencies':
78+
[
79+
'../../../../toolchain/lc-compile/lc-compile.gyp:lc-compile',
80+
'inih-build',
81+
],
82+
83+
'type': 'none',
84+
85+
'actions':
86+
[
87+
{
88+
'action_name': 'ini_output_auxc',
89+
90+
'sources':
91+
[
92+
'../ini.lcb',
93+
],
94+
95+
'inputs':
96+
[
97+
'<(_sources)',
98+
],
99+
100+
'outputs':
101+
[
102+
'<(SHARED_INTERMEDIATE_DIR)/ini.cpp',
103+
],
104+
105+
'message': 'Output module as auxc',
106+
107+
'action':
108+
[
109+
'>(lc-compile_host)',
110+
'--forcebuiltins',
111+
'--modulepath',
112+
'<(PRODUCT_DIR)/modules/lci',
113+
'--outputauxc',
114+
'<(SHARED_INTERMEDIATE_DIR)/ini.cpp',
115+
'<(_sources)',
116+
],
117+
},
118+
{
119+
'action_name': 'link_ini_lcext',
120+
121+
'inputs':
122+
[
123+
'../../../../tools/build-module-lcext-ios.sh',
124+
'<(SHARED_INTERMEDIATE_DIR)/ini.cpp',
125+
'ini.ios',
126+
'<(PRODUCT_DIR)/inih<(STATIC_LIB_SUFFIX)',
127+
],
128+
129+
'outputs':
130+
[
131+
'<(PRODUCT_DIR)/inih.lcext',
132+
'<(PRODUCT_DIR)/packaged_extensions/com.livecode.library.ini/code/<(platform_id)/module.lcm'
133+
],
134+
135+
'message': 'Link lcext',
136+
137+
'action':
138+
[
139+
'../../../../tools/build-module-lcext-ios.sh',
140+
'<(SHARED_INTERMEDIATE_DIR)/ini.cpp',
141+
'ini.ios',
142+
'<(PRODUCT_DIR)/packaged_extensions/com.livecode.library.ini/code/<(platform_id)/inih.lcext',
143+
'$(not_a_real_variable)com.livecode.library.ini',
144+
'<(PRODUCT_DIR)/packaged_extensions/com.livecode.library.ini/code/<(platform_id)/module.lcm',
145+
'<(PRODUCT_DIR)/inih<(STATIC_LIB_SUFFIX)',
146+
],
147+
},
148+
149+
],
150+
},
79151
],
80152

81153
}

extensions/libraries/timezone/tz/tz.gyp

Lines changed: 88 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
'target_name': 'tz',
1717
'type': 'none',
1818

19-
'dependencies':
20-
[
21-
'libtz-build',
22-
],
23-
2419
'conditions':
2520
[
2621
[
@@ -35,19 +30,18 @@
3530
[
3631
'OS == "ios" and "iphoneos" in target_sdk',
3732
{
38-
'copies':
39-
[
40-
{
41-
'destination': '<(PRODUCT_DIR)/packaged_extensions/com.livecode.library.timezone/code/<(platform_id)/',
42-
'files':
43-
[
44-
'<(PRODUCT_DIR)/tz<(STATIC_LIB_SUFFIX)',
45-
],
46-
},
47-
],
33+
'dependencies':
34+
[
35+
'libtz-lcext',
36+
],
4837
},
4938
{
50-
39+
40+
'dependencies':
41+
[
42+
'libtz-build',
43+
],
44+
5145
'copies':
5246
[
5347
{
@@ -239,6 +233,84 @@
239233
],
240234
],
241235
},
236+
{
237+
'target_name': 'libtz-lcext',
238+
'product_prefix': '',
239+
'product_name': 'tz',
240+
'dependencies':
241+
[
242+
'../../../../toolchain/lc-compile/lc-compile.gyp:lc-compile',
243+
'libtz-build',
244+
],
245+
246+
'type': 'none',
247+
248+
'actions':
249+
[
250+
{
251+
'action_name': 'timezone_output_auxc',
252+
253+
'sources':
254+
[
255+
'../timezone.lcb',
256+
],
257+
258+
'inputs':
259+
[
260+
'<(_sources)',
261+
],
262+
263+
'outputs':
264+
[
265+
'<(SHARED_INTERMEDIATE_DIR)/timezone.cpp',
266+
],
267+
268+
'message': 'Output module as auxc',
269+
270+
'action':
271+
[
272+
'>(lc-compile_host)',
273+
'--forcebuiltins',
274+
'--modulepath',
275+
'<(PRODUCT_DIR)/modules/lci',
276+
'--outputauxc',
277+
'<(SHARED_INTERMEDIATE_DIR)/timezone.cpp',
278+
'<(_sources)',
279+
],
280+
},
281+
{
282+
'action_name': 'link_timezone_lcext',
283+
284+
'inputs':
285+
[
286+
'../../../../tools/build-module-lcext-ios.sh',
287+
'<(SHARED_INTERMEDIATE_DIR)/timezone.cpp',
288+
'tz.ios',
289+
'<(PRODUCT_DIR)/tz<(STATIC_LIB_SUFFIX)',
290+
],
291+
292+
'outputs':
293+
[
294+
'<(PRODUCT_DIR)/tz.lcext',
295+
'<(PRODUCT_DIR)/packaged_extensions/com.livecode.library.timezone/code/<(platform_id)/module.lcm'
296+
],
297+
298+
'message': 'Link lcext',
299+
300+
'action':
301+
[
302+
'../../../../tools/build-module-lcext-ios.sh',
303+
'<(SHARED_INTERMEDIATE_DIR)/timezone.cpp',
304+
'tz.ios',
305+
'<(PRODUCT_DIR)/packaged_extensions/com.livecode.library.timezone/code/<(platform_id)/tz.lcext',
306+
'$(not_a_real_variable)com.livecode.library.timezone',
307+
'<(PRODUCT_DIR)/packaged_extensions/com.livecode.library.timezone/code/<(platform_id)/module.lcm',
308+
'<(PRODUCT_DIR)/tz<(STATIC_LIB_SUFFIX)',
309+
],
310+
},
311+
312+
],
313+
},
242314
],
243315

244316
}

extensions/libraries/timezone/tz/tz.ios

Whitespace-only changes.

0 commit comments

Comments
 (0)