Skip to content

Commit c54228e

Browse files
committed
Revert "Make generator support files common and add csc test in binding-integration-Tests."
This reverts commit fa5b016.
1 parent 7bd164c commit c54228e

40 files changed

+117
-274
lines changed

Java.Interop.sln

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Java.Interop.BootstrapTasks
101101
EndProject
102102
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "binding-integration-Tests", "tests\binding-integrated-Tests\binding-integration-Tests.csproj", "{D5CE4B09-C1D3-4647-B78B-6D2E89FE883E}"
103103
EndProject
104-
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "binding-support-files", "tests\binding-support-files\binding-support-files.shproj", "{AA1309A9-60BE-4BFD-802B-C44283669D58}"
105-
EndProject
106104
Global
107105
GlobalSection(SolutionConfigurationPlatforms) = preSolution
108106
Debug|Any CPU = Debug|Any CPU
@@ -405,6 +403,5 @@ Global
405403
{D1243BAB-23CA-4566-A2A3-3ADA2C2DC3AF} = {4C173212-371D-45D8-BA83-9226194F48DC}
406404
{3E8E5C8C-59A6-4A9A-B55D-46AB14431B2A} = {172B608B-E6F3-41CC-9949-203A76BA247C}
407405
{D5CE4B09-C1D3-4647-B78B-6D2E89FE883E} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
408-
{AA1309A9-60BE-4BFD-802B-C44283669D58} = {271C9F30-F679-4793-942B-0D9527CB3E2F}
409406
EndGlobalSection
410407
EndGlobal

src/Android.Interop/Android.Interop.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
1616
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
1717
<AssemblyName>Android.Interop</AssemblyName>
18-
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
18+
<TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
1919
</PropertyGroup>
2020
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2121
<DebugSymbols>true</DebugSymbols>

src/Android.Interop/Tests/Android.Interop-Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<AndroidApplication>True</AndroidApplication>
1717
<AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
1818
<AssemblyName>Android.Interop-Tests</AssemblyName>
19-
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
19+
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
2020
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
2121
</PropertyGroup>
2222
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -75,7 +75,7 @@
7575
<Import Project="..\..\Java.Interop.Export\Tests\Export-Tests.projitems" Label="Shared" Condition="Exists('..\..\Java.Interop.Export\Tests\Export-Tests.projitems')" />
7676
<Import Project="..\..\..\tests\PerformanceTests\PerformanceTests.projitems" Label="Shared" Condition="Exists('..\..\..\tests\PerformanceTests\PerformanceTests.projitems')" />
7777
<Import Project="..\..\Java.Interop.Dynamic\Tests\Dynamic-Tests.projitems" Label="Shared" Condition="Exists('..\..\Java.Interop.Dynamic\Tests\Dynamic-Tests.projitems')" />
78-
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
78+
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
7979
<PropertyGroup>
8080
<BuildDependsOn>
8181
BuildInteropTestJar;
@@ -100,7 +100,7 @@
100100
</ProjectReference>
101101
<ProjectReference Include="..\..\..\lib\mono.linq.expressions\Mono.Linq.Expressions.csproj">
102102
<Project>{0C001D50-4176-45AE-BDC8-BA626508B0CC}</Project>
103-
<Name>Mono.Linq.Expressions</Name>
103+
<Name>Mono.Linq.Expressions-Android</Name>
104104
</ProjectReference>
105105
<ProjectReference Include="..\..\Java.Interop.Dynamic\Java.Interop.Dynamic.csproj">
106106
<Project>{AD4468F8-8883-434B-9D4C-E1801BB3B52A}</Project>

src/Java.Interop.Dynamic/Tests/Dynamic-Tests.shproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<ProjectGuid>{8A190F28-74C7-45D8-A701-5864CDF4124A}</ProjectGuid>
5-
<ProductVersion>8.0.30703</ProductVersion>
6-
<SchemaVersion>2.0</SchemaVersion>
75
</PropertyGroup>
86
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
97
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />

