forked from DataDog/dd-trace-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update build scripts to use a single prebuilds artifact (DataDog#767)
- Loading branch information
Showing
7 changed files
with
105 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,6 +109,7 @@ out | |
versions | ||
build | ||
prebuilds | ||
prebuilds.* | ||
docs/test.js | ||
!packages/*/test/**/node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
'use strict' | ||
|
||
const checksum = require('checksum') | ||
const fs = require('fs') | ||
const glob = require('glob') | ||
const os = require('os') | ||
const path = require('path') | ||
const tar = require('tar') | ||
|
||
const platforms = [ | ||
'darwin-ia32', | ||
'darwin-x64', | ||
'linux-ia32', | ||
'linux-x64', | ||
'win32-ia32', | ||
'win32-x64' | ||
] | ||
|
||
zipPrebuilds() | ||
extractPrebuilds() | ||
validatePrebuilds() | ||
createChecksum() | ||
copyPrebuilds() | ||
|
||
function zipPrebuilds () { | ||
tar.create({ | ||
gzip: true, | ||
sync: true, | ||
portable: true, | ||
strict: true, | ||
file: path.join(os.tmpdir(), 'prebuilds.tgz') | ||
}, glob.sync('prebuilds/**/*.node')) | ||
} | ||
|
||
function extractPrebuilds () { | ||
tar.extract({ | ||
sync: true, | ||
strict: true, | ||
file: path.join(os.tmpdir(), 'prebuilds.tgz'), | ||
cwd: os.tmpdir() | ||
}) | ||
} | ||
|
||
function validatePrebuilds () { | ||
platforms.forEach(platform => { | ||
fs.readdirSync(path.join(os.tmpdir(), 'prebuilds', platform)) | ||
.filter(file => /^node-\d+\.node$/.test(file)) | ||
.forEach(file => { | ||
const content = fs.readFileSync(path.join('prebuilds', platform, file)) | ||
const sum = fs.readFileSync(path.join('prebuilds', platform, `${file}.sha1`), 'ascii') | ||
|
||
if (sum !== checksum(content)) { | ||
throw new Error(`Invalid checksum for "prebuilds/${platform}/${file}".`) | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
function createChecksum () { | ||
const file = path.join(os.tmpdir(), 'prebuilds.tgz') | ||
const sum = checksum(fs.readFileSync(file)) | ||
|
||
fs.writeFileSync(`${file}.sha1`, sum) | ||
} | ||
|
||
function copyPrebuilds () { | ||
const basename = path.normalize(path.join(__dirname, '..')) | ||
const filename = 'prebuilds.tgz' | ||
|
||
fs.copyFileSync( | ||
path.join(os.tmpdir(), filename), | ||
path.join(basename, filename) | ||
) | ||
|
||
fs.copyFileSync( | ||
path.join(os.tmpdir(), `${filename}.sha1`), | ||
path.join(basename, `${filename}.sha1`) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters