Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ demo/train-*
.nyc_output/
coverage/
.DS_Store
*.node
70 changes: 70 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
language: node_js
compiler: gcc
env:
global:
- NODE_GLES_SKIP_BINARY_DOWNLOAD_FOR_CI=true
jobs:
include:
- stage: build
node_js: "10"
os: linux
- stage: build
node_js: "11"
os: linux
- stage: build
node_js: "12"
os: linux
- stage: build
node_js: "13"
os: linux
- stage: build
node_js: "14"
os: linux
- stage: build
node_js: "10"
os: osx
- stage: build
node_js: "11"
os: osx
- stage: build
node_js: "12"
os: osx
- stage: build
node_js: "13"
os: osx
- stage: build
node_js: "14"
os: osx
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-7
- g++-7
- make
- git
before_install:
- npm install -g yarn
- if [ $TRAVIS_OS_NAME == "linux" ]; then
export CC="gcc-7";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just specify "gcc"? These should be symlink'd on linux.

export CXX="g++-7";
export LINK="gcc-7";
export LINKXX="g++-7";
fi
- node --version
- yarn --version
script:
- yarn build
after_script:
- "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
cache: yarn
deploy:
provider: releases
api_key:
secure: ADD YOUR TRAVIS KEY HERE
file_glob: true
file: "node-gles-*-*-*.node"
skip_cleanup: true
on:
tags: true
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ Future plans include surfacing an API for running [Compute Shaders](https://www.

## Supported platforms

* Mac OS
* Windows
* Linux
This is a native Addon to NodeJS which delivers prebuilt binaries. Only some environments are supported:

| Node Version | Windows 64-Bit | Windows 32-Bit | Linux 64-Bit | Linux 32-Bit | OSX |
| ------------------ | -------------- | -------------- | ------------ | ------------ | --- |
| Earlier | ✗ | ✗ | ✗ | ✗ | ✗ |
| Node 10 _(Abi 64)_ | ✓ | ✗ | ✓ | ✗ | ✓ |
| Node 11 _(Abi 67)_ | ✓ | ✗ | ✓ | ✗ | ✓ |
| Node 12 _(Abi 72)_ | ✓ | ✗ | ✓ | ✗ | ✓ |
| Node 13 _(Abi 79)_ | ✓ | ✗ | ✓ | ✗ | ✓ |
| Node 14 _(Abi 83)_ | ✓ | ✗ | ✓ | ✗ | ✓ |

## Creating a WebGL context

Expand Down
110 changes: 110 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# The release configuration.
# This is executed for releases only and will upload the artifact to Github.
- configuration: release
version: "{build}"
branches:
only:
- release
- /\d\.\d\.\d/
except:
- master
os: Visual Studio 2013
platform:
- x64
build: off
clone_folder: C:\repositories\node-gles
# This is adapted from the appveyor.yml in node-sass.
# http://www.wintellect.com/devcenter/jrobbins/pdb-files-what-every-developer-must-know
# http://help.appveyor.com/discussions/kb/32-how-to-build-on-logical-drive-created-by-subst
init:
- cmd: >-
subst S: C:\repositories
- ps: set-location -path S:\node-gles
environment:
NODE_GLES_SKIP_BINARY_DOWNLOAD_FOR_CI: true
matrix:
- nodejs_version: 10
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 11
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 12
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 13
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 14
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
install:
- git submodule update --init --recursive
- ps: Install-Product node $env:nodejs_version $env:platform
- node --version
- npm --version
- npm install -g yarn
- yarn --version
- yarn install
build_script:
- yarn build
artifacts:
- path: node-gles-*-*-*.node
name: node-gles
deploy:
- provider: GitHub
artifact: node-gles
auth_token:
secure: ADD YOUR APPVEYOR KEY HERE
draft: false
prerelease: false
on:
appveyor_repo_tag: true
# The testing configuration.
# This will be executed for master and all pull requests and wont upload any artifacts.
- configuration: testing
version: "{build}"
branches:
except:
- release
- /\d\.\d\.\d/
skip_tags: true
os: Visual Studio 2013
platform:
- x64
build: off
clone_folder: C:\repositories\node-gles
# This is adapted from the appveyor.yml in node-sass.
# http://www.wintellect.com/devcenter/jrobbins/pdb-files-what-every-developer-must-know
# http://help.appveyor.com/discussions/kb/32-how-to-build-on-logical-drive-created-by-subst
init:
- cmd: >-
subst S: c:\repositories
- ps: set-location -path S:\node-gles
environment:
NODE_GLES_SKIP_BINARY_DOWNLOAD_FOR_CI: true
matrix:
- nodejs_version: 10
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 11
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 12
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 13
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- nodejs_version: 14
GYP_MSVS_VERSION: 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
install:
- ps: Install-Product node $env:nodejs_version $env:platform
- node --version
- npm --version
- npm install -g yarn
- yarn --version
- yarn install
build_script:
- yarn build
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"scripts": {
"build-npm": "./scripts/build-npm.sh",
"format": "clang-format -i -style=Google binding/*.cc binding/*.h",
"install": "node scripts/install.js"
"install": "node scripts/install.js",
"build": "node scripts/build.js && tsc -p .",
"postbuild": "node scripts/rename.js"
},
"devDependencies": {
"@types/bindings": "^1.3.0",
Expand All @@ -32,6 +34,7 @@
"bindings": "^1.3.0",
"https-proxy-agent": "^2.2.3",
"progress": "^2.0.3",
"request": "^2.88.2",
"rimraf": "^2.6.2",
"tar": "^6.0.1"
}
Expand Down
168 changes: 168 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/**
* @license
* Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/

const cp = require('child_process');
const fs = require('fs');
const https = require('https');
const path = require('path');
const rimraf = require('rimraf');
const tar = require('tar');
const util = require('util');
const os = require('os');
const url = require('url');
const zip = require('adm-zip');
const HttpsProxyAgent = require('https-proxy-agent');
const ProgressBar = require('progress');

const mkdir = util.promisify(fs.mkdir);
const exists = util.promisify(fs.exists);
const rename = util.promisify(fs.rename);
const unlink = util.promisify(fs.unlink);

// Determine which tarball to download based on the OS platform and arch:
const platform = os.platform().toLowerCase();
const platformArch = `${platform}-${os.arch().toLowerCase()}`;
let ANGLE_BINARY_URI = 'https://storage.googleapis.com/angle-builds/';
if (platform === 'darwin') {
// TODO(add debug flag?)
ANGLE_BINARY_URI += `angle-3729-${platformArch}.tar.gz`;
} else if (platform === 'linux') {
// TODO(add debug flag?)
ANGLE_BINARY_URI += `angle-3729-${platformArch}.tar.gz`;
} else if (platform === 'win32') {
ANGLE_BINARY_URI += `angle-3729-${platformArch}.zip`;
} else {
console.log('platform: ' + platform);
throw new Error(`The platform ${platformArch} is not currently supported!`);
}

console.log(`Downloading ANGLE from: ${ANGLE_BINARY_URI}`);

// Dependency storage paths:
const depsPath = path.join(__dirname, '..', 'deps');

//
// Ensures that a directory exists at a given path.
//
async function ensureDir(dirPath) {
if (!await exists(dirPath)) {
await mkdir(dirPath);
}
}

//
// Downloads the ANGLE tarball set at `ANGLE_BINARY_URI` with an optional
// callback when downloading and extracting has finished.
//
async function downloadAngleLibs(callback) {
console.error('* Downloading ANGLE');
await ensureDir(depsPath);

// If HTTPS_PROXY, https_proxy, HTTP_PROXY, or http_proxy is set
const proxy = process.env['HTTPS_PROXY'] || process.env['https_proxy'] ||
process.env['HTTP_PROXY'] || process.env['http_proxy'] || '';

// Using object destructuring to construct the options object for the
// http request. the '...url.parse(ANGLE_BINARY_URI)' part fills in the host,
// path, protocol, etc from the ANGLE_BINARY_URI and then we set the agent to
// the default agent which is overridden a few lines down if there is a proxy
const options = {
...url.parse(ANGLE_BINARY_URI),
agent: https.globalAgent,
headers: { 'Cache-Control': 'no-cache' }
};

if (proxy !== '') {
options.agent = new HttpsProxyAgent(proxy);
}

const request = https.get(options, response => {
const bar = new ProgressBar('[:bar] :rate/bps :percent :etas', {
complete: '=',
incomplete: ' ',
width: 30,
total: parseInt(response.headers['content-length'], 10)
});

if (platform === 'win32') {
// Save zip file to disk, extract, and delete the downloaded zip file.
const tempFileName = path.join(__dirname, '_tmp.zip');
const outputFile = fs.createWriteStream(tempFileName);

response.on('data', chunk => bar.tick(chunk.length))
.pipe(outputFile)
.on('close', async () => {
const zipFile = new zip(tempFileName);
zipFile.extractAllTo(depsPath, true /* overwrite */);

