build.gradle 3.44 KB
Newer Older
1
2
plugins
{
3
4
5
6
	// C++ needs to be first otherwise the build will break
	id "cpp-library"
	id "java-library"
	id "java-test-fixtures"
7
}
8

9
10
11
description = "This library provides the base support for testing and " +
	"running SquirrelJME on a Java SE host, which is normally not " +
	"capable of doing as such."
12

13
14
15
16
17
18
19
20
// Although it would be useful to use Java 8, we have to stay on Java 7
// because SquirrelJME is a Java 7 VM.
compileJava
{
	sourceCompatibility = JavaVersion.VERSION_1_7
	targetCompatibility = JavaVersion.VERSION_1_7
}

21
22
23
24
// Due to the combination of C++ and Java these dependencies have to be very
// specific in that they only refer to the Java or C++ portion. So
// "implementation" and "compile" cannot be used because the C++ library will
// try to use them during compilation.
25
26
dependencies
{
27
28
	// We need these two modules to obtain the SquirrelJME specific classes
	compileClasspath project(":modules:cldc-compact")
29
30
	compileClasspath project(":modules:common-vm")
	compileClasspath project(":modules:io")
31
	compileClasspath project(":modules:tac")
32
	compileClasspath project(":modules:zip")
33
	compileClasspath project(":modules:debug-jdwp")
34
35

	// And for run-time to be able to be ran
36
	runtimeClasspath project(":modules:cldc-compact")
37
38
	runtimeClasspath project(":modules:common-vm")
	runtimeClasspath project(":modules:io")
39
	runtimeClasspath project(":modules:tac")
40
	runtimeClasspath project(":modules:zip")
41
	runtimeClasspath project(":modules:debug-jdwp")
42
43
44
45
}

// We need the native library in the JAR before we can properly use it
// But we can compile the Java code just fine without it
46
boolean useDebugLib = false
47
jar {
48
49
50
51
52
	dependsOn (useDebugLib ? "assembleDebug" : "assembleRelease")
	
	java.nio.file.Path libPath = buildDir.toPath().resolve("lib")
		.resolve("main").resolve((useDebugLib ? "debug" : "release"))
	project.ext.libPathBase = libPath
53

54
	from libPath.toFile()
55
	into "/"
56
}
Stephanie Gawroriski's avatar
Stephanie Gawroriski committed
57
58
59
60
61
62
63
64
65

java
{
	javadoc.options.tags = [ "squirreljme.property",
		"squirreljme.env",
		"squirreljme.error",
		"squirreljme.syscallparam",
		"squirreljme.syscallreturn",
		"squirreljme.tsiparam",
66
67
		"squirreljme.configtype",
		"squirreljme.uiwidgetparam" ]
Stephanie Gawroriski's avatar
Stephanie Gawroriski committed
68
69
}

70
71
// Improve debugging with native code compiles, these are only used by the
// build system tests so these do not impact users at all
72
73
74
75
76
77
78
79
tasks.withType(CppCompile).configureEach() {item ->
	// Never do this for release!
	if (item.name.toLowerCase().contains("release")) {
		return
	}

	item.debuggable = true
	item.optimized = false
80
81
	
	// Additional compiler options for each compiler
82
	item.compilerArgs.addAll toolChain.map { toolChain ->
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
		// Microsoft Visual C++
		if ("visualCpp".equalsIgnoreCase(toolChain.name)) {
			return [
				// Disable optimization
				"/Od",
			
				// Buffer security check
				"/GS",
				
				// Run-time error checking
				"/RTC",
				
				// Enable all warnings
				"/Wall",
				
				// Our object files contain _full_ debug info
				"/Z7",
				
				// End
				]
		}
		
		return []
	}
}

// Ensure debugging information is used when linking
110
111
112
113
114
115
116
tasks.withType(LinkSharedLibrary).configureEach() { item ->
	// Never do this for release!
	if (item.name.toLowerCase().contains("release")) {
		return
	}
	
	item.getDebuggable().set(true)
117
118
	
	// Additional compiler options for each compiler
119
	item.linkerArgs.addAll toolChain.map { toolChain ->
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
		// Microsoft Visual C++
		if ("visualCpp".equalsIgnoreCase(toolChain.name)) {
			return [
				// Full debug info
				"/DEBUG:FULL",
				
				// Create map file
				"/MAP"
			
				// End
				]
		}
		
		return []
	}
}