2019-10-24 06:01:50 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2019 by its authors. See AUTHORS.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2019-01-15 23:29:56 -08:00
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
2019-10-24 08:18:44 -07:00
|
|
|
namespace Efl.Eo
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
2019-01-15 23:29:56 -08:00
|
|
|
|
2019-10-28 15:06:38 -07:00
|
|
|
internal partial class NativeModule
|
2019-01-15 23:29:56 -08:00
|
|
|
{
|
2019-03-20 03:26:49 -07:00
|
|
|
private const int RTLD_NOW = 0x002;
|
2019-01-15 23:29:56 -08:00
|
|
|
// Currently we are using GLOBAL due to issues
|
|
|
|
// with the way evas modules are built.
|
2019-03-20 03:26:49 -07:00
|
|
|
private const int RTLD_GLOBAL = 0x100;
|
2019-01-15 23:29:56 -08:00
|
|
|
|
|
|
|
[DllImport(efl.Libs.Libdl)]
|
2019-03-20 03:26:49 -07:00
|
|
|
private static extern IntPtr dlopen(string fileName, int flag);
|
2019-01-15 23:29:56 -08:00
|
|
|
[DllImport(efl.Libs.Libdl)]
|
2019-03-20 03:26:49 -07:00
|
|
|
private static extern int dlclose(IntPtr handle);
|
2019-01-15 23:29:56 -08:00
|
|
|
|
2019-03-20 03:26:49 -07:00
|
|
|
///<summary>Closes the library handle.</summary>
|
|
|
|
///<param name="handle">The handle to the library.</param>
|
2019-10-28 15:06:38 -07:00
|
|
|
internal static void UnloadLibrary(IntPtr handle)
|
2019-01-15 23:29:56 -08:00
|
|
|
{
|
|
|
|
dlclose(handle);
|
|
|
|
}
|
|
|
|
|
2019-03-20 03:26:49 -07:00
|
|
|
///<summary>Loads the given library.
|
|
|
|
///
|
|
|
|
///It attempts to load using the following list of names based on the <c>filename</c>
|
|
|
|
///parameter:
|
|
|
|
///
|
|
|
|
///<list type="bullet">
|
|
|
|
///<item>
|
|
|
|
///<description><c>filename</c></description>
|
|
|
|
///</item>
|
|
|
|
///<item>
|
|
|
|
///<description><c>libfilename</c></description>
|
|
|
|
///</item>
|
|
|
|
///<item>
|
|
|
|
///<description><c>filename.so</c></description>
|
|
|
|
///</item>
|
|
|
|
///<item>
|
|
|
|
///<description><c>libfilename.so</c></description>
|
|
|
|
///</item>
|
efl-mono: Correctly load dynamic libs for OSX
Summary:
OSX libs end with `.dylib`, so it made failed to load libs, for instance
dl name is `dl.dylib` making it unable to load as it was before
(`libdl.so`).
Test Plan:
Compare with master and note that this diff is able to fail on tests, and
not about importing libs.
- Configure as especified by Enlightenment man page + `-Dbindigns=mono -Ddotnet=true`:
```
meson -Dsystemd=false -Dv4l2=false -Davahi=false -Deeze=false -Dx11=false -Dopengl=full -Dcocoa=true -Dnls=false -Demotion-loaders-disabler=gstreamer1,libvlc,xine -Decore-imf-loaders-disabler=scim,ibus -Dbindigns=cxx,mono -Ddotnet=true --prefix=$PWD/prefix build
```
- Build normally
- Test `efl-mono-suite`
Reviewers: felipealmeida
Reviewed By: felipealmeida
Subscribers: stefan_schmidt, cedric, #reviewers, #committers, woohyun
Tags: #efl, #expertise_solutions
Differential Revision: https://phab.enlightenment.org/D12156
2020-11-25 05:40:17 -08:00
|
|
|
///<item>
|
|
|
|
///<description><c>filename.dylib</c></description>
|
|
|
|
///</item>
|
|
|
|
///<item>
|
|
|
|
///<description><c>libfilename.dylib</c></description>
|
|
|
|
///</item>
|
2019-03-20 03:26:49 -07:00
|
|
|
///</list>
|
|
|
|
///</summary>
|
|
|
|
///<param name="filename">The name to search for.</param>
|
|
|
|
///<returns>The loaded library handle or <see cref="System.IntPtr.Zero"/> on failure.</returns>
|
2019-10-28 15:06:38 -07:00
|
|
|
internal static IntPtr LoadLibrary(string filename)
|
2019-01-15 23:29:56 -08:00
|
|
|
{
|
|
|
|
Eina.Log.Debug($"Loading library {filename}");
|
|
|
|
var r = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
|
|
|
|
if (r == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
r = dlopen("lib" + filename, RTLD_NOW | RTLD_GLOBAL);
|
|
|
|
if (r == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
r = dlopen(filename + ".so", RTLD_NOW | RTLD_GLOBAL);
|
|
|
|
if (r == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
r = dlopen("lib" + filename + ".so", RTLD_NOW | RTLD_GLOBAL);
|
efl-mono: Correctly load dynamic libs for OSX
Summary:
OSX libs end with `.dylib`, so it made failed to load libs, for instance
dl name is `dl.dylib` making it unable to load as it was before
(`libdl.so`).
Test Plan:
Compare with master and note that this diff is able to fail on tests, and
not about importing libs.
- Configure as especified by Enlightenment man page + `-Dbindigns=mono -Ddotnet=true`:
```
meson -Dsystemd=false -Dv4l2=false -Davahi=false -Deeze=false -Dx11=false -Dopengl=full -Dcocoa=true -Dnls=false -Demotion-loaders-disabler=gstreamer1,libvlc,xine -Decore-imf-loaders-disabler=scim,ibus -Dbindigns=cxx,mono -Ddotnet=true --prefix=$PWD/prefix build
```
- Build normally
- Test `efl-mono-suite`
Reviewers: felipealmeida
Reviewed By: felipealmeida
Subscribers: stefan_schmidt, cedric, #reviewers, #committers, woohyun
Tags: #efl, #expertise_solutions
Differential Revision: https://phab.enlightenment.org/D12156
2020-11-25 05:40:17 -08:00
|
|
|
if (r == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
r = dlopen(filename + ".dylib", RTLD_NOW | RTLD_GLOBAL);
|
|
|
|
if (r == IntPtr.Zero)
|
|
|
|
{
|
|
|
|
r = dlopen("lib" + filename + ".dylib", RTLD_NOW | RTLD_GLOBAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-01-15 23:29:56 -08:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
}
|