Skip to content

Commit

Permalink
merging changes from edge-js
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed May 8, 2024
1 parent 1221e53 commit 1b89223
Show file tree
Hide file tree
Showing 11 changed files with 3,469 additions and 85 deletions.
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ adhoc/

package/
tools/build

/src/double/Edge.js/obj/
/src/double/Edge.js/bin/
/src/double/Edge.js.CSharp/obj/
/src/double/Edge.js.CSharp/bin/
/src/double/Edge.js/*.sln
/src/double/Edge.js.CSharp/*.sln
/src/Debug/

/test/obj/
/test/bin/
/test/Properties/
/test/test.nuget.cache

package-lock.json

tools/nuget/content
tools/nuget/lib
tools/nuget/*.nupkg
Expand All @@ -83,3 +83,8 @@ TemporaryGeneratedFile*.*
/lib/native/win32/x64/*/msvcp140.dll
/lib/native/win32/x64/*/vccorlib140.dll
/lib/native/win32/x64/*/vcruntime140.dll

test/mochawesome-report
mochawesome-report
mochawesome.json

2 changes: 0 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ tools/build
/test/Properties/
/test/test.nuget.cache

package-lock.json

tools/nuget/content
tools/nuget/lib
tools/nuget/*.zip
Expand Down
27 changes: 1 addition & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This is a fork of [edge-js](https://github.com/agracio/edge-js) adapted to suppo
| Electron 29.x | v20.9.0 |
| Electron 30.x | v20.11.1 |

- You do not need to use same version of Node.js in your project as Electron Node.js version
- You do not need to use the same version of Node.js in your project as Electron Node.js version
- On Linux and MacOS `npm install` will compile binaries with correct Node.Js headers for a given Electron version.

#### Usage is the same as edge-js, replace `require('edge-js')` with `require('electron-edge-js')`:
Expand All @@ -38,14 +38,6 @@ var helloWorld = edge.func(function () {/*
}
*/});
```
## Migration to .NET 6 :exclamation:

Edge.Js C# code has been migrated to .NET 6.
If your project is referencing `EdgeJs.dll` file locations have changed.

```bash
node_modules/electron-edge-js/lib/bootstrap/bin/Release/net6.0/EdgeJs.dll
```

## Requirements (Windows)

Expand All @@ -62,19 +54,6 @@ Electron is built using specific version of Node.js. In order to use `edge-js` i
Sample app that shows how to work with .NET Core using inline code and compiled C# libraries.
https://github.com/agracio/electron-edge-js-quick-start

## MacOS

`edge-js` and `electron-edge-js` will fail to build on MacOS if Visual Studio for Mac is installed.
VS installs incomplete Mono runtimes that `edge-js` fails to access during `nmp install`.
Removing VS does not remove Mono fully and leaves behind an incomplete Mono install.
To remove Mono from macOS use this script

```bash
sudo rm -rf /Library/Frameworks/Mono.framework
sudo pkgutil --forget com.xamarin.mono-MDK.pkg
sudo rm /etc/paths.d/mono-commands
```

## Packaging Electron application

`electron-edge-js` needs to be specified as an external module, some examples<br/>
Expand Down Expand Up @@ -156,10 +135,6 @@ powerpoint.open(path.join(${remotePath}${process.env.file}.pptx), function(err)
});
```
## Build
build.bat supports only Electron major versions.
Expand Down
76 changes: 32 additions & 44 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -206,50 +206,38 @@
[
'"<!((which mono 2>/dev/null) || echo not_found)"!="not_found"',
{
'sources+': [
'src/mono/clractioncontext.cpp',
'src/mono/clrfunc.cpp',
'src/mono/clrfuncinvokecontext.cpp',
'src/mono/monoembedding.cpp',
'src/mono/task.cpp',
'src/mono/dictionary.cpp',
'src/mono/nodejsfunc.cpp',
'src/mono/nodejsfuncinvokecontext.cpp',
'src/mono/utils.cpp',
'src/common/utils.cpp',
'src/common/v8synchronizationcontext.cpp',
'src/common/callbackhelper.cpp',
'src/common/edge.cpp'
],
'conditions':
[
[
'"<!((pkg-config mono-2 --libs 2>/dev/null) || echo not_found)"!="not_found"',
{
'include_dirs': [
'<!@(pkg-config mono-2 --cflags-only-I | sed s/-I//g)',
'<!@(pkg-config glib-2.0 --cflags-only-I | sed s/-I//g)',
],
'link_settings': {
'libraries': [
'<!@(pkg-config mono-2 --libs)'
]
}
},
'"<!((pkg-config mono-2 --libs 2>/dev/null) || echo not_found)"=="not_found"',
{
'include_dirs': [
'<!@(<(DFLT_PKG_CONFIG_PATH) pkg-config mono-2 --cflags-only-I | sed s/-I//g)',
'<!@(pkg-config glib-2.0 --cflags-only-I | sed s/-I//g)',
],
'link_settings': {
'libraries': [
'<!@(<(DFLT_PKG_CONFIG_PATH) pkg-config mono-2 --libs)'
]
}
}
]
],
'conditions': [
[
'"<!((pkg-config mono-2 --libs 2>/dev/null) || echo not_found)"!="not_found"',
{
'sources+': [
'src/mono/clractioncontext.cpp',
'src/mono/clrfunc.cpp',
'src/mono/clrfuncinvokecontext.cpp',
'src/mono/monoembedding.cpp',
'src/mono/task.cpp',
'src/mono/dictionary.cpp',
'src/mono/nodejsfunc.cpp',
'src/mono/nodejsfuncinvokecontext.cpp',
'src/mono/utils.cpp',
'src/common/utils.cpp',
'src/common/v8synchronizationcontext.cpp',
'src/common/callbackhelper.cpp',
'src/common/edge.cpp'
],

'include_dirs': [
'<!@(pkg-config mono-2 --cflags-only-I | sed s/-I//g)',
'<!@(pkg-config glib-2.0 --cflags-only-I | sed s/-I//g)',
],
'link_settings': {
'libraries': [
'<!@(pkg-config mono-2 --libs)'
]
}
}
]
],
},
{
'type': 'none'
Expand Down
1 change: 1 addition & 0 deletions lib/bootstrap/bootstrap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<AssemblyName>bootstrap</AssemblyName>
<PackageId>bootstrap</PackageId>
<LangVersion>default</LangVersion>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<ItemGroup >
Expand Down
8 changes: 4 additions & 4 deletions lib/edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ if (edgeNative.match(/edge_coreclr\.node$/i)) {
// how to compile literal C# at https://github.com/agracio/edge-js-cs/blob/master/lib/edge-cs.js
process.env.EDGE_USE_CORECLR = 1;
}
if (process.env.EDGE_USE_CORECLR && !process.env.EDGE_BOOTSTRAP_DIR && fs.existsSync(path.join(__dirname, 'bootstrap', 'bin', 'Release', 'net6.0', 'bootstrap.dll'))) {
process.env.EDGE_BOOTSTRAP_DIR = path.join(__dirname, 'bootstrap', 'bin', 'Release', 'net6.0');
if (process.env.EDGE_USE_CORECLR && !process.env.EDGE_BOOTSTRAP_DIR && fs.existsSync(path.join(__dirname, 'bootstrap', 'bin', 'Release', 'bootstrap.dll'))) {
process.env.EDGE_BOOTSTRAP_DIR = path.join(__dirname, 'bootstrap', 'bin', 'Release');
}

process.env.EDGE_NATIVE = edgeNative;
Expand Down Expand Up @@ -113,7 +113,7 @@ exports.func = function (language, options) {
}

if (process.env.EDGE_USE_CORECLR) {
var defaultManifest = path.join(__dirname, 'bootstrap', 'bin', 'Release', 'net6.0', 'bootstrap.deps.json');
var defaultManifest = path.join(__dirname, 'bootstrap', 'bin', 'Release', 'bootstrap.deps.json');
var compilerManifest;
if (compiler.getBootstrapDependencyManifest) {
compilerManifest = compiler.getBootstrapDependencyManifest();
Expand All @@ -126,7 +126,7 @@ exports.func = function (language, options) {
}

if (!options.assemblyFile && !options.source) {
throw new Error('Provide DLL or source file name or .NET script literal as a string parmeter, or specify an options object ' +
throw new Error('Provide DLL or source file name or .NET script literal as a string parameter, or specify an options object '+
'with assemblyFile or source string property.');
}
else if (options.assemblyFile && options.source) {
Expand Down
Loading

0 comments on commit 1b89223

Please sign in to comment.