Merge pull request #3577 from noverby/wip/rib/java-codegen
Include target build directory while compiling Java, for generated code dependencies (Polished)pull/2577/merge
commit
4d7ff40460
10 changed files with 94 additions and 3 deletions
@ -1,6 +1,5 @@ |
||||
javaprog = jar('myprog', |
||||
'com/mesonbuild/Simple.java', |
||||
'com/mesonbuild/TextPrinter.java', |
||||
main_class : 'com.mesonbuild.Simple', |
||||
include_directories : include_directories('.')) |
||||
main_class : 'com.mesonbuild.Simple') |
||||
test('subdirtest', javaprog) |
||||
|
@ -0,0 +1,8 @@ |
||||
package com.mesonbuild; |
||||
|
||||
class Simple { |
||||
public static void main(String [] args) { |
||||
TextPrinter t = new TextPrinter("Printing from Java."); |
||||
t.print(); |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
package com.mesonbuild; |
||||
|
||||
class TextPrinter { |
||||
|
||||
private String msg; |
||||
|
||||
TextPrinter(String s) { |
||||
msg = s; |
||||
} |
||||
|
||||
public void print() { |
||||
System.out.println(msg); |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
# The Ninja backend used to try and pass -sourcepath repeatedly for |
||||
# multiple includes which would discard prior includes. Since this |
||||
# won't compile without the '.' include, this ensures that multiple |
||||
# paths are passed in a [semi-]colon separated list instead... |
||||
|
||||
project('includedirsjava', 'java') |
||||
|
||||
javaprog = jar('myprog', |
||||
'com/mesonbuild/Simple.java', |
||||
'com/mesonbuild/TextPrinter.java', |
||||
main_class : 'com.mesonbuild.Simple', |
||||
include_directories : [ include_directories('com'), |
||||
include_directories('com/mesonbuild') ]) |
||||
test('subdirtest', javaprog) |
@ -0,0 +1,5 @@ |
||||
package com.mesonbuild; |
||||
|
||||
public class Config { |
||||
public static final boolean FOOBAR = @foobar@; |
||||
} |
@ -0,0 +1,12 @@ |
||||
package com.mesonbuild; |
||||
|
||||
import com.mesonbuild.Config; |
||||
|
||||
class Simple { |
||||
public static void main(String [] args) { |
||||
if (Config.FOOBAR) { |
||||
TextPrinter t = new TextPrinter("Printing from Java."); |
||||
t.print(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
package com.mesonbuild; |
||||
|
||||
class TextPrinter { |
||||
|
||||
private String msg; |
||||
|
||||
TextPrinter(String s) { |
||||
msg = s; |
||||
} |
||||
|
||||
public void print() { |
||||
System.out.println(msg); |
||||
} |
||||
} |
@ -0,0 +1,6 @@ |
||||
|
||||
conf_data = configuration_data() |
||||
conf_data.set('foobar', 'true') |
||||
config_file = configure_file(input : 'Config.java.in', |
||||
output : 'Config.java', |
||||
configuration : conf_data) |
@ -0,0 +1,15 @@ |
||||
# If we generate code under the build directory then the backend needs to add |
||||
# the build directory to the -sourcepath passed to javac otherwise the compiler |
||||
# won't be able to handle the -implicit:class behaviour of automatically |
||||
# compiling dependency classes. |
||||
|
||||
project('codegenjava', 'java') |
||||
|
||||
subdir('com/mesonbuild') |
||||
|
||||
javaprog = jar('myprog', |
||||
config_file, |
||||
'com/mesonbuild/Simple.java', |
||||
'com/mesonbuild/TextPrinter.java', |
||||
main_class : 'com.mesonbuild.Simple') |
||||
test('subdirtest', javaprog) |
Loading…
Reference in new issue