Skip to content

Commit b285cdb

Browse files
committed
testing macOS build
1 parent b47f93c commit b285cdb

File tree

9 files changed

+141
-87
lines changed

9 files changed

+141
-87
lines changed

.github/actions/build/action.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ runs:
1818
- name: Build ${{ inputs.arch }}
1919
shell: pwsh
2020
run: |
21-
node-gyp configure --target=${{ inputs.node }} --runtime=node --release --arch=${{ inputs.arch }}
21+
22+
node-gyp configure --target=${{ inputs.node }} --runtime=node --release --arch=${{ inputs.arch }}
2223
2324
if ( '${{ inputs.arch }}' -eq 'arm64' -And '${{ runner.os }}' -eq 'Windows'){
2425
(Get-Content -Raw build/build_managed.vcxproj) -replace '<FloatingPointModel>Strict</FloatingPointModel>', '<!-- <FloatingPointModel>Strict</FloatingPointModel> -->' | Out-File -Encoding Utf8 build/build_managed.vcxproj
@@ -27,6 +28,7 @@ runs:
2728
}
2829
2930
node-gyp build
31+
3032
if ( '${{ runner.os }}' -eq 'Windows'){
3133
cmd /c copy /y build\Release\edge_*.node release\win32\${{ inputs.arch }}\${{ inputs.node-major }}
3234
cmd /c rmdir /S /Q build
@@ -37,5 +39,6 @@ runs:
3739
Copy-Item "build/Release/edge_coreclr.node" -Destination "release/darwin/${{ inputs.arch }}/${{ inputs.node-major }}"
3840
Copy-Item "build/Release/edge_nativeclr.node" -Destination "release/darwin/${{ inputs.arch }}/${{ inputs.node-major }}"
3941
Copy-Item "build/Release/MonoEmbedding.exe" -Destination "release/darwin/${{ inputs.arch }}/${{ inputs.node-major }}"
40-
node-gyp clean
42+
43+
node-gyp clean
4144
}

.github/actions/setup-env/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ runs:
6262
if: runner.os == 'Linux'
6363
shell: bash
6464
run: |
65-
sudo apt -qq install mono-complete pkg-config
65+
sudo apt -q install mono-complete pkg-config
6666
6767
- name: Versions
6868
shell: bash

.github/workflows/build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
strategy:
2929
matrix:
3030
# os: [windows-2022, macos-14]
31-
os: [macos-14]
31+
os: [windows-2022, macos-15]
3232
fail-fast: true
3333

3434
name: build node-${{ inputs.build-version }} ${{ matrix.os }}
@@ -48,8 +48,8 @@ jobs:
4848
needs: build
4949
strategy:
5050
matrix:
51-
os: [macos-13, macos-15]
52-
# os: [windows-2022, macos-13, macos-15]
51+
# os: [windows-2022]
52+
os: [windows-2022, macos-13, macos-15]
5353
fail-fast: false
5454

5555
name: test node-${{ inputs.build-version }} ${{ matrix.os }}

.github/workflows/main.yml

+3-9
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ jobs:
8383
strategy:
8484
fail-fast: false
8585
matrix:
86-
# os: [macos-13, macos-15, ubuntu-24.04, ubuntu-24.04-arm, windows-2022]
87-
os: [macos-13, macos-15, ubuntu-24.04, ubuntu-24.04-arm]
86+
os: [macos-13, macos-15, ubuntu-24.04, ubuntu-24.04-arm, windows-2022]
87+
# os: [macos-13, macos-15]
8888
# node: [18, 20, 22, 23]
89-
node: [20, 22]
89+
node: [18, 20, 22, 23]
9090
steps:
9191

9292
- name: Checkout code
@@ -98,18 +98,12 @@ jobs:
9898
node: ${{ matrix.node }}
9999
os: ${{ matrix.os }}
100100

