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

Commit cdad26d

Browse files
Refactor the "javac" rule to allow custom classpath settings
1 parent 0e7198e commit cdad26d

File tree

4 files changed

+107
-54
lines changed

4 files changed

+107
-54
lines changed

config/java.gypi

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
'variables':
3+
{
4+
'javac_wrapper_path': '../tools/javac_wrapper.sh',
5+
},
6+
7+
'rules':
8+
[
9+
10+
{
11+
'rule_name': 'aidl_interface_gen',
12+
'extension': 'aidl',
13+
14+
'message': ' AIDL <(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).java',
15+
'process_outputs_as_sources': 1,
16+
17+
'inputs':
18+
[
19+
'<(aidl_framework_path)',
20+
],
21+
22+
'outputs':
23+
[
24+
'<(INTERMEDIATE_DIR)/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).java',
25+
],
26+
27+
'action':
28+
[
29+
'<(aidl_path)',
30+
'-Isrc/java',
31+
'-p' '<@(_inputs)',
32+
'-o' '<(INTERMEDIATE_DIR)/src/java',
33+
'<(RULE_INPUT_PATH)',
34+
],
35+
},
36+
37+
{
38+
'rule_name': 'javac',
39+
'extension': 'java',
40+
41+
'message': ' JAVAC <(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).class',
42+
43+
'variables':
44+
{
45+
'java_classpath_param': ">!(['<(pathify_path)', '<(java_classpath)', '>@(java_extra_classpath)', '<(PRODUCT_DIR)/>(java_classes_dir_name)'])",
46+
47+
'java_extra_classpath%': '>(java_extra_classpath)',
48+
'variables':
49+
{
50+
'java_extra_classpath%': '',
51+
'pathify_path': '../tools/pathify.sh',
52+
},
53+
54+
'java_source_path': '../engine/src/java',
55+
},
56+
57+
'outputs':
58+
[
59+
# Java writes the output file based on the class name.
60+
# Use some Make nastiness to correct the output name
61+
'<(PRODUCT_DIR)/>(java_classes_dir_name)/$(subst\t/../livecode/engine,,$(subst\t<(INTERMEDIATE_DIR)/,,$(subst\tsrc/java/,,<(RULE_INPUT_DIRNAME))))/<(RULE_INPUT_ROOT).class',
62+
],
63+
64+
'action':
65+
[
66+
'<(javac_wrapper_path)',
67+
'<(javac_path)',
68+
'1.5',
69+
'-d', '<(PRODUCT_DIR)/>(java_classes_dir_name)',
70+
'-implicit:none',
71+
'-classpath', '>(java_classpath_param)',
72+
'-sourcepath', '<(java_source_path):<(INTERMEDIATE_DIR)/src/java',
73+
'<(RULE_INPUT_PATH)',
74+
],
75+
},
76+
],
77+
}

engine/kernel.gypi

Lines changed: 8 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -228,61 +228,15 @@
228228
[
229229
'OS == "android"',
230230
{
231-
'rules':
231+
'variables':
232+
{
233+
'java_classes_dir_name': 'classes_livecode_community',
234+
},
235+
236+
# Include the rules for compiling Java
237+
'includes':
232238
[
233-
234-
{
235-
'rule_name': 'aidl_interface_gen',
236-
'extension': 'aidl',
237-
238-
'message': ' AIDL <(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).java',
239-
'process_outputs_as_sources': 1,
240-
241-
'inputs':
242-
[
243-
'<(aidl_framework_path)',
244-
],
245-
246-
'outputs':
247-
[
248-
'<(INTERMEDIATE_DIR)/<(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).java',
249-
],
250-
251-
'action':
252-
[
253-
'<(aidl_path)',
254-
'-Isrc/java',
255-
'-p' '<@(_inputs)',
256-
'-o' '<(INTERMEDIATE_DIR)/src/java',
257-
'<(RULE_INPUT_PATH)',
258-
],
259-
},
260-
261-
{
262-
'rule_name': 'javac',
263-
'extension': 'java',
264-
265-
'message': ' JAVAC <(RULE_INPUT_DIRNAME)/<(RULE_INPUT_ROOT).class',
266-
267-
'outputs':
268-
[
269-
# Java writes the output file based on the class name.
270-
# Use some Make nastiness to correct the output name
271-
'<(PRODUCT_DIR)/classes_livecode_community/$(subst\t<(INTERMEDIATE_DIR)/,,$(subst\tsrc/java/,,<(RULE_INPUT_DIRNAME)))/<(RULE_INPUT_ROOT).class',
272-
],
273-
274-
'action':
275-
[
276-
'<(javac_path)',
277-
'-d', '<(PRODUCT_DIR)/classes_livecode_community',
278-
'-source', '1.5',
279-
#'-target', '1.5',
280-
'-implicit:none',
281-
'-cp', '<(java_classpath)',
282-
'-sourcepath', 'src/java:<(INTERMEDIATE_DIR)/src/java',
283-
'<(RULE_INPUT_PATH)',
284-
],
285-
},
239+
'../config/java.gypi',
286240
],
287241
}
288242
]

tools/javac_wrapper.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# This script exists to work around a Gyp bug that prevents passing the
4+
# '-source' and '-target' options with the same version number - the number
5+
# is interpreted as a filename and is unique-ified on the command line...
6+
7+
javac=$1
8+
version=$2
9+
shift 2
10+
11+
"$javac" -source $version -target $version $*
12+

tools/pathify.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Turns a series of arguments into a path string
4+
5+
for item in $*; do
6+
path="${path:+${path}:}${item}"
7+
done
8+
9+
echo $path
10+

0 commit comments

Comments
 (0)