Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee5cc6e589 | ||
|
|
6ad1a5079e | ||
|
|
d66fb5cf16 | ||
|
|
28e4f64ae8 | ||
|
|
8fb3d4fa9b | ||
|
|
fa6110530f | ||
|
|
7eabea0f1a | ||
|
|
82635217c5 | ||
|
|
0ff24f8744 | ||
|
|
dd13c4b6cc | ||
|
|
639ed9be89 | ||
|
|
ff581e8b44 | ||
|
|
1a8de46fb7 | ||
|
|
ad699b35c0 | ||
|
|
31bc7170f6 | ||
|
|
9cc5d4f9ee | ||
|
|
731c53d97f | ||
|
|
6669833e3d | ||
|
|
ca8d10fddb |
32
.github/workflows/ci.yml
vendored
32
.github/workflows/ci.yml
vendored
@@ -13,15 +13,19 @@ jobs:
|
||||
name: ${{ matrix.friendlyName }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 10
|
||||
env:
|
||||
# Needed until macos-11.0 hosted runners are available
|
||||
SDKROOT: '/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk'
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node: [12.14.1]
|
||||
os: [macos-10.14, windows-2019, ubuntu-18.04]
|
||||
os: [macos-10.14, windows-latest, ubuntu-18.04]
|
||||
include:
|
||||
- os: macos-10.14
|
||||
friendlyName: macOS
|
||||
- os: windows-2019
|
||||
- os: windows-latest
|
||||
friendlyName: Windows
|
||||
- os: ubuntu-18.04
|
||||
friendlyName: Linux
|
||||
@@ -33,6 +37,16 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
|
||||
# This step can be removed as soon as official Windows arm64 builds are published:
|
||||
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342
|
||||
- run: |
|
||||
$NodeVersion = (node --version) -replace '^.'
|
||||
$NodeFallbackVersion = "15.8.0"
|
||||
& .\script\download-node-lib-win-arm64.ps1 $NodeVersion $NodeFallbackVersion
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
name: Install Windows arm64 node.lib
|
||||
|
||||
- name: Install and build
|
||||
run: yarn
|
||||
- name: Lint
|
||||
@@ -40,12 +54,14 @@ jobs:
|
||||
- name: Test
|
||||
run: yarn test
|
||||
shell: bash
|
||||
- name: Prebuild Node x64
|
||||
run: yarn prebuild-node
|
||||
- name: Prebuild Electron x64
|
||||
run: yarn prebuild-electron
|
||||
- name: Prebuild Electron arm64
|
||||
run: yarn prebuild-electron-arm64
|
||||
- name: Prebuild (x64)
|
||||
run: npm run prebuild-napi-x64
|
||||
- name: Prebuild (arm64)
|
||||
run: npm run prebuild-napi-arm64
|
||||
if: ${{ matrix.os != 'ubuntu-18.04' }}
|
||||
- name: Prebuild (Windows x86)
|
||||
run: npm run prebuild-napi-ia32
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
- name: Publish
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
run: yarn upload
|
||||
|
||||
@@ -9,7 +9,7 @@ The intention is to support the same platforms that
|
||||
|
||||
## Building
|
||||
|
||||
This project is written as a Node project with the C-portions beign compiled by
|
||||
This project is written as a Node project with the C-portions being compiled by
|
||||
node-gyp. Installing dependencies and building requires Node.js, and yarn. With
|
||||
those prerequisites the initial setup should be as easy as running `yarn` and
|
||||
subsequent builds can be done using `yarn build`. There are some tests available
|
||||
|
||||
11
binding.gyp
11
binding.gyp
@@ -2,12 +2,16 @@
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'desktop-trampoline',
|
||||
'defines': [
|
||||
"NAPI_VERSION=<(napi_build_version)",
|
||||
],
|
||||
'type': 'executable',
|
||||
'sources': [
|
||||
'src/desktop-trampoline.c',
|
||||
'src/socket.c'
|
||||
],
|
||||
'include_dirs': [
|
||||
'<!(node -p "require(\'node-addon-api\').include_dir")',
|
||||
'include'
|
||||
],
|
||||
'xcode_settings': {
|
||||
@@ -27,12 +31,17 @@
|
||||
'-pie',
|
||||
'-D_FORTIFY_SOURCE=1',
|
||||
'-fstack-protector-strong',
|
||||
'-Werror=format-security'
|
||||
'-Werror=format-security',
|
||||
'-fno-exceptions'
|
||||
],
|
||||
'cflags_cc!': [ '-fno-exceptions' ],
|
||||
'ldflags!': [
|
||||
'-z relro',
|
||||
'-z now'
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': { 'ExceptionHandling': 1 },
|
||||
},
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'defines': [ 'WINDOWS' ],
|
||||
|
||||
25
docs/releases.md
Normal file
25
docs/releases.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Releases
|
||||
|
||||
All releases are published using GitHub releases. Anyone with push access to the
|
||||
repository can create a new release.
|
||||
|
||||
### Release Process
|
||||
|
||||
1. Create a branch named `releases/X.Y.Z`, where `X.Y.Z` is the version you want
|
||||
to release.
|
||||
1. Update the `version` field in the `package.json` with the new version you're
|
||||
about to release.
|
||||
1. Open a Pull Request for that branch.
|
||||
1. Once the branch is approved, `git tag vX.Y.Z` the version you wish to
|
||||
publish. **Important:** the version in the tag name must be preceeded by a
|
||||
`v`.
|
||||
1. `git push --follow-tags` to ensure all new commits (and the tag) are pushed
|
||||
to the remote. Pushing the tag will start the release process.
|
||||
1. Wait a few minutes for the build to finish (look for the build in
|
||||
https://github.com/desktop/desktop-trampoline/actions)
|
||||
1. Once the build is complete it will create a new release with all of the
|
||||
assets and suggested release notes.
|
||||
1. Update the changelog to whatever makes sense for this release. It should be
|
||||
focused on user-facing changes.
|
||||
1. Confirm all assets are uploaded for all the supported platforms.
|
||||
1. Merge the Pull Request into `main` and you're done :tada:
|
||||
22
package.json
22
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "desktop-trampoline",
|
||||
"version": "0.9.2",
|
||||
"version": "0.9.5",
|
||||
"main": "index.js",
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
@@ -15,10 +15,10 @@
|
||||
"test": "jest",
|
||||
"lint": "prettier -c **/*.js **/*.md",
|
||||
"lint:fix": "prettier --write **/*.js **/*.md",
|
||||
"prebuild-node": "prebuild -t 10.11.0 -t 11.9.0 -t 12.0.0 -t 14.8.0 --strip --include-regex \"desktop-trampoline(\\.exe)?$\"",
|
||||
"prebuild-electron": "prebuild -t 7.0.0 -t 8.0.0 -t 9.0.0 -t 10.0.0 -t 11.0.0 -r electron --strip --include-regex \"desktop-trampoline(\\.exe)?$\"",
|
||||
"prebuild-electron-arm64": "prebuild -t 7.0.0 -t 8.0.0 -t 9.0.0 -t 10.0.0 -t 11.0.0 -r electron -a arm64 --strip --include-regex \"desktop-trampoline(\\.exe)?$\"",
|
||||
"prebuild-all": "yarn prebuild-node && yarn prebuild-electron && yarn prebuild-electron-arm64",
|
||||
"prebuild-napi-x64": "prebuild -t 3 -r napi -a x64 --strip --include-regex \"desktop-trampoline(\\.exe)?$\"",
|
||||
"prebuild-napi-ia32": "prebuild -t 3 -r napi -a ia32 --strip --include-regex \"desktop-trampoline(\\.exe)?$\"",
|
||||
"prebuild-napi-arm64": "prebuild -t 3 -r napi -a arm64 --strip --include-regex \"desktop-trampoline(\\.exe)?$\"",
|
||||
"prebuild-all": "yarn prebuild-napi-x64 && yarn prebuild-napi-ia32 && yarn prebuild-napi-arm64",
|
||||
"upload": "node ./script/upload.js"
|
||||
},
|
||||
"repository": {
|
||||
@@ -29,11 +29,23 @@
|
||||
"url": "https://github.com/desktop/desktop-trampoline/issues"
|
||||
},
|
||||
"homepage": "https://github.com/desktop/desktop-trampoline#readme",
|
||||
"dependencies": {
|
||||
"node-addon-api": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"jest": "^26.4.2",
|
||||
"node-gyp": "^7.1.0",
|
||||
"prebuild": "^10.0.1",
|
||||
"prettier": "^2.1.2",
|
||||
"split2": "^3.2.2"
|
||||
},
|
||||
"binary": {
|
||||
"napi_versions": [
|
||||
3
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"runtime": "napi",
|
||||
"target": 3
|
||||
}
|
||||
}
|
||||
|
||||
36
script/download-node-lib-win-arm64.ps1
Normal file
36
script/download-node-lib-win-arm64.ps1
Normal file
@@ -0,0 +1,36 @@
|
||||
# This script can be removed as soon as official Windows arm64 builds are published:
|
||||
# https://github.com/nodejs/build/issues/2450#issuecomment-705853342
|
||||
|
||||
$nodeVersion = $args[0]
|
||||
$fallbackVersion = $args[1]
|
||||
|
||||
If ($null -eq $nodeVersion -Or $null -eq $fallbackVersion) {
|
||||
Write-Error "No NodeJS version given as argument to this file. Run it like download-nodejs-win-arm64.ps1 NODE_VERSION NODE_FALLBACK_VERSION"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$url = "https://unofficial-builds.nodejs.org/download/release/v$nodeVersion/win-arm64/node.lib"
|
||||
$fallbackUrl = "https://unofficial-builds.nodejs.org/download/release/v$fallbackVersion/win-arm64/node.lib"
|
||||
|
||||
# Always write to the $nodeVersion cache folder, even if we're using the fallbackVersion
|
||||
$cacheFolder = "$env:TEMP\prebuild\napi\$nodeVersion\arm64"
|
||||
|
||||
If (!(Test-Path $cacheFolder)) {
|
||||
New-Item -ItemType Directory -Force -Path $cacheFolder
|
||||
}
|
||||
|
||||
$output = "$cacheFolder\node.lib"
|
||||
$start_time = Get-Date
|
||||
|
||||
Try {
|
||||
Invoke-WebRequest -Uri $url -OutFile $output
|
||||
$downloadedNodeVersion = $nodeVersion
|
||||
} Catch {
|
||||
If ($_.Exception.Response -And $_.Exception.Response.StatusCode -eq "NotFound") {
|
||||
Write-Output "No arm64 node.lib found for Node Windows $nodeVersion, trying fallback version $fallbackVersion..."
|
||||
Invoke-WebRequest -Uri $fallbackUrl -OutFile $output
|
||||
$downloadedNodeVersion = $fallbackVersion
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output "Downloaded arm64 NodeJS lib v$downloadedNodeVersion to $output in $((Get-Date).Subtract($start_time).Seconds) second(s)"
|
||||
@@ -66,7 +66,9 @@ int runTrampolineClient(SOCKET *outSocket, int argc, char **argv, char **envp) {
|
||||
*outSocket = socket;
|
||||
|
||||
if (connectSocket(socket, desktopPort) != 0) {
|
||||
printSocketError("ERROR: Couldn't connect to 127.0.0.1:%d", desktopPort);
|
||||
printSocketError("ERROR: Couldn't connect to 127.0.0.1:%d - Please make "
|
||||
"sure you don't have an antivirus or firewall blocking "
|
||||
"this connection.", desktopPort);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -102,7 +104,7 @@ int runTrampolineClient(SOCKET *outSocket, int argc, char **argv, char **envp) {
|
||||
|
||||
// TODO: send stdin stuff?
|
||||
|
||||
char buffer[BUFFER_LENGTH];
|
||||
char buffer[BUFFER_LENGTH + 1];
|
||||
size_t totalBytesRead = 0;
|
||||
ssize_t bytesRead = 0;
|
||||
|
||||
|
||||
27
src/socket.c
27
src/socket.c
@@ -6,13 +6,30 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
||||
#define MAX_WSA_ERROR_DESCRIPTION_LENGTH 4096
|
||||
|
||||
void getWSALastErrorDescription(wchar_t *buffer, int bufferLength) {
|
||||
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, WSAGetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPWSTR)buffer, bufferLength - 1, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int initializeNetwork(void) {
|
||||
#ifdef WINDOWS
|
||||
// Initialize Winsock
|
||||
WSADATA wsaData;
|
||||
int result = WSAStartup(MAKEWORD(2,2), &wsaData);
|
||||
if (result != NO_ERROR) {
|
||||
fprintf(stderr, "ERROR: WSAStartup failed: %d\n", result);
|
||||
wchar_t errorDescription[MAX_WSA_ERROR_DESCRIPTION_LENGTH];
|
||||
getWSALastErrorDescription(errorDescription, MAX_WSA_ERROR_DESCRIPTION_LENGTH);
|
||||
|
||||
fprintf(stderr, "ERROR: WSAStartup failed (%d). Error %ld: %ls\n",
|
||||
result, WSAGetLastError(), errorDescription);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
@@ -55,8 +72,7 @@ int readSocket(SOCKET socket, void *buffer, size_t length) {
|
||||
return recv(socket, buffer, length, 0);
|
||||
}
|
||||
|
||||
void printSocketError(char *fmt, ...)
|
||||
{
|
||||
void printSocketError(char *fmt, ...) {
|
||||
char formatted_string[4096];
|
||||
|
||||
va_list argptr;
|
||||
@@ -65,7 +81,10 @@ void printSocketError(char *fmt, ...)
|
||||
va_end(argptr);
|
||||
|
||||
#ifdef WINDOWS
|
||||
fprintf(stderr, "%s: %ld\n", formatted_string, WSAGetLastError());
|
||||
wchar_t errorDescription[MAX_WSA_ERROR_DESCRIPTION_LENGTH];
|
||||
getWSALastErrorDescription(errorDescription, MAX_WSA_ERROR_DESCRIPTION_LENGTH);
|
||||
|
||||
fprintf(stderr, "%s (%ld): %ls\n", formatted_string, WSAGetLastError(), errorDescription);
|
||||
#else
|
||||
fprintf(stderr, "%s (%d): %s\n", formatted_string, errno, strerror(errno));
|
||||
#endif
|
||||
|
||||
@@ -3008,6 +3008,11 @@ node-abi@^2.2.0:
|
||||
dependencies:
|
||||
semver "^5.4.1"
|
||||
|
||||
node-addon-api@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.1.0.tgz#98b21931557466c6729e51cb77cd39c965f42239"
|
||||
integrity sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw==
|
||||
|
||||
node-gyp@^6.0.1:
|
||||
version "6.1.0"
|
||||
resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-6.1.0.tgz#64e31c61a4695ad304c1d5b82cf6b7c79cc79f3f"
|
||||
|
||||
Reference in New Issue
Block a user