src/Java.Interop.Export/Tests/Export-Tests.shproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<ProjectGuid>{849ABEDC-6A9C-44F0-8543-5298C096A3FB}</ProjectGuid>
5-
<ProductVersion>8.0.30703</ProductVersion>
6-
<SchemaVersion>2.0</SchemaVersion>
75
</PropertyGroup>
86
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
97
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />

src/Java.Interop/Tests/Interop-Tests.shproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<ProjectGuid>{0ADB8D72-7479-49AF-8809-E03AE4A4EAE2}</ProjectGuid>
5-
<ProductVersion>8.0.30703</ProductVersion>
6-
<SchemaVersion>2.0</SchemaVersion>
75
</PropertyGroup>
86
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
97
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />

src/java-interop/java-interop.csproj

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<ProductVersion>8.0.30703</ProductVersion>
88
<SchemaVersion>2.0</SchemaVersion>
99
<ProjectGuid>{BB0AB9F7-0979-41A7-B7A9-877260655F94}</ProjectGuid>
10-
<OutputType>Exe</OutputType>
1110
</PropertyGroup>
1211
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1312
<DebugSymbols>true</DebugSymbols>
@@ -60,18 +59,27 @@
6059
<Runtime Condition="'$(OS)' != 'Windows_NT'">mono</Runtime>
6160
</PropertyGroup>
6261
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)" />
63-
<Target Name="BuildJni_c" Inputs="$(JNIEnvGenPath)\jnienv-gen.exe" Outputs="jni.c">
62+
<Target Name="BuildJni_c"
63+
Inputs="$(JNIEnvGenPath)\jnienv-gen.exe"
64+
Outputs="jni.c">
6465
<MakeDir Directories="$(OutputPath)" />
6566
<Exec Command="$(Runtime) &quot;$(JNIEnvGenPath)\jnienv-gen.exe&quot; jni.g.cs jni.c" />
6667
</Target>
67-
<Target Name="BuildMac" Condition=" '$(OS)' != 'Windows_NT' And Exists ('/Library/Frameworks/')" DependsOnTargets="BuildMacLibraries" Inputs="@(MacLibLipo)" Outputs="$(OutputPath)\lib$(OutputName).dylib">
68+
<Target Name="BuildMac"
69+
Condition=" '$(OS)' != 'Windows_NT' And Exists ('/Library/Frameworks/')"
70+
DependsOnTargets="BuildMacLibraries"
71+
Inputs="@(MacLibLipo)"
72+
Outputs="$(OutputPath)\lib$(OutputName).dylib">
6873
<PropertyGroup>
6974
<_Files>@(MacLibLipo -&gt; '%(Identity)', ' ')</_Files>
7075
</PropertyGroup>
7176
<Message Text="Inputs: MacLibLipo=@(MacLibLipo)" />
7277
<Exec Command="lipo $(_Files) -create -output $(OutputPath)\lib$(OutputName).dylib" />
7378
</Target>
74-
<Target Name="BuildMacLibraries" Condition=" '$(OS)' != 'Windows_NT' And Exists ('/Library/Frameworks/')" Inputs="@(Compile)" Outputs="@(MacLibLipo)">
79+
<Target Name="BuildMacLibraries"
80+
Condition=" '$(OS)' != 'Windows_NT' And Exists ('/Library/Frameworks/')"
81+
Inputs="@(Compile)"
82+
Outputs="@(MacLibLipo)">
7583
<PropertyGroup>
7684
<_FixedDefines>$(DefineSymbols.Split(' '))</_FixedDefines>
7785
</PropertyGroup>
@@ -90,7 +98,10 @@
9098
<!-- Mono 4.4.0 (mono-4.4.0-branch/a3fabf1) has an incorrect shared library name. Fix it -->
9199
<Exec Command="install_name_tool -change /private/tmp/source-mono-4.4.0/bockbuild-mono-4.4.0-branch/profiles/mono-mac-xamarin/package-root/lib/libmonosgen-2.0.1.dylib /Library/Frameworks/Mono.framework/Libraries/libmonosgen-2.0.1.dylib &quot;%(MacLibLipo.Identity)&quot;" />
92100
</Target>
93-
<Target Name="BuildUnixLibraries" Condition=" '$(OS)' != 'Windows_NT' And !Exists ('/Library/Frameworks/')" Inputs="@(Compile)" Outputs="$(OutputPath)\lib$(OutputName).so">
101+
<Target Name="BuildUnixLibraries"
102+
Condition=" '$(OS)' != 'Windows_NT' And !Exists ('/Library/Frameworks/')"
103+
Inputs="@(Compile)"
104+
Outputs="$(OutputPath)\lib$(OutputName).so">
94105
<PropertyGroup>
95106
<_FixedDefines>$(DefineSymbols.Replace(' ', ';'))</_FixedDefines>
96107
</PropertyGroup>
@@ -110,7 +121,10 @@
110121
<Target Name="Clean">
111122
<RemoveDir Directories="obj" />
112123
<Delete Files="jni.c" />
113-
<Delete Files="$(OutputPath)\lib$(OutputName).dylib" Condition=" '$(OS)' != 'Windows_NT' " />
124+
<Delete
125+
Files="$(OutputPath)\lib$(OutputName).dylib"
126+
Condition=" '$(OS)' != 'Windows_NT' "
127+
/>
114128
</Target>
115129
<ItemGroup>
116130
<ProjectReference Include="..\..\build-tools\jnienv-gen\jnienv-gen.csproj">

