Skip to content

Commit 9a15c8c

Browse files
committed
setup-nasm v1.2.0
2 parents 4301395 + 717efc4 commit 9a15c8c

File tree

185 files changed

+19650
-964
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+19650
-964
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
os: [macos-latest, ubuntu-latest, windows-latest]
18-
version: [2.14.02, 2.12]
18+
version: [2.15.05, 2.14.02]
1919
steps:
2020
- name: Check out source code
2121
uses: actions/checkout@v1
@@ -39,7 +39,7 @@ jobs:
3939
fail-fast: false
4040
matrix:
4141
os: [macos-latest, ubuntu-latest]
42-
version: [2.14.02, 2.12]
42+
version: [2.15.05, 2.14.02]
4343
steps:
4444
- name: Check out source code
4545
uses: actions/checkout@v1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Supports Linux, macOS, and Windows.
1111

1212
## Inputs
1313

14-
- `version` – version of NASM to install (default: 2.14.02)
14+
- `version` – version of NASM to install (default: 2.15.05)
1515
- `from-source` – set to `true` to always build from source, or `false` to never
1616
- `platform` – set binary platform to something non-standard
1717
- `destination` – target directory for download and installation (default: `$HOME/nasm`)

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ inputs:
44
version:
55
description: NASM version to install
66
required: true
7-
default: 2.14.02
7+
default: 2.15.05
88
from-source:
99
description: Force or deny compilation from source code
1010
platform:

index.js

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ const fs = require('fs')
55
const fetch = require('node-fetch')
66
const path = require('path')
77
const process = require('process')
8+
const stream = require('stream')
9+
const tar = require('tar-fs')
810
const URL = require('url').URL
11+
const util = require('util')
912

1013
// This could have been a ten-line shell script, but no, we are full-stack async now...
1114
// Though, it does look pretty in the Web console.
@@ -75,47 +78,47 @@ async function main() {
7578
}
7679

7780
async function buildFromSource() {
78-
const url = new URL(`https://www.nasm.us/pub/nasm/releasebuilds/${version}/nasm-${version}.zip`)
81+
const url = new URL(`https://www.nasm.us/pub/nasm/releasebuilds/${version}/nasm-${version}.tar.gz`)
7982
const buffer = await fetchBuffer(url)
80-
const zip = new AdmZip(buffer)
83+
// node-fetch returns already ungzipped tarball.
84+
await extractTar(buffer, absNasmDir)
8185

82-
zip.extractAllTo(absNasmDir)
86+
// The tarball has all content in a versioned subdirectory: "nasm-2.15.05".
87+
const sourceDir = path.join(absNasmDir, `nasm-${version}`)
88+
core.debug(`extracted NASM to '${sourceDir}'`)
8389

84-
// NASM uses the usual "./configure && make" but ZIP makes it harder.
85-
// First of all, configure shell script usually ends up with Windows
86-
// line endings which breaks the shebang line on non-Windows machines.
87-
const configurePath = path.join(absNasmDir, 'configure')
90+
// NASM uses the usual "./configure && make", but make sure we extracted
91+
// everything correctly before jumping in.
92+
const configurePath = path.join(sourceDir, 'configure')
8893
if (!fs.existsSync(configurePath)) {
8994
core.debug(`configure script missing: ${configurePath}`)
90-
throw new Error(`failed to extract to '${absNasmDir}'`)
95+
throw new Error(`failed to extract to '${sourceDir}'`)
9196
}
92-
dos2unix(configurePath)
93-
fs.chmodSync(configurePath, '755')
9497

9598
// Now we can run "./configure". Node.js does not allow to change current
9699
// working directory for the current process, so we use absolute paths.
97-
execute([configurePath], {cwd: absNasmDir})
100+
execute([configurePath], {cwd: sourceDir})
98101

99102
// Now comes the fun part! Somehow, despite smoking Autocrack, NASM manages
100103
// to botch up platform detection. Or that's Apple thinking different again,
101104
// I don't know. Whatever it is, here are magic patches to make things work.
102105
if (platform == 'linux' || platform == 'macosx') {
103106
if (version.match(/2.14/)) {
104-
appendFile(path.join(absNasmDir, 'include/compiler.h'), [
107+
appendFile(path.join(sourceDir, 'include/compiler.h'), [
105108
'#include <time.h>'
106109
])
107110
}
108111
}
109112
if (platform == 'macosx') {
110113
if (version.match(/2.14/)) {
111-
appendFile(path.join(absNasmDir, 'config/config.h'), [
114+
appendFile(path.join(sourceDir, 'config/config.h'), [
112115
'#define HAVE_SNPRINTF 1',
113116
'#define HAVE_VSNPRINTF 1',
114117
'#define HAVE_INTTYPES_H 1'
115118
])
116119
}
117120
if (version.match(/2.13/)) {
118-
appendFile(path.join(absNasmDir, 'config/config.h'), [
121+
appendFile(path.join(sourceDir, 'config/config.h'), [
119122
'#define HAVE_STRLCPY 1',
120123
'#define HAVE_DECL_STRLCPY 1',
121124
'#define HAVE_SNPRINTF 1',
@@ -124,7 +127,7 @@ async function main() {
124127
])
125128
}
126129
if (version.match(/2.12/)) {
127-
appendFile(path.join(absNasmDir, 'config.h'), [
130+
appendFile(path.join(sourceDir, 'config.h'), [
128131
'#define HAVE_STRLCPY 1',
129132
'#define HAVE_DECL_STRLCPY 1',
130133
'#define HAVE_SNPRINTF 1',
@@ -134,9 +137,12 @@ async function main() {
134137
}
135138

136139
// Finally, build the damn binary.
137-
execute(['make', 'nasm'], {cwd: absNasmDir})
140+
execute(['make', 'nasm'], {cwd: sourceDir})
138141

139-
core.debug(`compiled NASM in '${absNasmDir}'`)
142+
core.debug(`compiled NASM in '${sourceDir}'`)
143+
144+
// The binary is expected at a slightly different place...
145+
fs.renameSync(path.join(sourceDir, nasm), absNasmFile)
140146
}
141147

142148
var made_it = false
@@ -187,14 +193,6 @@ function execute(cmdline, extra_options) {
187193
return result
188194
}
189195

190-
function dos2unix(path) {
191-
const converted = path + '.unix'
192-
const content = fs.readFileSync(path, {encoding: 'utf8'})
193-
const unixified = content.replace(/\r\n/g, '\n')
194-
fs.writeFileSync(converted, unixified, {encoding: 'utf8'})
195-
fs.renameSync(converted, path)
196-
}
197-
198196
function appendFile(path, strings) {
199197
fs.appendFileSync(path, '\n' + strings.join('\n') + '\n')
200198
}
@@ -212,4 +210,15 @@ async function fetchBuffer(url) {
212210
return buffer
213211
}
214212

213+
async function extractTar(buffer, directory) {
214+
core.info('Extracting source code...')
215+
// Yes, I love async programming very much. So straightforward!
216+
async function * data() { yield buffer; }
217+
const tarball = stream.Readable.from(data())
218+
.pipe(tar.extract(directory))
219+
// Stream promise API is not available on GitHub Actions. Drain manually.
220+
const finished = util.promisify(stream.finished)
221+
return finished(tarball)
222+
}
223+
215224
main().catch((e) => core.setFailed(`could not install NASM: ${e}`))

node_modules/@actions/core/LICENSE.md

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)