Skip to content

Commit

Permalink
Implement skeleton codes for a new version of WebIDL compiler
Browse files Browse the repository at this point in the history
This is a new initial implementation of WebIDL compiler. It has the
following differences compared to the existing one.
  - It is built by `gulp` instead of `gyp`
  - No longer build `generator` and `webidl` separately

ISSUE=#207
  • Loading branch information
romandev committed Nov 25, 2017
1 parent 34893d1 commit 3f92783
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
1 change: 1 addition & 0 deletions bootstrap/bacardi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ for command in $(ls $(bootstrap_command_path)); do
fi
done

export NODE_PATH=$(bacardi_path)
gulp $@
27 changes: 27 additions & 0 deletions generator/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2017 The Bacardi Authors.
*
* 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.
*/

import * as assert from 'assert';

export async function run(idlFiles: string[]): Promise<number> {
assert(idlFiles.indexOf('test/test_interface.idl') >= 0);
assert(idlFiles.indexOf('examples/calculator.idl') >= 0);
assert(idlFiles.indexOf('examples/electron/native/electron_native.idl') >= 0);

// Not implemented yet.

return 0;
}
21 changes: 19 additions & 2 deletions gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

import * as generator from 'generator';
import * as globs from 'globs';
import * as gulp from 'gulp';
import * as shell from 'gulp-shell';
import gulpTslint from 'gulp-tslint';
Expand All @@ -29,6 +31,15 @@ gulp.task('default', () => {
return;
});

/**
* Build WebIDL
*/
gulp.task('build_webidl', (callback) => {
globs(['examples/**/*.idl', 'test/**/*.idl'], async(error, files) => {
callback(await generator.run(files));
});
});

/**
* This task will be used in binding.gyp to build native files.
*/
Expand Down Expand Up @@ -100,7 +111,10 @@ gulp.task('lint_native', shell.task([
gulp.task('lint_ts', () => {
const program: ts.Program = tslint.Linter.createProgram('tsconfig.json');

return gulp.src('gulpfile.ts')
return gulp.src([
'gulpfile.ts',
'generator/index.ts'
])
.pipe(gulpTslint({
formatter: 'codeFrame',
program: program
Expand All @@ -113,7 +127,10 @@ gulp.task('lint_ts', () => {
gulp.task('lint_ts:fix', () => {
const program: ts.Program = tslint.Linter.createProgram('tsconfig.json');

return gulp.src('gulpfile.ts')
return gulp.src([
'gulpfile.ts',
'generator/index.ts'
])
.pipe(gulpTslint({
formatter: 'codeFrame',
program: program,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"change-case": "^3.0.1",
"electron": "^1.7.8",
"electron-rebuild": "^1.6.0",
"globs": "^0.1.3",
"gulp": "^3.9.1",
"gulp-shell": "^0.6.3",
"gulp-tslint": "^8.1.2",
Expand Down

0 comments on commit 3f92783

Please sign in to comment.