tests/PerformanceTests/PerformanceTests.shproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<ProjectGuid>{0FBECD2A-7C91-41AB-A4B4-B781E8EC8479}</ProjectGuid>
5-
<ProductVersion>8.0.30703</ProductVersion>
6-
<SchemaVersion>2.0</SchemaVersion>
75
</PropertyGroup>
86
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
97
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />

tests/binding-integrated-Tests/BindingBuilder.cs

Lines changed: 8 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ public enum Steps
3434
public const string MetadataXmlSubDir = "metadata";
3535
public const string CSharpSourcesSubDir = "csharp";
3636

37-
public static string [] StubPartialSources =>
38-
Directory.GetFiles (Path.Combine (ThisAssemblyDirectory, "SupportFiles"), "*.cs")
39-
.Where (cs => cs.IndexOf ("Java_Lang_", StringComparison.OrdinalIgnoreCase) < 0)
40-
.Where (cs => !string.Equals (Path.GetFileName (cs), "JavaObject.cs", StringComparison.OrdinalIgnoreCase))
41-
.ToArray ();
42-
public static string [] StubAllSources =>
43-
Directory.GetFiles (Path.Combine (ThisAssemblyDirectory, "SupportFiles"), "*.cs");
44-
45-
static string ThisAssemblyDirectory => Path.GetDirectoryName (new Uri (typeof (BindingBuilder).Assembly.CodeBase).LocalPath);
46-
4737
public Steps ProcessSteps { get; set; } = Steps.All;
4838

4939
// entire work (intermediate output) directory
@@ -52,24 +42,7 @@ public enum Steps
5242
// Used to resolve javac and rt.jar
5343
public string JdkPath { get; set; }
5444

55-
public string GeneratorPath { get; set; } = Path.Combine (ThisAssemblyDirectory, "generator.exe");
56-
57-
public bool UseSystemCsc { get; set; } // we don't have to default to csc-dim, but why "not" ?
58-
59-
public string CscPath { get; set; }
60-
61-
static string GetMscorlibPath () => new Uri (typeof (object).Assembly.CodeBase).LocalPath;
62-
63-
static string ProbeCscDimPath ()
64-
{
65-
// For Windows, use nuget package. For Mac/Linux, use SYSMONO dim/csc.exe.
66-
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
67-
return Path.Combine ("..", "..", "..", "packages", "xamarin.android.csc.dim.0.1.2", "tools", "csc.exe");
68-
// assume path relative to framework dll in the GAC.
69-
return Path.GetFullPath (Path.Combine (GetMscorlibPath (), "..", "dim", "csc.exe"));
70-
}
71-
72-
static string GetSystemRuntimeDll () => Path.Combine (Path.GetDirectoryName (GetMscorlibPath ()), "Facades", "System.Runtime.dll");
45+
public string GeneratorPath { get; set; } = Path.Combine (Path.GetDirectoryName (new Uri (typeof (BindingBuilder).Assembly.CodeBase).LocalPath), "generator.exe");
7346