await unlink(tempFileName);

// The .lib files for the two .dll files we care about have a name
// the compiler doesn't like - rename them:
await rename(
path.join(
depsPath, 'angle', 'out', 'Release', 'libGLESv2.dll.lib'),
path.join(
depsPath, 'angle', 'out', 'Release', 'libGLESv2.lib'));
await rename(
path.join(
depsPath, 'angle', 'out', 'Release', 'libEGL.dll.lib'),
path.join(depsPath, 'angle', 'out', 'Release', 'libEGL.lib'));

if (callback !== undefined) {
callback();
}
});
} else {
// All other platforms use a tarball:
response
.on('data',
(chunk) => {
bar.tick(chunk.length);
})
.pipe(tar.x({ C: depsPath, strict: true }))
.on('close', () => {
if (callback !== undefined) {
callback();
}
});
}
});

request.end();
}

//
// Wraps and executes a node-gyp rebuild command.
//
async function buildBindings() {
console.error('* Building ANGLE bindings')
cp.execSync('node-gyp rebuild', (err) => {
if (err) {
throw new Error('node-gyp failed with: ' + err);
}
});
}

//
// Main execution function for this script.
//
async function run() {
await downloadAngleLibs(buildBindings);
}

run();
3 changes: 3 additions & 0 deletions scripts/file-name.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const suffix: string;
export const baseName: string;
export const qualifiedName: string;
Loading