Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
24c5424b
Commit
24c5424b
authored
Feb 19, 2016
by
Josh Haberman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a bit more to README.md, and allowed custom PROTOC var in tests.
parent
907ad4a0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
README.md
js/README.md
+24
-0
gulpfile.js
js/gulpfile.js
+4
-2
No files found.
js/README.md
View file @
24c5424b
...
...
@@ -43,6 +43,10 @@ Once you have `protoc` compiled, you can run the tests by typing:
$ npm install
$ npm test
# If your protoc is somewhere else than ../src/protoc, instead do this.
# But make sure your protoc is the same version as this (or compatible)!
$ PROTOC=/usr/local/bin/protoc npm test
This will run two separate copies of the tests: one that uses
Closure Compiler style imports and one that uses CommonJS imports.
You can see all the CommonJS files in
`commonjs_out/`
.
...
...
@@ -113,6 +117,26 @@ statements like:
var message = new messages.MyMessage();
The `--js_out` flag
-------------------
The syntax of the
`--js_out`
flag is:
--js_out=[OPTIONS:]output_dir
Where
`OPTIONS`
are separated by commas. Options are either
`opt=val`
or
just
`opt`
(for options that don't take a value). The available options
are specified and documented in the
`GeneratorOptions`
struct in
[
src/google/protobuf/compiler/js/js_generator.h
](
https://github.com/google/protobuf/blob/master/src/google/protobuf/compiler/js/js_generator.h#L53
)
.
Some examples:
-
`--js_out=library=myprotos_lib.js,binary:.`
: this contains the options
`library=myprotos.lib.js`
and
`binary`
and outputs to the current directory.
The
`import_style`
option is left to the default, which is
`closure`
.
-
`--js_out=import_style=commonjs,binary:protos`
: this contains the options
`import_style=commonjs`
and
`binary`
and outputs to the directory
`protos`
.
API
===
...
...
js/gulpfile.js
View file @
24c5424b
...
...
@@ -2,8 +2,10 @@ var gulp = require('gulp');
var
exec
=
require
(
'child_process'
).
exec
;
var
glob
=
require
(
'glob'
);
var
protoc
=
process
.
env
.
PROTOC
||
'../src/protoc'
;
gulp
.
task
(
'genproto_closure'
,
function
(
cb
)
{
exec
(
'../src/protoc
--js_out=library=testproto_libs,binary:. -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto'
,
exec
(
protoc
+
'
--js_out=library=testproto_libs,binary:. -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto'
,
function
(
err
,
stdout
,
stderr
)
{
console
.
log
(
stdout
);
console
.
log
(
stderr
);
...
...
@@ -12,7 +14,7 @@ gulp.task('genproto_closure', function (cb) {
});
gulp
.
task
(
'genproto_commonjs'
,
function
(
cb
)
{
exec
(
'mkdir -p commonjs_out &&
../src/protoc
--js_out=import_style=commonjs,binary:commonjs_out -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto'
,
exec
(
'mkdir -p commonjs_out &&
'
+
protoc
+
'
--js_out=import_style=commonjs,binary:commonjs_out -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto'
,
function
(
err
,
stdout
,
stderr
)
{
console
.
log
(
stdout
);
console
.
log
(
stderr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment