Skip to content

Commit

Permalink
Introduce gulp build to build native/idl files
Browse files Browse the repository at this point in the history
This change introduces `gulp` build system to build native/idl files. After
this patch, we no longer need to create and modify `gyp/gypi` files to update
the list of native/idl files.

This change includes the following things:
  - Introduce `gulp` build (including some related packages)
  - Stop using `.gypi` files except `generator.gypi`. Once move TSC build to
    `gulp`, then we can remove it as well

ISSUE=#98,#193
  • Loading branch information
romandev committed Nov 19, 2017
1 parent e5123a5 commit d83d8be
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 141 deletions.
20 changes: 4 additions & 16 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@

{
'includes': [
'core/core.gypi',
'examples/examples.gypi',
'examples/electron/native/electron_native.gypi',
'generator/generator.gypi',
'test/test.gypi',
],

'targets': [
Expand Down Expand Up @@ -52,13 +48,8 @@
}],
],
'sources': [
'<@(core_cpp_files)',
'<@(examples_cpp_files)',
'<@(examples_idl_output_files)',
'<@(examples_electron_native_cpp_files)',
'<@(examples_electron_native_idl_output_files)',
'<@(test_cpp_files)',
'<@(test_idl_output_files)',
'<!@(./bacardi list_cpp_files --silent)',
'<!@(./bacardi list_generated_cpp_files --silent)',
'<(SHARED_INTERMEDIATE_DIR)/bacardi.cc',
],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
Expand Down Expand Up @@ -109,13 +100,10 @@
{
'action_name': 'idl',
'inputs': [
'<@(examples_idl_files)',
'<@(examples_electron_native_idl_files)',
'<@(test_idl_files)',
'<!@(./bacardi list_idl_files --silent)',
],
'outputs': [
'<@(examples_electron_native_idl_output_files)',
'<@(test_idl_output_files)',
'<!@(./bacardi list_generated_cpp_files --silent)',
],
'conditions': [
['OS!="win"',
Expand Down
17 changes: 15 additions & 2 deletions bootstrap/bacardi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,20 @@ git submodule update
# Sync third_parties.
sync_node

# NPM update
if [ ! -f .last_update ] || [ package.json -nt .last_update ]; then
# FIXME(zino): If npm packages are updated, then node-gyp will be triggered
# automatically. To get native/idl file list, we will use ./bacardi list*
# command again in binding.gyp. Then, it causes infinite loop finally.
# To avoid the problem, as a workaround, we should filter list* commands here.
if [ "${1:0:4}" = "list" ]; then
gulp $@
exit
fi

# NPM install or update
if [ ! -f .last_update ]; then
npm install && > .last_update
elif [ package.json -nt .last_update ]; then
npm update && > .last_update
fi

for command in $(ls $(bootstrap_command_path)); do
Expand All @@ -47,3 +58,5 @@ for command in $(ls $(bootstrap_command_path)); do
exit
fi
done

gulp $@
25 changes: 0 additions & 25 deletions core/core.gypi

This file was deleted.

32 changes: 0 additions & 32 deletions examples/electron/native/electron_native.gypi

This file was deleted.

35 changes: 0 additions & 35 deletions examples/examples.gypi

This file was deleted.

74 changes: 74 additions & 0 deletions gulpfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Copyright (c) 2017 The Absolute 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 gulp from 'gulp';
import * as path from 'path';
import * as through from 'through2';

gulp.task('default', (callback) => {
// FIXME(zino): Should print available commands in Bacardi.
return;
});

/**
* This task will be used in binding.gyp to build native files.
*/
gulp.task('list_cpp_files', (callback) => {
return gulp
.src([
'core/**/*.h', 'core/**/*.cc', 'examples/**/*.h', 'examples/**/*.cc',
'test/**/*.h', 'test/**/*.cc'
])
.pipe(printPath());
});

/**
* This task will be used in binding.gyp to build idl files.
*/
gulp.task('list_idl_files', (callback) => {
return gulp.src(['examples/**/*.idl', 'test/**/*.idl']).pipe(printPath());
});

/**
* This task will be used in binding.gyp to build idl files.
*/
gulp.task('list_generated_cpp_files', (callback) => {
// FIXME(zino): The following file list should be generated by idl generator
// automatically.
const genDir = 'build/Release/obj/gen/';
const genFiles = [
path.join(genDir, 'examples/calculator_bridge.cc'),
path.join(genDir, 'examples/calculator_bridge.h'),
path.join(genDir, 'examples/ternary_calculator_bridge.cc'),
path.join(genDir, 'examples/ternary_calculator_bridge.h'),
path.join(genDir, 'examples/electron/native/electron_native_bridge.cc'),
path.join(genDir, 'examples/electron/native/electron_native_bridge.h'),
path.join(genDir, 'test/test_interface_bridge.cc'),
path.join(genDir, 'test/test_interface_bridge.h'),
];

return genFiles.forEach((file) => {
process.stdout.write('"' + file + '"\n');
});
});

/* Custom plugins */
function printPath() {
return through.obj((files, encoding, callback) => {
process.stdout.write('"' + path.relative(files.cwd, files.path) + '"\n');
callback();
});
}
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
{
"devDependencies": {
"@types/gulp": "^4.0.5",
"@types/gulp-typescript": "^2.13.0",
"@types/jest": "^21.1.2",
"@types/node": "^8.0.24",
"@types/through2": "^2.0.33",
"bindings": "^1.3.0",
"change-case": "^3.0.1",
"electron": "^1.7.8",
"electron-rebuild": "^1.6.0",
"gulp": "^3.9.1",
"gulp-typescript": "^3.2.3",
"jest": "^21.2.1",
"mkdirp": "^0.5.1",
"node-addon-api": "^1.0.0",
"node-gyp": "^3.6.2",
"nunjucks": "^3.0.1",
"through2": "^2.0.3",
"ts-jest": "^21.1.0",
"ts-node": "^3.3.0",
"typescript": "^2.4.2",
"webidl2": "^4.1.0"
},
Expand Down
31 changes: 0 additions & 31 deletions test/test.gypi

This file was deleted.

0 comments on commit d83d8be

Please sign in to comment.