7447
static string ProbeJavaHome ()
7548
{
@@ -81,10 +54,7 @@ static string ProbeJavaHome ()
8154

8255
public static BindingBuilder CreateBestBetDefault (BindingProject project)
8356
{
84-
return new BindingBuilder (project) {
85-
JdkPath = ProbeJavaHome (),
86-
CscPath = ProbeCscDimPath (),
87-
};
57+
return new BindingBuilder (project) { JdkPath = ProbeJavaHome () };
8858
}
8959

9060
public BindingBuilder (BindingProject project)
@@ -155,8 +125,8 @@ void Javac ()
155125
project.JavacExecutionOutput = $"Execute javac as: {psi.FileName} {psi.Arguments}\n";
156126

157127
var proc = new Process () { StartInfo = psi };
158-
proc.OutputDataReceived += (sender, e) => project.JavacExecutionOutput += e.Data + '\n';
159-
proc.ErrorDataReceived += (sender, e) => project.JavacExecutionOutput += e.Data + '\n';
128+
proc.OutputDataReceived += (sender, e) => project.JavacExecutionOutput += e.Data;
129+
proc.ErrorDataReceived += (sender, e) => project.JavacExecutionOutput += e.Data;
160130
proc.Start ();
161131
proc.BeginOutputReadLine ();
162132
proc.BeginErrorReadLine ();
@@ -190,8 +160,8 @@ void Jar ()
190160
project.JarExecutionOutput = $"Execute jar as: {psi.FileName} {psi.Arguments}\n";
191161

192162
var proc = new Process () { StartInfo = psi };
193-
proc.OutputDataReceived += (sender, e) => project.JarExecutionOutput += e.Data + '\n';
194-
proc.ErrorDataReceived += (sender, e) => project.JarExecutionOutput += e.Data + '\n';
163+
proc.OutputDataReceived += (sender, e) => project.JarExecutionOutput += e.Data;
164+
proc.ErrorDataReceived += (sender, e) => project.JarExecutionOutput += e.Data;
195165
proc.Start ();
196166
proc.BeginOutputReadLine ();
197167
proc.BeginErrorReadLine ();
@@ -305,8 +275,8 @@ void GenerateBindingSources ()
305275
project.GeneratorExecutionOutput = $"Execute generator as: {psi.FileName} {psi.Arguments}\n";
306276

307277
var proc = new Process () { StartInfo = psi };
308-
proc.OutputDataReceived += (sender, e) => project.GeneratorExecutionOutput += e.Data + '\n';
309-
proc.ErrorDataReceived += (sender, e) => project.GeneratorExecutionOutput += e.Data + '\n';
278+
proc.OutputDataReceived += (sender, e) => project.GeneratorExecutionOutput += e.Data;
279+
proc.ErrorDataReceived += (sender, e) => project.GeneratorExecutionOutput += e.Data;
310280
proc.Start ();
311281
proc.BeginOutputReadLine ();
312282
proc.BeginErrorReadLine ();
@@ -317,63 +287,6 @@ void GenerateBindingSources ()
317287

318288
void CompileBindings ()
319289
{
320-
if ((ProcessSteps & Steps.Csc) == 0)
321-
return;
322-
323-
if (CscPath == null)
324-
throw new InvalidOperationException ("CscPath is not set.");
325-
326-
var objDir = IntermediateOutputPathAbsolute;
327-
EnsureDirectory (objDir);
328-
329-
if (project.GeneratedCSharpSourceFiles == null)
330-
project.GeneratedCSharpSourceDirectory = Path.Combine (objDir, CSharpSourcesSubDir);
331-
if (!Directory.GetFiles (project.GeneratedCSharpSourceDirectory, "*.cs").Any () && !project.CSharpSourceFiles.Any () && !project.CSharpSourceStrings.Any ())
332-
throw new InvalidOperationException ("No C# sources exist.");
333-
if (project.GeneratedDllFile == null)
334-
project.GeneratedDllFile = Path.Combine (objDir, project.Id + ".dll");
335-
336-
foreach (var item in project.CSharpSourceStrings)
337-
File.WriteAllText (Path.Combine (project.GeneratedCSharpSourceDirectory, item.FileName), item.Content);
338-
var csFiles = project.CSharpSourceFiles.AsEnumerable ();
339-
340-
switch (project.CSharpStubUsage) {
341-
case CSharpStubUsage.Partial:
342-
csFiles = csFiles.Concat (StubPartialSources);
343-
break;
344-
case CSharpStubUsage.Full:
345-
csFiles = csFiles.Concat (StubAllSources);
346-
break;
347-
}
348-
349-
string localSystemRuntime = Path.Combine (ThisAssemblyDirectory, "System.Runtime.dll");
350-
if (!File.Exists (localSystemRuntime))
351-
File.Copy (GetSystemRuntimeDll (), localSystemRuntime);
352-
353-
var psi = new ProcessStartInfo () {
354-
UseShellExecute = false,
355-
FileName = UseSystemCsc ? "csc" : CscPath,
356-
Arguments = $" -t:library -unsafe" +
357-
$" -out:\"{project.GeneratedDllFile}\" {project.GeneratedCSharpSourceDirectory}{Path.DirectorySeparatorChar}*.cs " +
358-
$" {string.Join (" ", csFiles.Select (s => '"' + s + '"'))}" +
359-
$" -r:{ThisAssemblyDirectory}{Path.DirectorySeparatorChar}System.Runtime.dll" +
360-
$" -r:{ThisAssemblyDirectory}{Path.DirectorySeparatorChar}Java.Interop.dll" +
361-
$" {string.Join (" ", project.ReferenceDlls.Select (s => " -r \"" + s + '"'))}",
362-
RedirectStandardOutput = true,
363-
RedirectStandardError = true,
364-
};
365-
366-
project.CscExecutionOutput = $"Execute csc as: {psi.FileName} {psi.Arguments}\n";
367-
368-
var proc = new Process () { StartInfo = psi };
369-
proc.OutputDataReceived += (sender, e) => project.CscExecutionOutput += e.Data + '\n';
370-
proc.ErrorDataReceived += (sender, e) => project.CscExecutionOutput += e.Data + '\n';
371-
proc.Start ();
372-
proc.BeginOutputReadLine ();
373-
proc.BeginErrorReadLine ();
374-
proc.WaitForExit ();
375-
if (proc.ExitCode != 0)
376-
throw new Exception ("csc failed: " + project.CscExecutionOutput);
377290
}
378291
}
379292
}

tests/binding-integrated-Tests/BindingProject.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,12 @@ public class SourceFile
88
public string Content { get; set; }
99
}
1010

11-
public enum CSharpStubUsage
12-
{
13-
None,
14-
Partial,
15-
Full,
16-
}
17-
1811
public class BindingProject
1912
{
2013
public string Id { get; set; }
2114

2215
public string JavacOptions { get; set; } = "-g";
23-
public string GeneratorOptions { get; internal set; } = " --codegen-target=XAJavaInterop1 --public";
24-
public CSharpStubUsage CSharpStubUsage { get; set; } = CSharpStubUsage.Full;
16+
public string GeneratorOptions { get; internal set; }
2517

2618
public IList<string> JavaSourceFiles { get; set; } = new List<string> ();
2719
public IList<SourceFile> JavaSourceStrings { get; set; } = new List<SourceFile> ();

0 commit comments

Comments
 (0)