summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-05 17:59:01 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-06 11:20:19 -0300
commit17a81bee4a53891e44a165a14ca20027f9aa0824 (patch)
tree744dcdbea803e8eaaac8af6a55c35b2d7fcaab7c /src
parent8a5976666b1566f0025f9aff394002b766069beb (diff)
csharp: Revamp dotnet support
Summary: Instead of building with a patched meson version, make use of custom targets and generated csproj files so we can used upstream meson normally. This avoids digging into "non official" dotnet stuff like calling the CSC.dll directly that the patched meson tried to do. To enable, run meson with `-Ddotnet=true`. Regarding source file dependencies, Meson has a limitation[1] about generated artifacts being placed in subdirectories. In order to correctly track these generated artifacts for dotnet, we generated them in the same folder as the csproj file through `dotnet build -o`. Instead of installing the dll like we do for mono, a nupkg is generated and installed in the same folder as the dll would be (<prefix>/lib/x86_64-linux-gnu/efl-mono-1) To avoid messing around with Nupkg caches, we reference the source project for the library directly instead of the nupkg when building the test suite. [1] https://github.com/mesonbuild/meson/issues/2320 Fixes T8168 Reviewers: bu5hm4n, woohyun, Jaehyun_Cho Reviewed By: Jaehyun_Cho Subscribers: cedric, brunobelo, felipealmeida, segfaultxavi Tags: #efl, #do_not_merge Maniphest Tasks: T8168 Differential Revision: https://phab.enlightenment.org/D9717
Diffstat (limited to 'src')
-rw-r--r--src/bindings/mono/efl_mono/meson.build7
-rw-r--r--src/bindings/mono/efl_sharp.csproj.in39
-rw-r--r--src/bindings/mono/eo_mono/EoWrapper.cs1
-rw-r--r--src/bindings/mono/meson.build113
-rw-r--r--src/tests/efl_mono/efl_sharp_test_suite.csproj.in36
-rw-r--r--src/tests/efl_mono/meson.build152
6 files changed, 251 insertions, 97 deletions
diff --git a/src/bindings/mono/efl_mono/meson.build b/src/bindings/mono/efl_mono/meson.build
index 6542f51..8bfba31 100644
--- a/src/bindings/mono/efl_mono/meson.build
+++ b/src/bindings/mono/efl_mono/meson.build
@@ -37,8 +37,11 @@ efl_src = configure_file(
37friend_assemblies = '' 37friend_assemblies = ''
38mono_friend_assemblies = get_option('mono-friend-assemblies') 38mono_friend_assemblies = get_option('mono-friend-assemblies')
39if get_option('build-tests') 39if get_option('build-tests')
40 mono_friend_assemblies += 'efl-mono-suite' 40 if get_option('dotnet')
41 mono_friend_assemblies += 'efl_mono_test' 41 mono_friend_assemblies += 'efl_sharp_test_suite'
42 else
43 mono_friend_assemblies += 'efl_mono_test'
44 endif
42endif 45endif
43 46
44foreach f : mono_friend_assemblies 47foreach f : mono_friend_assemblies
diff --git a/src/bindings/mono/efl_sharp.csproj.in b/src/bindings/mono/efl_sharp.csproj.in
new file mode 100644
index 0000000..d44aa5a
--- /dev/null
+++ b/src/bindings/mono/efl_sharp.csproj.in
@@ -0,0 +1,39 @@
1<Project Sdk="Microsoft.NET.Sdk">
2
3 <PropertyGroup>
4 <OutputType>Library</OutputType>
5 <TargetFramework>netstandard@NETSTANDARD_VERSION@</TargetFramework>
6 </PropertyGroup>
7
8 <PropertyGroup>
9 <PackageId>Efl.Csharp</PackageId>
10 <Version>@EFL_VERSION@</Version>
11 <Authors>EFL Team</Authors>
12 <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
13 </PropertyGroup>
14
15 <!-- <PropertyGroup Condition="'$(BuildType)'=='Beta'"> -->
16 <!-- <DefineConstants>EFL_BETA</DefineConstants> -->
17 <!-- </PropertyGroup> -->
18 <PropertyGroup>
19 <DefineConstants>@EFL_BETA@</DefineConstants>
20 </PropertyGroup>
21
22 <ItemGroup>
23 <Compile Include="@BINDING_SRC@/efl_mono/*.cs" />
24 <!-- FIXME Windows support -->
25 <Compile Include="@BINDING_SRC@/eo_mono/*.cs" Exclude="@BINDING_SRC@/eo_mono/*Windows.cs" />
26 <Compile Include="@BINDING_SRC@/eina_mono/*.cs" />
27 <Compile Include="@BINDING_SRC@/eolian_mono/*.cs" />
28 <Compile Include="@BINDING_SRC@/eldbus_mono/*.cs" />
29 </ItemGroup>
30
31 <!-- Calling `dotnet build` from a different folder seems to mess up the automatic source file discovery.
32 But we want them to be included only when building the lib itself.
33 -->
34 <ItemGroup Condition="'$(BuildingLib)'=='Yes'">
35 <Compile Include="./efl_mono/*.cs" />
36 <Compile Include="./*.cs" />
37 </ItemGroup>
38
39</Project>
diff --git a/src/bindings/mono/eo_mono/EoWrapper.cs b/src/bindings/mono/eo_mono/EoWrapper.cs
index 621a8bc..4209fa7 100644
--- a/src/bindings/mono/eo_mono/EoWrapper.cs
+++ b/src/bindings/mono/eo_mono/EoWrapper.cs
@@ -483,6 +483,7 @@ public abstract class EoWrapper : IWrapper, IDisposable
483/// allow minimal interaction with them through <see cref="Efl.Object" />. 483/// allow minimal interaction with them through <see cref="Efl.Object" />.
484/// 484///
485/// But as <see cref="Efl.Object" /> is abstract, whis realized class will allow us to create C# instances of it.</summary> 485/// But as <see cref="Efl.Object" /> is abstract, whis realized class will allow us to create C# instances of it.</summary>
486[Efl.Object.NativeMethods]
486internal class ObjectRealized : Efl.Object 487internal class ObjectRealized : Efl.Object
487{ 488{
488 internal ObjectRealized(Efl.Eo.WrappingHandle ch) : base(ch) { } 489 internal ObjectRealized(Efl.Eo.WrappingHandle ch) : base(ch) { }
diff --git a/src/bindings/mono/meson.build b/src/bindings/mono/meson.build
index 9545aa1..86cef4d 100644
--- a/src/bindings/mono/meson.build
+++ b/src/bindings/mono/meson.build
@@ -1,33 +1,11 @@
1add_languages('cs') 1# dotnet supports cs files indirectly through custom_targets
2if not get_option('dotnet')
3 add_languages('cs')
4endif
2 5
3 6
4runtime_assemblies = [] 7runtime_assemblies = []
5 8
6# Check if we should use dotnet options
7cs_is_dotnet = meson.get_compiler('cs').get_id().contains('dotnet')
8
9if (cs_is_dotnet)
10
11warning('Dotnet support is still not upstream in meson.')
12
13runtime_assemblies += [
14 '-r:System.Console.dll',
15 '-r:Microsoft.CSharp.dll',
16 '-r:System.Collections.dll',
17 '-r:System.Collections.Concurrent.dll',
18 '-r:System.ComponentModel.Primitives.dll',
19 '-r:System.ComponentModel.Primitives.dll',
20 '-r:System.Diagnostics.Debug.dll',
21 '-r:System.Diagnostics.TraceSource.dll',
22 '-r:System.Dynamic.Runtime.dll',
23 '-r:System.Linq.dll',
24 '-r:System.Runtime.dll',
25 '-r:System.Runtime.Extensions.dll',
26 '-r:System.Security.dll',
27]
28
29endif
30
31mono_sublibs = [ 9mono_sublibs = [
32 ['Eina', true, ], # 10 ['Eina', true, ], #
33 ['Eolian', true, ], # 11 ['Eolian', true, ], #
@@ -158,16 +136,81 @@ endif
158efl_mono_install_dir = join_paths(dir_lib, 'efl-mono-'+version_major) 136efl_mono_install_dir = join_paths(dir_lib, 'efl-mono-'+version_major)
159efl_mono_xml_doc = join_paths(meson.current_build_dir(), 'efl_mono.xml') 137efl_mono_xml_doc = join_paths(meson.current_build_dir(), 'efl_mono.xml')
160 138
161efl_mono = library('efl_mono', 139if (get_option('dotnet'))
162 mono_generator_target + mono_files + [efl_src], 140 dotnet = find_program('dotnet')
163 install : true, 141 warning('Dotnet support is still experimental.')
164 install_dir : efl_mono_install_dir, 142
165 cs_args : extra_cs_args + ['-doc:' + efl_mono_xml_doc, '-warnaserror+'] 143 lib_csproj_conf_data = configuration_data()
166) 144
145 dotnet_version = run_command(dotnet, ['--version'], check: true)
146 message('Found dotnet core version ' + dotnet_version.stdout().strip())
147
148 # The major version should be enough for now while we don't have to deal
149 # with minor differences and dotnet core is far from version 10
150 dotnet_major_version = dotnet_version.stdout().strip()[0].to_int()
151 if dotnet_major_version == 3
152 dotnet_core_app_version = '3.0'
153 dotnet_standard_version = '2.1'
154 elif dotnet_major_version == 2
155 dotnet_core_app_version = '2.0'
156 dotnet_standard_version = '2.0'
157 else
158 error('Unsupported dotnet version. Must be at least 2.2')
159 endif
160
161 lib_csproj_conf_data.set('NETSTANDARD_VERSION', dotnet_standard_version)
162 lib_csproj_conf_data.set('BINDING_SRC', meson.current_source_dir())
163 lib_csproj_conf_data.set('EFL_VERSION', meson.project_version())
167 164
168meson.add_install_script(join_paths(meson.source_root(), 'meson', 'meson_csharp_docs.sh'), 165 if get_option('mono-beta')
169 efl_mono_xml_doc, 166 lib_csproj_conf_data.set('EFL_BETA', 'EFL_BETA')
170 efl_mono_install_dir) 167 else
168 lib_csproj_conf_data.set('EFL_BETA', '')
169 endif
170
171 lib_csproj = configure_file(input: 'efl_sharp.csproj.in',
172 output: 'efl_sharp.csproj',
173 configuration: lib_csproj_conf_data)
174
175 efl_mono = custom_target('efl_mono',
176 input: mono_generator_target + mono_files + [efl_src] + [lib_csproj],
177 output: 'efl_sharp.dll',
178 build_by_default: true,
179 command: [dotnet,
180 'build',
181 '-o', meson.current_build_dir(),
182 '-p:BuildingLib=Yes',
183 lib_csproj],
184 install: true,
185 install_dir: efl_mono_install_dir,
186 )
187
188 efl_mono_pack = custom_target('efl_mono_nuget',
189 input: lib_csproj,
190 output: 'Efl.Csharp.' + meson.project_version() + '.nupkg',
191 depends: [efl_mono],
192 command: [dotnet,
193 'pack',
194 '-o', meson.current_build_dir(),
195 '-p:BuildingLib=No',
196 lib_csproj],
197 install: true,
198 install_dir: efl_mono_install_dir,
199 )
200
201else
202
203 efl_mono = library('efl_mono',
204 mono_generator_target + mono_files + [efl_src],
205 install : true,
206 install_dir : efl_mono_install_dir,
207 cs_args : extra_cs_args + ['-doc:' + efl_mono_xml_doc, '-warnaserror+']
208 )
209
210 meson.add_install_script(join_paths(meson.source_root(), 'meson', 'meson_csharp_docs.sh'),
211 efl_mono_xml_doc,
212 efl_mono_install_dir)
213endif
171 214
172efl_mono_test_suite_path=join_paths(meson.current_build_dir()) 215efl_mono_test_suite_path=join_paths(meson.current_build_dir())
173 216
diff --git a/src/tests/efl_mono/efl_sharp_test_suite.csproj.in b/src/tests/efl_mono/efl_sharp_test_suite.csproj.in
new file mode 100644
index 0000000..c236363
--- /dev/null
+++ b/src/tests/efl_mono/efl_sharp_test_suite.csproj.in
@@ -0,0 +1,36 @@
1<Project Sdk="Microsoft.NET.Sdk">
2
3 <PropertyGroup>
4 <OutputType>Exe</OutputType>
5 <TargetFramework>netcoreapp@NETCOREAPP_VERSION@</TargetFramework>
6 </PropertyGroup>
7
8 <PropertyGroup>
9 <PackageId>Efl.Csharp.Test.Suite</PackageId>
10 <Version>@EFL_VERSION@</Version>
11 <Authors>EFL Team</Authors>
12 <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
13 </PropertyGroup>
14
15 <PropertyGroup>
16 <DefineConstants>@EFL_BETA@</DefineConstants>
17 </PropertyGroup>
18
19 <ItemGroup>
20 <ProjectReference Include="../../bindings/mono/efl_sharp.csproj" />
21 </ItemGroup>
22
23 <ItemGroup>
24 <Compile Include="@BINDING_TEST_SRC@/*.cs" />
25 <!-- Somehow dotnet build -o DIR seems to miss the genenerated files despite
26 them being in the same folder as the csproj file. The line below makes
27 sure we include them.
28
29 The side effect is that invoking directly `dotnet build` will raise "source file FOO
30 already included" warnings.
31 -->
32 <Compile Include="./*.cs" />
33 </ItemGroup>
34
35</Project>
36
diff --git a/src/tests/efl_mono/meson.build b/src/tests/efl_mono/meson.build
index d7cd6bb..9b58563 100644
--- a/src/tests/efl_mono/meson.build
+++ b/src/tests/efl_mono/meson.build
@@ -1,3 +1,4 @@
1# Generation of .eo.cs files and test library common to dotnet and mono
1eo_files = [ 2eo_files = [
2 'dummy_child.eo', 3 'dummy_child.eo',
3 'dummy_numberwrapper.eo', 4 'dummy_numberwrapper.eo',
@@ -56,68 +57,88 @@ foreach mono_gen_file : eo_files
56 '@INPUT@']) 57 '@INPUT@'])
57endforeach 58endforeach
58 59
59efl_mono_test = library('efl_mono_test', 60if get_option('dotnet')
60 eo_file_targets, 61
61 link_with : [efl_mono], 62 dotnet_test_conf_data = configuration_data()
63
64 dotnet_test_conf_data.set('EFL_VERSION', meson.project_version())
65 dotnet_test_conf_data.set('BINDING_BUILD', join_paths(meson.current_build_dir(),
66 '..', '..', 'bindings', 'mono'))
67 dotnet_test_conf_data.set('BINDING_TEST_SRC', meson.current_source_dir())
68
69 dotnet_test_conf_data.set('NETCOREAPP_VERSION', dotnet_core_app_version)
70
71 if get_option('mono-beta')
72 dotnet_test_conf_data.set('EFL_BETA', 'EFL_BETA')
73 else
74 dotnet_test_conf_data.set('EFL_BETA', '')
75 endif
76
77 dotnet_test_csproj = configure_file(input: 'efl_sharp_test_suite.csproj.in',
78 output: 'efl_sharp_test_suite.csproj',
79 configuration: dotnet_test_conf_data,
80 )
81
82 efl_mono_suite = custom_target('efl_mono_test',
83 input: eo_file_targets + [dotnet_test_csproj],
84 output: 'efl_sharp_test_suite.dll',
85 depends: [efl_mono],
86 build_by_default: true,
87 command: [dotnet,
88 'build',
89 '-o',
90 meson.current_build_dir(),
91 '--framework',
92 'netcoreapp' + dotnet_core_app_version,
93 dotnet_test_csproj],
94 )
95
96else
97 efl_mono_test = library('efl_mono_test',
98 eo_file_targets,
99 link_with : [efl_mono],
100 cs_args : extra_cs_args
101 )
102
103 efl_mono_src = [
104 'Main.cs',
105 'TestUtils.cs',
106 'EinaTestData.cs',
107 'StructHelpers.cs',
108 'BasicDirection.cs',
109 'Eina.cs',
110 'Eldbus.cs',
111 'Eo.cs',
112 'EoPromises.cs',
113 'EoConstruction.cs',
114 'Errors.cs',
115 'Events.cs',
116 'FunctionPointers.cs',
117 'FunctionPointerMarshalling.cs',
118 'Model.cs',
119 'Parts.cs',
120 'Promises.cs',
121 'Strbuf.cs',
122 'Strings.cs',
123 'Structs.cs',
124 'Value.cs',
125 'ValueEolian.cs',
126 'Inheritance.cs',
127 'Hash.cs'
128 ]
129
130 efl_mono_suite = executable('efl-mono-suite',
131 efl_mono_src,
132 link_with : [efl_mono, efl_mono_test],
62 cs_args : extra_cs_args 133 cs_args : extra_cs_args
63) 134 )
64 135endif
65efl_mono_src = [
66 'Main.cs',
67 'TestUtils.cs',
68 'EinaTestData.cs',
69 'StructHelpers.cs',
70 'BasicDirection.cs',
71 'Eina.cs',
72 'Eldbus.cs',
73 'Eo.cs',
74 'EoPromises.cs',
75 'EoConstruction.cs',
76 'Errors.cs',
77 'Events.cs',
78 'FunctionPointers.cs',
79 'FunctionPointerMarshalling.cs',
80 'Model.cs',
81 'Parts.cs',
82 'Promises.cs',
83 'Strbuf.cs',
84 'Strings.cs',
85 'Structs.cs',
86 'Value.cs',
87 'ValueEolian.cs',
88 'Inheritance.cs',
89 'Hash.cs'
90]
91
92efl_mono_suite = executable('efl-mono-suite',
93 efl_mono_src,
94 link_with : [efl_mono, efl_mono_test],
95 cs_args : extra_cs_args
96)
97 136
137# Common environment shared by both dotnet and mono
98env_mono = environment() 138env_mono = environment()
99env_mono.set('MONO_PATH', efl_mono_test_suite_path ) 139env_mono.set('MONO_PATH', efl_mono_test_suite_path )
100env_mono.set('EFL_RUN_IN_TREE', '1') 140env_mono.set('EFL_RUN_IN_TREE', '1')
101 141
102if (cs_is_dotnet)
103copy_prog = find_program(['cp', 'copy'])
104
105configure_file(input : 'efl-mono-suite.runtimeconfig.json',
106 output : 'efl-mono-suite.runtimeconfig.json',
107 copy : true)
108
109custom_target('copy_efl_mono_dll',
110 build_by_default : true,
111 input : efl_mono,
112 output : efl_mono.full_path().split('/')[-1],
113 command : [copy_prog, '@INPUT@', '@OUTPUT@'])
114
115custom_target('copy_efl_mono_lib_dll',
116 build_by_default : true,
117 input : efl_mono_lib,
118 output : efl_mono_lib.full_path().split('/')[-1],
119 command : [copy_prog, '@INPUT@', '@OUTPUT@'])
120endif
121 142
122config_libs = ['eina', 'ecore', 'eo', 'efl', 'evas', 'eldbus', 'elementary', 'efl_mono'] 143config_libs = ['eina', 'ecore', 'eo', 'efl', 'evas', 'eldbus', 'elementary', 'efl_mono']
123load_lib = efl_mono_test_suite_path + ':' 144load_lib = efl_mono_test_suite_path + ':'
@@ -136,9 +157,20 @@ foreach config : config_libs
136 load_lib += repaired_path+':' 157 load_lib += repaired_path+':'
137endforeach 158endforeach
138 159
160load_lib += ':' + meson.current_build_dir()
161
139env_mono.set('LD_LIBRARY_PATH', load_lib) 162env_mono.set('LD_LIBRARY_PATH', load_lib)
140 163
141test('efl-mono-suite', 164
142 efl_mono_suite, 165if get_option('dotnet')
143 env : env_mono 166 test('efl-mono-suite',
144) 167 dotnet,
168 args: [join_paths(meson.current_build_dir(), 'efl_sharp_test_suite.dll')],
169 env: env_mono,
170 )
171else
172 test('efl-mono-suite',
173 efl_mono_suite,
174 env : env_mono
175 )
176endif