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
55cc3aa9
Commit
55cc3aa9
authored
Feb 02, 2016
by
Josh Haberman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP.
parent
c40f8c1f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
8 deletions
+76
-8
commonjs_export.js
js/commonjs_export.js
+10
-0
gulpfile.js
js/gulpfile.js
+34
-5
jasmine_commonjs.json
js/jasmine_commonjs.json
+11
-0
package.json
js/package.json
+4
-2
js_generator.cc
src/google/protobuf/compiler/js/js_generator.cc
+0
-0
js_generator.h
src/google/protobuf/compiler/js/js_generator.h
+17
-1
No files found.
js/commonjs_export.js
0 → 100644
View file @
55cc3aa9
/**
* @fileoverview Export symbols needed by generated code in CommonJS style.
*/
exports
=
{
Message
:
jspb
.
Message
,
BinaryReader
:
jspb
.
BinaryReader
,
BinaryWriter
:
jspb
.
BinaryWriter
,
ExtensionFieldInfo
:
jspb
.
ExtensionFieldInfo
,
};
js/gulpfile.js
View file @
55cc3aa9
var
gulp
=
require
(
'gulp'
);
var
gulp
=
require
(
'gulp'
);
var
exec
=
require
(
'child_process'
).
exec
;
var
exec
=
require
(
'child_process'
).
exec
;
gulp
.
task
(
'genproto'
,
function
(
cb
)
{
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
(
'../src/protoc --js_out=library=testproto_libs,binary:. -I ../src -I . *.proto ../src/google/protobuf/descriptor.proto'
,
function
(
err
,
stdout
,
stderr
)
{
function
(
err
,
stdout
,
stderr
)
{
console
.
log
(
stdout
);
console
.
log
(
stdout
);
console
.
log
(
stderr
);
console
.
log
(
stderr
);
cb
(
err
);
cb
(
err
);
});
});
})
});
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'
,
function
(
err
,
stdout
,
stderr
)
{
console
.
log
(
stdout
);
console
.
log
(
stderr
);
cb
(
err
);
});
});
gulp
.
task
(
'deps'
,
[
'genproto'
],
function
(
cb
)
{
gulp
.
task
(
'dist'
,
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 -p . -p node_modules/google-closure-library/closure -o compiled --compiler_jar node_modules/google-closure-compiler/compiler.jar > google-protobuf.js'
,
function
(
err
,
stdout
,
stderr
)
{
console
.
log
(
stdout
);
console
.
log
(
stderr
);
cb
(
err
);
});
});
gulp
.
task
(
'deps'
,
[
'genproto_closure'
],
function
(
cb
)
{
exec
(
'./node_modules/google-closure-library/closure/bin/build/depswriter.py *.js binary/*.js > deps.js'
,
exec
(
'./node_modules/google-closure-library/closure/bin/build/depswriter.py *.js binary/*.js > deps.js'
,
function
(
err
,
stdout
,
stderr
)
{
function
(
err
,
stdout
,
stderr
)
{
console
.
log
(
stdout
);
console
.
log
(
stdout
);
console
.
log
(
stderr
);
console
.
log
(
stderr
);
cb
(
err
);
cb
(
err
);
});
});
})
})
;
gulp
.
task
(
'test
'
,
[
'genproto
'
,
'deps'
],
function
(
cb
)
{
gulp
.
task
(
'test
_closure'
,
[
'genproto_closure
'
,
'deps'
],
function
(
cb
)
{
exec
(
'JASMINE_CONFIG_PATH=jasmine.json ./node_modules/.bin/jasmine'
,
exec
(
'JASMINE_CONFIG_PATH=jasmine.json ./node_modules/.bin/jasmine'
,
function
(
err
,
stdout
,
stderr
)
{
function
(
err
,
stdout
,
stderr
)
{
console
.
log
(
stdout
);
console
.
log
(
stdout
);
...
@@ -27,3 +47,12 @@ gulp.task('test', ['genproto', 'deps'], function (cb) {
...
@@ -27,3 +47,12 @@ gulp.task('test', ['genproto', 'deps'], function (cb) {
cb
(
err
);
cb
(
err
);
});
});
});
});
gulp
.
task
(
'test_commonjs'
,
[
'genproto_commonjs'
,
'dist'
],
function
(
cb
)
{
exec
(
'JASMINE_CONFIG_PATH=jasmine.json cp jasmine_commonjs.json commonjs_out/jasmine.json && cd commonjs_out && ../node_modules/.bin/jasmine'
,
function
(
err
,
stdout
,
stderr
)
{
console
.
log
(
stdout
);
console
.
log
(
stderr
);
cb
(
err
);
});
});
js/jasmine_commonjs.json
0 → 100644
View file @
55cc3aa9
{
"spec_dir"
:
""
,
"spec_files"
:
[
"*_test.js"
],
"helpers"
:
[
"node_modules/google-closure-library/closure/goog/bootstrap/nodejs.js"
,
"node_loader.js"
,
"deps.js"
]
}
js/package.json
View file @
55cc3aa9
...
@@ -2,13 +2,15 @@
...
@@ -2,13 +2,15 @@
"name"
:
"google-protobuf"
,
"name"
:
"google-protobuf"
,
"version"
:
"3.0.0-alpha.5"
,
"version"
:
"3.0.0-alpha.5"
,
"description"
:
"Protocol Buffers for JavaScript"
,
"description"
:
"Protocol Buffers for JavaScript"
,
"main"
:
"
debug
.js"
,
"main"
:
"
google-protobuf
.js"
,
"dependencies"
:
{
"dependencies"
:
{
"google-closure-library"
:
"~20160125.0.0"
,
"google-closure-library"
:
"~20160125.0.0"
,
"gulp"
:
"~3.9.0"
,
"gulp"
:
"~3.9.0"
,
"jasmine"
:
"~2.4.1"
"jasmine"
:
"~2.4.1"
},
},
"devDependencies"
:
{},
"devDependencies"
:
{
"google-closure-compiler"
:
"~20151216.2.0"
},
"scripts"
:
{
"scripts"
:
{
"test"
:
"./node_modules/gulp/bin/gulp.js test"
"test"
:
"./node_modules/gulp/bin/gulp.js test"
},
},
...
...
src/google/protobuf/compiler/js/js_generator.cc
View file @
55cc3aa9
This diff is collapsed.
Click to expand it.
src/google/protobuf/compiler/js/js_generator.h
View file @
55cc3aa9
...
@@ -67,6 +67,13 @@ struct GeneratorOptions {
...
@@ -67,6 +67,13 @@ struct GeneratorOptions {
bool
error_on_name_conflict
;
bool
error_on_name_conflict
;
// Enable binary-format support?
// Enable binary-format support?
bool
binary
;
bool
binary
;
// What style of imports should be used.
enum
ImportStyle
{
IMPORT_CLOSURE
,
// goog.require()
IMPORT_COMMONJS
,
// require()
IMPORT_BROWSER
,
// no import statements
IMPORT_ES6
,
// import { member } from ''
}
import_style
;
GeneratorOptions
()
GeneratorOptions
()
:
add_require_for_enums
(
false
),
:
add_require_for_enums
(
false
),
...
@@ -75,7 +82,8 @@ struct GeneratorOptions {
...
@@ -75,7 +82,8 @@ struct GeneratorOptions {
namespace_prefix
(
""
),
namespace_prefix
(
""
),
library
(
""
),
library
(
""
),
error_on_name_conflict
(
false
),
error_on_name_conflict
(
false
),
binary
(
false
)
{}
binary
(
false
),
import_style
(
IMPORT_CLOSURE
)
{}
bool
ParseFromOptions
(
bool
ParseFromOptions
(
const
vector
<
pair
<
string
,
string
>
>&
options
,
const
vector
<
pair
<
string
,
string
>
>&
options
,
...
@@ -111,6 +119,10 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
...
@@ -111,6 +119,10 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
io
::
Printer
*
printer
,
io
::
Printer
*
printer
,
const
vector
<
const
FileDescriptor
*>&
file
,
const
vector
<
const
FileDescriptor
*>&
file
,
std
::
set
<
string
>*
provided
)
const
;
std
::
set
<
string
>*
provided
)
const
;
void
FindProvidesForFile
(
const
GeneratorOptions
&
options
,
io
::
Printer
*
printer
,
const
FileDescriptor
*
file
,
std
::
set
<
string
>*
provided
)
const
;
void
FindProvidesForMessage
(
const
GeneratorOptions
&
options
,
void
FindProvidesForMessage
(
const
GeneratorOptions
&
options
,
io
::
Printer
*
printer
,
io
::
Printer
*
printer
,
const
Descriptor
*
desc
,
const
Descriptor
*
desc
,
...
@@ -168,6 +180,10 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
...
@@ -168,6 +180,10 @@ class LIBPROTOC_EXPORT Generator : public CodeGenerator {
std
::
set
<
string
>*
required
,
std
::
set
<
string
>*
required
,
std
::
set
<
string
>*
forwards
)
const
;
std
::
set
<
string
>*
forwards
)
const
;
void
GenerateFile
(
const
GeneratorOptions
&
options
,
io
::
Printer
*
printer
,
const
FileDescriptor
*
file
)
const
;
// Generate definitions for all message classes and enums in all files,
// Generate definitions for all message classes and enums in all files,
// processing the files in dependence order.
// processing the files in dependence order.
void
GenerateFilesInDepOrder
(
const
GeneratorOptions
&
options
,
void
GenerateFilesInDepOrder
(
const
GeneratorOptions
&
options
,
...
...
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