101-
# - if: runner.os == 'macOS' && matrix.node == '16.x'
102-
# name: Add missing packages for macOS NodeJs 16
103-
# run: |
104-
# pip install setuptools
105-
106101
- name: Run .NET 4.5 tests
107102
if: matrix.os != 'macos-13'
108103
shell: bash
109104
run: node tools/test.js CI
110105

111106
- name: "Run .net core tests"
112-
# if: runner.os == 'macOS' || runner.os == 'Linux'
113107
run: node tools/test.js CI
114108
env:
115109
EDGE_USE_CORECLR: 1

README.md

+122-68
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,19 @@ Read more about the background and motivations of the project [here](http://toma
4343

4444
## Updates
4545
* Support for new versions of Node.Js.
46-
* Support for .NET Core 3.1 - 8.x on Windows/Linux/macOS.
46+
* Support for .NET Core 3.1 - 9.x on Windows/Linux/macOS.
4747
* Fixes AccessViolationException when running Node.js code from C# [PR #573](https://github.com/tjanczuk/edge/pull/573).
4848
* Fixes StackOverflowException [PR #566](https://github.com/tjanczuk/edge/pull/566) that occurs when underlying C# code throws complex exception.
4949
* Fixes issues [#469](https://github.com/tjanczuk/edge/issues/469), [#713](https://github.com/tjanczuk/edge/issues/713)
5050
* Other PRs: [PR #725](https://github.com/tjanczuk/edge/pull/725), [PR #640](https://github.com/tjanczuk/edge/pull/640)
5151
* Multiple bug fixes and improvements to the original code.
5252

5353
----
54+
5455
### NPM package [`edge-js`](https://www.npmjs.com/package/edge-js)
5556

5657
### NuGet package [`EdgeJs`](https://www.nuget.org/packages/EdgeJs)
58+
5759
----
5860

5961
## Electron
@@ -75,7 +77,7 @@ https://github.com/agracio/edge-js-quick-start
7577
### Windows
7678

7779
| Version | x86 | x64 | arm64 |
78-
| ------- | ------------------ | ------------------ | ------------------ |
80+
|---------|--------------------|--------------------|--------------------|
7981
| 16.x | :heavy_check_mark: | :heavy_check_mark: | :x: |
8082
| 18.x | :heavy_check_mark: | :heavy_check_mark: | :x: |
8183
| 20.x | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
@@ -85,48 +87,70 @@ https://github.com/agracio/edge-js-quick-start
8587

8688
### macOS
8789

88-
| Version | x64 | arm64 (M1+) |
89-
| -------------- | ------------------ | ------------------ |
90-
| 16.x - 23.x | :heavy_check_mark: | :heavy_check_mark: |
90+
| Version | x64 | arm64 (M1+) |
91+
|-------------|--------------------|--------------------|
92+
| 16.x - 23.x | :heavy_check_mark: | :heavy_check_mark: |
9193

9294
### Linux
9395

94-
| Version | x64 | arm64 |
95-
| -------------- | ------------------ | ------------------ |
96-
| 14.x - 23.x | :heavy_check_mark: | :heavy_check_mark: |
96+
| Version | x64 | arm64 |
97+
|-------------|--------------------|--------------------|
98+
| 14.x - 23.x | :heavy_check_mark: | :heavy_check_mark: |
9799

98100
## Scripting CLR from Node.js and Node.js from CRL
99101

100102
<table>
101103
<tr><th>Script CLR from Node.js </th><th>Script Node.js from CLR</th></tr>
102104
<tr><td>
103105

104-
| | .NET 4.5 | Mono 6.x | CoreCLR |
105-
| ------- | ------------------ | ------------------ | ------------------ |
106-
| Windows | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
107-
| Linux | :x: | :x: | :heavy_check_mark: |
108-
| macOS | :x: | :heavy_check_mark: | :heavy_check_mark: |
106+
| | .NET 4.5 | Mono 6.x | CoreCLR |
107+
|---------|--------------------|---------------------|--------------------|
108+
| Windows | :heavy_check_mark: | :heavy_check_mark:* | :heavy_check_mark: |
109+
| Linux | :x: | :heavy_check_mark:* | :heavy_check_mark: |
110+
| macOS | :x: | :heavy_check_mark:* | :heavy_check_mark: |
109111

110112
</td><td>
111113

112-
| | .NET 4.5 | Mono | CoreCLR |
113-
| ------- | ------------------ | ---------- | ------------- |
114-
| Windows | :heavy_check_mark: | :x: | :x: |
115-
| Linux | :x: | :x: | :x: |
116-
| macOS | :x: | :x: | :x: |
114+
| | .NET 4.5 | Mono | CoreCLR |
115+
|---------|--------------------|------|---------|
116+
| Windows | :heavy_check_mark: | :x: | :x: |
117+
| Linux | :x: | :x: | :x: |
118+
| macOS | :x: | :x: | :x: |
117119

118120
</td></tr> </table>
119121

120122
## Mono
121123

122-
Mono is no longer actively supported. Existing code will remain In Edge.Js but focus will be on .NET Core.
123-
Mono tests are excluded from CI.
124+
Mono is no longer actively supported. Existing code will remain In Edge.Js but focus will be on .NET Core.
125+
126+
`*` Edge.js does not have a flag to force it to run in Mono environment on Windows, it would only be possible to run if you have Windows without .NET Framework present.
127+
`*` Mono does not appear to work on macOS x64.
128+
`*` On Linux there is a known bug that will throw exception when executing C# code under certain conditions. Use one of the following options.
129+
130+
1. Set `LD_PRELOAD` env variable before running Edge.js with Mono
131+
```bash
132+
EXPORT LD_PRELOAD="libmono-2.0.so libmonosgen-2.0.so libstdc++.so.6"
133+
```
134+
135+
2. Set `LD_PRELOAD` in your Node.js app entry point using Javascript
136+
137+
```js
138+
Object.assign(process.env, {
139+
// Work around Mono problem: undefined symbol: mono_add_internal_call_with_flags
140+
LD_PRELOAD: 'libmono-2.0.so libmonosgen-2.0.so libstdc++.so.6',
141+
});
142+
```
143+
Source: https://github.com/mono/mono/issues/17079#issuecomment-1195918648
144+
145+
Edge.js uses this code in test setup: https://github.com/agracio/edge-js/blob/8bab03aca2abaea66e78c3af2f29e35ac2fcb8cf/tools/test.js#L19-L24
146+
124147

125148
## Node.js application packaging
126149

127150
When packaging your application using Webpack make sure that `edge-js` is specified as external module.
128151

129152
### Webpack
153+
130154
```js
131155
externals: {
132156
'edge-js': 'commonjs2 edge-js',
@@ -163,47 +187,57 @@ export default nextConfig;
163187

164188
**NOTE** This functionality requires IronPython 3.4
165189

166-
| Framework | Platform | NPM Package | Language code | Documentation |
167-
| ----------- | ------------ | ------------ |-------------- | ------------- |
168-
| .NET 4.5 | Windows | `edge-py` | `py` | [Script Python in Node.js](https://github.com/agracio/edge-py) :link: |
169-
| CoreCLR | Any | `edge-py` | `py` | [Script Python in Node.js](https://github.com/agracio/edge-py) :link: |
190+
| Framework | Platform | NPM Package | Language code | Documentation |
191+
|-----------|----------|-------------|---------------|-----------------------------------------------------------------------|
192+
| .NET 4.5 | Windows | `edge-py` | `py` | [Script Python in Node.js](https://github.com/agracio/edge-py) :link: |
193+
| CoreCLR | Any | `edge-py` | `py` | [Script Python in Node.js](https://github.com/agracio/edge-py) :link: |
170194

171195
### PowerShell scripting
172196

173197
**NOTE** CoreCLR requires dotnet 8
174198

175-
| Framework | Platform | NPM Package | Language code | Documentation |
176-
| ----------- | ------------ | ----------- |-------------- | ------------- |
177-
| .NET 4.5 | Windows | `edge-ps` | `ps` | [Script PowerShell in Node.js](https://github.com/agracio/edge-ps) :link: |
178-
| CoreCLR | Windows | `edge-ps` | `ps` | [Script PowerShell in Node.js](https://github.com/agracio/edge-ps) :link: |
199+
| Framework | Platform | NPM Package | Language code | Documentation |
200+
|-----------|----------|-------------|---------------|---------------------------------------------------------------------------|
201+
| .NET 4.5 | Windows | `edge-ps` | `ps` | [Script PowerShell in Node.js](https://github.com/agracio/edge-ps) :link: |
202+
| CoreCLR | Windows | `edge-ps` | `ps` | [Script PowerShell in Node.js](https://github.com/agracio/edge-ps) :link: |
179203

180204
### MS SQL scripting
181205

182206
Provides simple access to MS SQL without the need to write separate C# code.
183207

184-
| Framework | Platform | NPM Package | Language code | Documentation |
185-
| ------------- | ------------ | ----------- |-------------- | ------------- |
186-
| .NET 4.5 | Windows | `edge-sql` | `sql`| [Script T-SQL in Node.js](https://github.com/agracio/edge-sql) :link: |
187-
| CoreCLR | Any | `edge-sql` | `sql`| [Script T-SQL in Node.js](https://github.com/agracio/edge-sql) :link: |
208+
| Framework | Platform | NPM Package | Language code | Documentation |
209+
|-----------|----------|-------------|---------------|-----------------------------------------------------------------------|
210+
| .NET 4.5 | Windows | `edge-sql` | `sql` | [Script T-SQL in Node.js](https://github.com/agracio/edge-sql) :link: |
211+
| CoreCLR | Any | `edge-sql` | `sql` | [Script T-SQL in Node.js](https://github.com/agracio/edge-sql) :link: |
188212

189213
### F# scripting
190214

191-
| Framework | Platform | NPM Package | Language code | Documentation |
192-
| ----------- | ------------ | ----------- |-------------- | ------------- |
193-
| .NET 4.5 | Windows | `edge-fs` | `fs` | [Script F# in Node.js](https://github.com/agracio/edge-fs) :link: |
194-
| CoreCLR | Windows | `edge-fs` | `fs` | [Script F# in Node.js](https://github.com/agracio/edge-fs) :link: |
215+
| Framework | Platform | NPM Package | Language code | Documentation |
216+
|-----------|----------|-------------|---------------|-------------------------------------------------------------------|
217+
| .NET 4.5 | Windows | `edge-fs` | `fs` | [Script F# in Node.js](https://github.com/agracio/edge-fs) :link: |
218+
| CoreCLR | Windows | `edge-fs` | `fs` | [Script F# in Node.js](https://github.com/agracio/edge-fs) :link: |
195219

196220
---------
197221

198222
## How to use
199223

200-
#### [Scripting CLR from Node.js](#scripting-clr-from-nodejs) - full documentation
201-
#### [Scripting Node.js from CLR](#how-to-integrate-nodejs-code-into-clr-code) - full documentation
224+
### [Scripting CLR from Node.js](#scripting-clr-from-nodejs) - full documentation
225+
### [Scripting Node.js from CLR](#how-to-integrate-nodejs-code-into-clr-code) - full documentation
202226

203-
#### Scripting CLR from Node.js sample app https://github.com/agracio/edge-js-quick-start
227+
### Scripting CLR from Node.js sample app https://github.com/agracio/edge-js-quick-start
204228
----
205229

206-
### Scripting CLR from Node.js examples
230+
### Short guide
231+
232+
- [Inline C# code](#inline-c-code)
233+
- [Passing parameters](#passing-parameters)
234+
- [Using C# class](#using-c-class)
235+
- [Using compiled dll](#using-compiled-assembly)
236+
- [Using CoreCLR](#coreclr)
237+
- [Executing synchronously without function callback](#executing-synchronously-without-function-callback)
238+
- [Using promises/async](#promises)
239+
- [Scripting Node.js from CLR](#scripting-nodejs-from-clr)
240+
- [Docker](#docker)
207241

208242
### Inline C# code
209243

@@ -241,32 +275,6 @@ helloWorld('JavaScript', function (error, result) {
241275
});
242276
```
243277

244-
#### CoreCLR
245-
* If not set Edge.js will run as .NET 4.5 on Windows and as Mono on macOS/Linux
246-
* Can be set using `js` code below or as an environment variable `SET EDGE_USE_CORECLR=1`
247-
* Check [appveyor.yml](https://github.com/agracio/edge-js/blob/master/appveyor.yml) `test_script` for reference on setting env variables
248-
* Must be set before `var edge = require('edge-js');`
249-
250-
```js
251-
// set this variable before
252-
// var edge = require('edge-js');
253-
254-
process.env.EDGE_USE_CORECLR=1
255-
256-
var edge = require('edge-js');
257-
258-
var helloWorld = edge.func(function () {/*
259-
async (input) => {
260-
return ".NET Welcomes " + input.ToString();
261-
}
262-
*/});
263-
264-
helloWorld('JavaScript', function (error, result) {
265-
if (error) throw error;
266-
console.log(result);
267-
});
268-
```
269-
270278
### Passing parameters
271279

272280
```js
@@ -383,7 +391,7 @@ namespace EdgeJsMethods
383391
var edge = require('edge-js');
384392

385393
var getPerson = edge.func({
386-
assemblyFile: myDll, // path to .dll
394+
assemblyFile: myDll, // path to compiled .dll
387395
typeName: 'EdgeJsMethods.Methods',
388396
methodName: 'GetPerson'
389397
});
@@ -404,6 +412,31 @@ public async Task<object> MyMethod(object|dynamic input)
404412
}
405413
```
406414

415+
#### CoreCLR
416+
* If not set Edge.js will run as .NET 4.5 on Windows and as Mono on macOS/Linux
417+
* Can be set using `js` code below or as an environment variable `SET EDGE_USE_CORECLR=1` or `EXPORT EDGE_USE_CORECLR=1` depending on your platform.
418+
* Must be set before `var edge = require('edge-js');`
419+
420+
```js
421+
// set this variable before
422+
// var edge = require('edge-js');
423+
424+
process.env.EDGE_USE_CORECLR=1
425+
426+
var edge = require('edge-js');
427+
428+
var helloWorld = edge.func(function () {/*
429+
async (input) => {
430+
return ".NET Welcomes " + input.ToString();
431+
}
432+
*/});
433+
434+
helloWorld('JavaScript', function (error, result) {
435+
if (error) throw error;
436+
console.log(result);
437+
});
438+
```
439+
407440
### Executing synchronously without function callback
408441

409442
If your C# implementation will complete synchronously you can call this function as any synchronous JavaScript function as follows:
@@ -433,10 +466,31 @@ var helloWorld = edge.func(function () {/*
433466

434467
// sync call will throw exception
435468
var result = helloWorld('JavaScript', true);
469+
```
470+
471+
### Promises
472+
473+
```js
474+
475+
var func = edge.func(function () {/*
476+
async (dynamic input) => {
477+
return "Welcome " + input.name + " " + input.surname;
478+
}
479+
*/});
480+
481+
function helloWorld(){
482+
return new Promise<T>((resolve, reject) =>{
483+
func({name: 'John', surname: 'Smith'}, function (error, result) {
484+
if(error) reject(error);
485+
else resolve(result);
486+
});
487+
});
488+
}
489+
436490
```
437491
----
438492

439-
### Scripting Node.js from CLR example
493+
### Scripting Node.js from CLR
440494

441495
```cs
442496
using System;

0 commit comments

Comments
 (0)