Skip to content

Commit

Permalink
v2.1.3
Browse files Browse the repository at this point in the history
Added support for armv7 which also fixes #4.
  • Loading branch information
paulober committed Nov 9, 2022
1 parent d9903e8 commit 4b10f40
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Package
run: npx vsce package --no-yarn --dependencies

- run: npx vsce publish --no-yarn --dependencies --target win32-x64 linux-x64 linux-arm64 darwin-x64 darwin-arm64
- run: npx vsce publish --no-yarn --dependencies --target win32-x64 linux-x64 linux-arm64 linux-armhf darwin-x64 darwin-arm64
name: Publish
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ All notable changes to the "pico-w-go" extension will be documented in this file
- Remove telnet and unix socket interfaces as they are never used and unable to connect to any plain MicroPython Raspberry Pi Pico (W) board
- Mounting the MicroPython filesystem into VS Code as a remote workspace.

## [2.1.3] - 2022-11-10

### Added
- Support for armv7 (32-bit) by providing a patch for the node-gyp-build dependency which should only be temp.

## [2.1.2] - 2022-10-31

### Changed
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ Pico-W-Go provides code auto-completion and allows you to communicate with your
This software is originally based on [Pico-Go](https://github.com/cpwood/Pico-Go) by cpwood.

Works with:
| Platform | Architectures |
|----------|:-------------:|
| Windows | x64 |
| macOS | x64, arm64 |
| Linux | x64, arm64 |
| Platform | Architectures |
|----------|:-----------------:|
| Windows | x64 |
| macOS | x64, arm64 |
| Linux | x64, arm64, armv7 |

## Features

Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pico-w-go",
"displayName": "Pico-W-Go",
"description": "Autocompletion and a REPL console for the Raspberry Pi Pico (W).",
"version": "2.1.2",
"version": "2.1.3",
"publisher": "paulober",
"license": "SEE LICENSE IN LICENSE.md",
"homepage": "https://github.com/paulober/Pico-W-Go/blob/main/README.md",
Expand Down Expand Up @@ -56,7 +56,8 @@
"platform": "linux",
"arch": [
"x64",
"arm64"
"arm64",
"arm"
]
}
],
Expand All @@ -67,7 +68,8 @@
],
"cpu": [
"x64",
"arm64"
"arm64",
"arm"
],
"minimumNodeVersion": 15,
"contributes": {
Expand Down
208 changes: 208 additions & 0 deletions patches/node-gyp-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
var fs = require('fs')
var path = require('path')
var os = require('os')

// Workaround to fix webpack's build warnings: 'the request of a dependency is an expression'
var runtimeRequire = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require // eslint-disable-line

var vars = (process.config && process.config.variables) || {}
var prebuildsOnly = !!process.env.PREBUILDS_ONLY
var abi = process.versions.modules // TODO: support old node where this is undef
var runtime = isElectron() ? 'electron' : (isNwjs() ? 'node-webkit' : 'node')

var arch = process.env.npm_config_arch || os.arch()
var platform = process.env.npm_config_platform || os.platform()
var libc = process.env.LIBC || (isAlpine(platform) ? 'musl' : 'glibc')
// ARMv7 detection patched to avoid arm_version === "default" on other arm systems than arm64 ones
var armv = process.env.ARM_VERSION || (arch === 'arm64' ? '8' : (arch === 'arm' ? (vars.arm_version === 'default' ? '7' : vars.arm_version) : '')) || ''
var uv = (process.versions.uv || '').split('.')[0]

module.exports = load

function load (dir) {
return runtimeRequire(load.path(dir))
}

load.path = function (dir) {
dir = path.resolve(dir || '.')

try {
var name = runtimeRequire(path.join(dir, 'package.json')).name.toUpperCase().replace(/-/g, '_')
if (process.env[name + '_PREBUILD']) dir = process.env[name + '_PREBUILD']
} catch (err) {}

if (!prebuildsOnly) {
var release = getFirst(path.join(dir, 'build/Release'), matchBuild)
if (release) return release

var debug = getFirst(path.join(dir, 'build/Debug'), matchBuild)
if (debug) return debug
}

var prebuild = resolve(dir)
if (prebuild) return prebuild

var nearby = resolve(path.dirname(process.execPath))
if (nearby) return nearby

var target = [
'platform=' + platform,
'arch=' + arch,
'runtime=' + runtime,
'abi=' + abi,
'uv=' + uv,
armv ? 'armv=' + armv : '',
'libc=' + libc,
'node=' + process.versions.node,
process.versions.electron ? 'electron=' + process.versions.electron : '',
typeof __webpack_require__ === 'function' ? 'webpack=true' : '' // eslint-disable-line
].filter(Boolean).join(' ')

throw new Error('No native build was found for ' + target + '\n loaded from: ' + dir + '\n')

function resolve (dir) {
// Find matching "prebuilds/<platform>-<arch>" directory
var tuples = readdirSync(path.join(dir, 'prebuilds')).map(parseTuple)
var tuple = tuples.filter(matchTuple(platform, arch)).sort(compareTuples)[0]
if (!tuple) return

// Find most specific flavor first
var prebuilds = path.join(dir, 'prebuilds', tuple.name)
var parsed = readdirSync(prebuilds).map(parseTags)
var candidates = parsed.filter(matchTags(runtime, abi))
var winner = candidates.sort(compareTags(runtime))[0]
if (winner) return path.join(prebuilds, winner.file)
}
}

function readdirSync (dir) {
try {
return fs.readdirSync(dir)
} catch (err) {
return []
}
}

function getFirst (dir, filter) {
var files = readdirSync(dir).filter(filter)
return files[0] && path.join(dir, files[0])
}

function matchBuild (name) {
return /\.node$/.test(name)
}

function parseTuple (name) {
// Example: darwin-x64+arm64
var arr = name.split('-')
if (arr.length !== 2) return

var platform = arr[0]
var architectures = arr[1].split('+')

if (!platform) return
if (!architectures.length) return
if (!architectures.every(Boolean)) return

return { name, platform, architectures }
}

function matchTuple (platform, arch) {
return function (tuple) {
if (tuple == null) return false
if (tuple.platform !== platform) return false
return tuple.architectures.includes(arch)
}
}

function compareTuples (a, b) {
// Prefer single-arch prebuilds over multi-arch
return a.architectures.length - b.architectures.length
}

function parseTags (file) {
var arr = file.split('.')
var extension = arr.pop()
var tags = { file: file, specificity: 0 }

if (extension !== 'node') return

for (var i = 0; i < arr.length; i++) {
var tag = arr[i]

if (tag === 'node' || tag === 'electron' || tag === 'node-webkit') {
tags.runtime = tag
} else if (tag === 'napi') {
tags.napi = true
} else if (tag.slice(0, 3) === 'abi') {
tags.abi = tag.slice(3)
} else if (tag.slice(0, 2) === 'uv') {
tags.uv = tag.slice(2)
} else if (tag.slice(0, 4) === 'armv') {
tags.armv = tag.slice(4)
} else if (tag === 'glibc' || tag === 'musl') {
tags.libc = tag
} else {
continue
}

tags.specificity++
}

return tags
}

function matchTags (runtime, abi) {
return function (tags) {
if (tags == null) return false
if (tags.runtime !== runtime && !runtimeAgnostic(tags)) return false
if (tags.abi !== abi && !tags.napi) return false
if (tags.uv && tags.uv !== uv) return false
if (tags.armv && tags.armv !== armv) return false
if (tags.libc && tags.libc !== libc) return false

return true
}
}

function runtimeAgnostic (tags) {
return tags.runtime === 'node' && tags.napi
}

function compareTags (runtime) {
// Precedence: non-agnostic runtime, abi over napi, then by specificity.
return function (a, b) {
if (a.runtime !== b.runtime) {
return a.runtime === runtime ? -1 : 1
} else if (a.abi !== b.abi) {
return a.abi ? -1 : 1
} else if (a.specificity !== b.specificity) {
return a.specificity > b.specificity ? -1 : 1
} else {
return 0
}
}
}

function isNwjs () {
return !!(process.versions && process.versions.nw)
}

function isElectron () {
if (process.versions && process.versions.electron) return true
if (process.env.ELECTRON_RUN_AS_NODE) return true
return typeof window !== 'undefined' && window.process && window.process.type === 'renderer'
}

function isAlpine (platform) {
return platform === 'linux' && fs.existsSync('/etc/alpine-release')
}

// Exposed for unit tests
// TODO: move to lib
load.parseTags = parseTags
load.matchTags = matchTags
load.compareTags = compareTags
load.parseTuple = parseTuple
load.matchTuple = matchTuple
load.compareTuples = compareTuples
1 change: 1 addition & 0 deletions scripts/applyPatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require('path');
const patches = [
['ftp-srv', 'ftp-srv.d.ts', path.join(__dirname, '..', 'node_modules', 'ftp-srv', 'ftp-srv.d.ts')],
['dtrace-provider', 'dtrace-provider.js', path.join(__dirname, '..', 'node_modules', 'dtrace-provider', 'dtrace-provider.js')],
['node-gyp-build', 'node-gyp-build.js', path.join(__dirname, '..', 'node_modules', 'node-gyp-build', 'index.js')],
];

for (let i = 0; i < patches.length; i++) {
Expand Down
32 changes: 16 additions & 16 deletions scripts/publish.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
npx vsce publish --target win32-x64 linux-x64 linux-arm64 darwin-x64 darwin-arm64
npx vsce publish --target win32-x64 linux-x64 linux-arm64 linux-armhf darwin-x64 darwin-arm64

# SIG # Begin signature block
# MIIIfwYJKoZIhvcNAQcCoIIIcDCCCGwCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUzKIjbwGUdGyIvLWMmQbiesaw
# 9iigggUUMIIFEDCCAvigAwIBAgIQX2UN69y+sLFPPURerUHC0zANBgkqhkiG9w0B
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUrf7aRWTg06UqaS2CAxQ+uEeb
# 0pKgggUUMIIFEDCCAvigAwIBAgIQX2UN69y+sLFPPURerUHC0zANBgkqhkiG9w0B
# AQsFADAgMQswCQYDVQQGEwJERTERMA8GA1UEAwwIcGF1bG9iZXIwHhcNMjIwOTA2
# MTkxNTE5WhcNMjMxMjMxMjIwMDAwWjAgMQswCQYDVQQGEwJERTERMA8GA1UEAwwI
# cGF1bG9iZXIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCvk+ceUwcW
Expand Down Expand Up @@ -34,17 +34,17 @@ npx vsce publish --target win32-x64 linux-x64 linux-arm64 darwin-x64 darwin-arm6
# g8cGeBoAgmMYBzGCAtUwggLRAgEBMDQwIDELMAkGA1UEBhMCREUxETAPBgNVBAMM
# CHBhdWxvYmVyAhBfZQ3r3L6wsU89RF6tQcLTMAkGBSsOAwIaBQCgeDAYBgorBgEE
# AYI3AgE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
# ks0cnnt4QzHSu0OolwZSW7TWwcX3/ouQxh/qcdk+FeDqRroVaoltRD3gqSCFJ6aF
# aM2SkqMoaRGd0kmdibZsuciIKS8+7H9swHDuyKpxBGXOvVZfFwOAr0zO8B4AD9um
# AcUHFqyaqDxZDkCBvNzQldCifmXCPB96MMW8F4Y7ZWlj9yZCV5Cgi4cVpZHsdVM1
# eBxvwiMQHDc3XXEeQaHTcAl9pcD7ee2ICdeP1kyRb5Z4mo6NV3LG8npx3tuur2zT
# x/xspAqTNOccpo06iBD7B0k4tIpnKaLm43aLSl3RPmRBiPWD5y2L9aPuMwZMhvu2
# gAXlGYbx9XrtZ1JMku4KeyY3Z94U/buqY9tFay4znY8CPr4EIYgjL0HWIjr4Oz5s
# uwqhdlGKGNapeDqMbMM/i9DQSNj60iJpsWUPKhMaQvrAZ24Vk2li5ub1P27ZcKMN
# jDKPnLFc8yaHY1FQ1SxGfqO5IgJVgDQqp5nDWSOU5vTuIHj59nCzPZU8e0LUcS4s
# +cxIswlaKADs5fw8/Q0PlAECn6dY6y6gZSiFXlLg/LPOKF0L7nlPk74dS8K+qEG2
# qZWRuY6qqSP7LWJLC3mFPGgDYw==
# SIG # End signature block

0 comments on commit 4b10f40

Please sign in to comment.