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
13374867
Commit
13374867
authored
Jun 16, 2016
by
Josh Haberman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JS: import well-known types from google-protobuf package.
parent
f180ef63
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
gulpfile.js
js/gulpfile.js
+25
-2
js_generator.cc
src/google/protobuf/compiler/js/js_generator.cc
+8
-0
No files found.
js/gulpfile.js
View file @
13374867
...
...
@@ -8,6 +8,20 @@ function exec(command, cb) {
var
protoc
=
process
.
env
.
PROTOC
||
'../src/protoc'
;
var
wellKnownTypes
=
[
'../src/google/protobuf/any.proto'
,
'../src/google/protobuf/api.proto'
,
'../src/google/protobuf/descriptor.proto'
,
'../src/google/protobuf/duration.proto'
,
'../src/google/protobuf/empty.proto'
,
'../src/google/protobuf/field_mask.proto'
,
'../src/google/protobuf/source_context.proto'
,
'../src/google/protobuf/struct.proto'
,
'../src/google/protobuf/timestamp.proto'
,
'../src/google/protobuf/type.proto'
,
'../src/google/protobuf/wrappers.proto'
,
];
gulp
.
task
(
'genproto_closure'
,
function
(
cb
)
{
exec
(
protoc
+
' --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto'
,
function
(
err
,
stdout
,
stderr
)
{
...
...
@@ -18,7 +32,16 @@ gulp.task('genproto_closure', function (cb) {
});
gulp
.
task
(
'genproto_commonjs'
,
function
(
cb
)
{
exec
(
'mkdir -p commonjs_out && '
+
protoc
+
' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . *.proto commonjs/test*/*.proto ../src/google/protobuf/descriptor.proto'
,
exec
(
'mkdir -p commonjs_out && '
+
protoc
+
' --js_out=import_style=commonjs,binary:commonjs_out -I ../src -I commonjs -I . *.proto commonjs/test*/*.proto ../src/google/protobuf/descriptor.proto'
+
wellKnownTypes
.
join
(
' '
),
function
(
err
,
stdout
,
stderr
)
{
console
.
log
(
stdout
);
console
.
log
(
stderr
);
cb
(
err
);
});
});
gulp
.
task
(
'genproto_wellknowntypes'
,
function
(
cb
)
{
exec
(
protoc
+
' --js_out=import_style=commonjs,binary:. -I ../src '
+
wellKnownTypes
.
join
(
' '
),
function
(
err
,
stdout
,
stderr
)
{
console
.
log
(
stdout
);
console
.
log
(
stderr
);
...
...
@@ -26,7 +49,7 @@ gulp.task('genproto_commonjs', function (cb) {
});
});
gulp
.
task
(
'dist'
,
function
(
cb
)
{
gulp
.
task
(
'dist'
,
[
'genproto_wellknowntypes'
],
function
(
cb
)
{
// TODO(haberman): minify this more aggressively.
// Will require proper externs/exports.
exec
(
'./node_modules/google-closure-library/closure/bin/calcdeps.py -i message.js -i binary/reader.js -i binary/writer.js -i commonjs/export.js -p . -p node_modules/google-closure-library/closure -o compiled --compiler_jar node_modules/google-closure-compiler/compiler.jar > google-protobuf.js'
,
...
...
src/google/protobuf/compiler/js/js_generator.cc
View file @
13374867
...
...
@@ -160,6 +160,14 @@ string GetJSFilename(const string& filename) {
// Given a filename like foo/bar/baz.proto, returns the root directory
// path ../../
string
GetRootPath
(
const
string
&
filename
)
{
if
(
filename
.
find
(
"google/protobuf"
)
==
0
)
{
// Well-known types (.proto files in the google/protobuf directory) are
// assumed to come from the 'google-protobuf' npm package. We may want to
// generalize this exception later by letting others put generated code in
// their own npm packages.
return
"google-protobuf/"
;
}
size_t
slashes
=
std
::
count
(
filename
.
begin
(),
filename
.
end
(),
'/'
);
if
(
slashes
==
0
)
{
return
"./"
;
...
...
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