@@ -112,7 +112,7 @@ project.ext {
112
112
" XBUILD_EXE" , false , {
113
113
unityRootDirTree. matching {
114
114
include (operatingSystem == OperatingSystem . WINDOWS ?
115
- " **/Mono/ bin/xbuild.bat" : " **/xbuild" )
115
+ " **/bin/xbuild.bat" : " **/xbuild" )
116
116
exclude unitySearchDirExcludes
117
117
}
118
118
})
@@ -121,6 +121,51 @@ project.ext {
121
121
}
122
122
saveProperty(" XBUILD_EXE" , xbuildExe, cacheProperties)
123
123
124
+ // Find mono to determine the distribution being used.
125
+ monoExe = getFileFromPropertyOrFileTree(
126
+ " MONO_EXE" , false , {
127
+ unityRootDirTree. matching {
128
+ include (operatingSystem == OperatingSystem . WINDOWS ?
129
+ " **/bin/mono.bat" : " **/bin/mono" )
130
+ exclude unitySearchDirExcludes
131
+ }
132
+ })
133
+ saveProperty(" MONO_EXE" , monoExe, cacheProperties)
134
+
135
+ // Get the mono distribution version.
136
+ def versionRegEx = / ^.* version ([^ ]+) .*/
137
+ def stdout = new ByteArrayOutputStream ()
138
+ exec {
139
+ commandLine monoExe, " -V"
140
+ ignoreExitValue true
141
+ standardOutput = stdout
142
+ }
143
+ def monoVersionList =
144
+ stdout. toString(). replace(" \r\n " , " \n " ). tokenize(" \n " ). findResults {
145
+ def versionMatch = it =~ versionRegEx
146
+ if (versionMatch. matches()) {
147
+ return versionMatch. group(1 )
148
+ }
149
+ return null
150
+ }
151
+ if (! monoVersionList) {
152
+ throw new StopActionException (
153
+ sprintf (" Unable to determine mono version from %s" , monoExe))
154
+ }
155
+ monoVersion = monoVersionList[0 ]
156
+
157
+ // Mono 5.x and above generate .pdb files that are compatible with visual
158
+ // studio as opposed to the mono-specific .pdb files.
159
+ pdbSupported = monoVersion. tokenize(" ." )[0 ]. toInteger() >= 5
160
+
161
+ if (pdbSupported) {
162
+ logger. warn(
163
+ sprintf (" Mono %s detected which will generate .pdb files " +
164
+ " that are not compatible with older versions of Unity. " +
165
+ " This can be fixed by compiling with Unity 5.6." ,
166
+ monoVersion))
167
+ }
168
+
124
169
// Find the NUnit framework dll.
125
170
unityNUnitDll = getFileFromPropertyOrFileTree(
126
171
" UNITY_NUNIT_PATH" , true , {
@@ -139,7 +184,7 @@ project.ext {
139
184
" NUNIT_CONSOLE_EXE" , false , {
140
185
unityRootDirTree. matching {
141
186
include (operatingSystem == OperatingSystem . WINDOWS ?
142
- " **/Mono/ bin/nunit-console2.bat" :
187
+ " **/bin/nunit-console2.bat" :
143
188
" **/nunit-console2" )
144
189
exclude unitySearchDirExcludes
145
190
}
@@ -170,7 +215,7 @@ project.ext {
170
215
unityPackagePath = findFileProperty(" UNITY_PACKAGE_PATH" , null )
171
216
172
217
// Whether debug symbols should be included.
173
- debugEnabled = findProperty( " NDEBUG " ) == null
218
+ debugEnabled = true
174
219
175
220
// Whether interactive mode tests are enabled.
176
221
interactiveModeTestsEnabled =
@@ -231,8 +276,8 @@ project.ext {
231
276
unityInteractiveModeArguments = [" -gvh_noninteractive" ]
232
277
// Extension for Unity asset metadata files.
233
278
unityMetadataExtension = " .meta"
234
- // Extension for debug files.
235
- dllMdbExtension = " .mdb"
279
+ // Extensions for debug files.
280
+ symbolDatabaseExtension = pdbSupported ? " .pdb " : " .dll .mdb"
236
281
// Changelog file.
237
282
changelog = new File (scriptDirectory, " CHANGELOG.md" )
238
283
pythonBootstrapDir = new File (buildDir, " python_bootstrap" )
@@ -414,8 +459,8 @@ void checkNUnitConsolePath() {
414
459
List<String > splitFilenameExtension (File fileObj ) {
415
460
String filename = fileObj. name
416
461
int extensionIndex =
417
- (filename - project. ext. unityMetadataExtension -
418
- project. ext. dllMdbExtension ). lastIndexOf(" ." )
462
+ (filename - project. ext. symbolDatabaseExtension -
463
+ project. ext. unityMetadataExtension ). lastIndexOf(" ." )
419
464
if (extensionIndex < 0 ) return [filename, " " ]
420
465
String basename = filename. substring(0 , extensionIndex)
421
466
String extension = filename. substring(extensionIndex)
@@ -554,7 +599,7 @@ File copyAssetMetadataFile(File sourceFile, File targetFile) {
554
599
if (! sourceFile. name. endsWith(project. ext. unityMetadataExtension)) {
555
600
return copyFile(sourceFile, targetFile)
556
601
}
557
- String [] lines = sourceFile. text. split (" \n " )
602
+ String [] lines = sourceFile. text. tokenize (" \n " )
558
603
559
604
// Parse the existing version from the asset metadata.
560
605
def folderAssetRegEx = / ^folderAsset:\s +yes\s *$/
@@ -639,7 +684,18 @@ Task createXbuildTask(String taskName, String taskDescription,
639
684
Iterable<File > outputFilesInBinaryOutputDir = outputFiles. collect {
640
685
return new File (binaryOutputDir, it. path)
641
686
}
687
+
688
+ if (project. ext. debugEnabled) {
689
+ outputFilesInBinaryOutputDir + = outputFilesInBinaryOutputDir. findResults {
690
+ return it. name. endsWith(" .dll" ) ?
691
+ new File (it. parentFile. path,
692
+ splitFilenameExtension(it)[0 ] +
693
+ project. ext. symbolDatabaseExtension) : null
694
+ }
695
+ }
696
+
642
697
Iterable<Task > dependsOnTasks = dependsOn ? dependsOn : []
698
+ Iterable<Task > compileTaskDependencies = dependsOnTasks. clone()
643
699
Iterable<Task > patchVersionFilesTasks = inputFiles. findResults {
644
700
if (it. name == " VersionNumber.cs" ) {
645
701
File versionFile = it
@@ -668,12 +724,14 @@ Task createXbuildTask(String taskName, String taskDescription,
668
724
return patchVersionTask
669
725
}
670
726
}
727
+ if (patchVersionFilesTasks) {
728
+ compileTaskDependencies + = patchVersionFilesTasks
729
+ }
730
+
671
731
Task task = tasks. create(name : taskName,
672
732
description : taskDescription,
673
733
type : Exec ,
674
- dependsOn : patchVersionFilesTasks ?
675
- patchVersionFilesTasks :
676
- dependsOnTasks). with {
734
+ dependsOn : compileTaskDependencies). with {
677
735
inputs. files inputFiles
678
736
outputs. files files(outputFilesInBinaryOutputDir)
679
737
executable project. ext. xbuildExe
@@ -723,25 +781,21 @@ Task createBuildPluginDllTask(String componentName,
723
781
File projectDir = new File (project. ext. pluginSourceDir, projectName)
724
782
File projectBuildDir = new File (project. ext. buildDir, projectName)
725
783
726
- List<File > buildFiles = [new File (assemblyDllBasename)]
727
- if (project. ext. debugEnabled) {
728
- buildFiles + = [new File (assemblyDllBasename + project. ext. dllMdbExtension)]
729
- }
730
-
731
784
// Compile the C# project.
732
785
Task compileTask = createXbuildTask(
733
786
sprintf (" compile%s" , componentName), sprintf (" Compile %s" , projectName),
734
787
project. ext. pluginSolutionFile, projectName,
735
788
fileTree(new File (projectDir, " src" )), projectBuildDir,
736
- buildFiles , dependsOn)
789
+ [ new File (assemblyDllBasename)] , dependsOn)
737
790
compileTask. ext. componentName = componentName
738
791
739
792
// Template metadata for the built DLL.
740
- Iterable<File > assemblyDllMetaFiles = buildFiles. collect {
741
- new File (new File (project. ext. pluginTemplateDir,
742
- project. ext. pluginEditorDllDir. path),
743
- it. name + project. ext. unityMetadataExtension)
744
- }
793
+ Iterable<File > assemblyDllMetaFiles =
794
+ compileTask. outputs. files. collect {
795
+ new File (new File (project. ext. pluginTemplateDir,
796
+ project. ext. pluginEditorDllDir. path),
797
+ it. name + project. ext. unityMetadataExtension)
798
+ }
745
799
// Optionally map unversioned to versioned filenames.
746
800
Iterable<File > unversionedFiles = files(compileTask. outputs. files,
747
801
assemblyDllMetaFiles)
@@ -942,7 +996,6 @@ Task createUnityTask(String taskName, String summary,
942
996
executeArguments)
943
997
}
944
998
unityTask. with {
945
- inputs. files fileTree(projectDir)
946
999
outputs. files files(logFile)
947
1000
}
948
1001
unityTask. ext. projectDir = projectDir
@@ -1030,22 +1083,32 @@ Task createUnityTestTask(String taskName, String description,
1030
1083
Iterable<File > editorAssets ,
1031
1084
Iterable<String > additionalArguments ,
1032
1085
Boolean batchMode , createTaskClosure ) {
1033
- List<File > inputFiles = fileTree(testScriptsDir). collect {
1034
- new File (it. absolutePath - testScriptsDir. absolutePath)
1086
+ List<File > testScripts = []
1087
+ if (testScriptsDir) {
1088
+ testScripts = fileTree(testScriptsDir). collect {
1089
+ new File (it. absolutePath. substring(
1090
+ testScriptsDir. absolutePath. length() + 1 ))
1091
+ }
1035
1092
}
1093
+
1036
1094
// Setup the Unity project.
1037
1095
Task setupTestProject = createSetupUnityProjectTask(
1038
1096
sprintf (" setup%s" , taskName), dependsOn, taskName, batchMode)
1039
1097
setupTestProject. with {
1040
- inputs. files inputFiles
1098
+ inputs. files (testScripts + editorAssets)
1041
1099
}
1042
1100
1101
+ List<Task > copyTasks = []
1102
+
1043
1103
// Task which copies test scripts into the project.
1044
- Task copyTestScripts = createCopyFilesTask(
1045
- sprintf (" copyScriptsFor%s" , taskName),
1046
- sprintf (" Copy the test scripts into the %s Unity project." , taskName),
1047
- inputFiles, testScriptsDir, setupTestProject. ext. projectDir,
1048
- [setupTestProject], null )
1104
+ if (testScriptsDir) {
1105
+ Task copyTestScripts = createCopyFilesTask(
1106
+ sprintf (" copyScriptsFor%s" , taskName),
1107
+ sprintf (" Copy the test scripts into the %s Unity project." , taskName),
1108
+ testScripts, testScriptsDir, setupTestProject. ext. projectDir,
1109
+ [setupTestProject], null )
1110
+ copyTasks + = [copyTestScripts]
1111
+ }
1049
1112
1050
1113
// Task which copies editor scripts into the project.
1051
1114
Task copyEditorAssets = tasks. create(
@@ -1059,10 +1122,11 @@ Task createUnityTestTask(String taskName, String description,
1059
1122
into new File (new File (setupTestProject. ext. projectDir, " Assets" ),
1060
1123
" Editor" )
1061
1124
}
1125
+ copyTasks + = [copyEditorAssets]
1062
1126
1063
1127
// Create the test task.
1064
1128
Task testTask = createUnityTask(taskName, " test" ,
1065
- [copyTestScripts, copyEditorAssets] ,
1129
+ copyTasks ,
1066
1130
setupTestProject. ext. projectDir. name,
1067
1131
setupTestProject. ext. containerDir,
1068
1132
additionalArguments, batchMode,
@@ -1124,8 +1188,7 @@ Task compileResolverLibTests = createXbuildTask(
1124
1188
fileTree(new File (new File (project. ext. pluginSourceDir,
1125
1189
" JarResolverLib" ), " src" )),
1126
1190
new File (project. ext. testDir, " ResolverLibTests" ),
1127
- [new File (" JarResolverTests.dll" ),
1128
- new File (" JarResolverTests.dll.mdb" )], []). with {
1191
+ [new File (" JarResolverTests.dll" )], []). with {
1129
1192
doFirst { checkNUnitDllPath() }
1130
1193
}
1131
1194
@@ -1546,7 +1609,7 @@ task gitAddReleaseFilesToStaging(type: Exec, dependsOn: releasePlugin) {
1546
1609
*/
1547
1610
String readVersionSummaryFromChangelog () {
1548
1611
String versionSummary = " "
1549
- for (String line in project. ext. changelog. text. split (" \n " )) {
1612
+ for (String line in project. ext. changelog. text. tokenize (" \n " )) {
1550
1613
String trimmedLine = line. trim()
1551
1614
if (line. isEmpty()) break
1552
1615
versionSummary + = line + " \n "
@@ -1631,8 +1694,7 @@ Task compileVersionHandlerImplTests = createXbuildTask(
1631
1694
" unit_tests" ),
1632
1695
" src" )),
1633
1696
new File (project. ext. testDir, " VersionHandlerImplTests" ),
1634
- [new File (" Google.VersionHandlerImplTests.dll" ),
1635
- new File (" Google.VersionHandlerImplTests.dll.mdb" )], []). with {
1697
+ [new File (" Google.VersionHandlerImplTests.dll" )], []). with {
1636
1698
doFirst { checkNUnitDllPath() }
1637
1699
}
1638
1700
@@ -1653,8 +1715,7 @@ Task compileUnityPackageManagerResolverTests = createXbuildTask(
1653
1715
" unit_tests" ),
1654
1716
" src" )),
1655
1717
new File (project. ext. testDir, " UnityPackageManagerResolverTests" ),
1656
- [new File (" Google.UnityPackageManagerResolverTests.dll" ),
1657
- new File (" Google.UnityPackageManagerResolverTests.dll.mdb" )],
1718
+ [new File (" Google.UnityPackageManagerResolverTests.dll" )],
1658
1719
[buildUnityPackageManagerResolver]). with {
1659
1720
doFirst { checkNUnitDllPath() }
1660
1721
}
@@ -1717,8 +1778,7 @@ Task compileIntegrationTester = createXbuildTask(
1717
1778
fileTree(new File (project. ext. pluginSourceDir,
1718
1779
" IntegrationTester" )),
1719
1780
new File (project. ext. buildDir, " IntegrationTester" ),
1720
- [new File (" Google.IntegrationTester.dll" ),
1721
- new File (" Google.IntegrationTester.dll.mdb" )],
1781
+ [new File (" Google.IntegrationTester.dll" )],
1722
1782
[compileVersionHandler])
1723
1783
1724
1784
/*
@@ -1775,8 +1835,7 @@ createUnityIntegrationTest(
1775
1835
" AndroidResolverIntegrationTests" ,
1776
1836
fileTree(new File (new File (project. ext. pluginSourceDir, " AndroidResolver" ),
1777
1837
" test" )),
1778
- [new File (" Google.AndroidResolverIntegrationTests.dll" ),
1779
- new File (" Google.AndroidResolverIntegrationTests.dll.mdb" )],
1838
+ [new File (" Google.AndroidResolverIntegrationTests.dll" )],
1780
1839
new File (
1781
1840
project. ext. scriptDirectory,
1782
1841
" source/AndroidResolver/test/AndroidResolverIntegrationTestsUnityProject" ),
0 commit comments