22#
33# See also code generation logic under generator/
44
5+ load ("@rules_pkg//:mappings.bzl" , "pkg_attributes" , "pkg_files" , "strip_prefix" )
6+ load ("@rules_pkg//:pkg.bzl" , "pkg_tar" , "pkg_zip" )
7+ load ("//:protobuf_javascript_release.bzl" , "package_naming" )
8+
59config_setting (
610 name = "x64_x86_windows" ,
711 values = {"cpu" : "x64_x86_windows" },
@@ -27,38 +31,65 @@ config_setting(
2731 values = {"cpu" : "darwin_x86_64" },
2832)
2933
30- filegroup (
31- name = "javascript" ,
34+ package_naming (
35+ name = "protobuf_javascript_pkg_naming" ,
36+ platform = select ({
37+ ":k8" : "linux-x86_64" , # currently the only supported build type in Github Actions
38+ ":x64_x86_windows" : "win32" ,
39+ ":x64_windows" : "win64" ,
40+ ":darwin_arm64" : "osx-aarch_64" ,
41+ ":darwin_x86_64" : "osx-x86_64" ,
42+ "//conditions:default" : "" # continues with current behavior when no --cpu is specified allowing existing internal builds to function
43+ })
44+ )
45+
46+ pkg_files (
47+ name = "plugin_files" ,
48+ srcs = ["//generator:protoc-gen-js" ],
49+ attributes = pkg_attributes (mode = "0555" ),
50+ prefix = "bin/" ,
51+ )
52+
53+ pkg_files (
54+ name = "dist_files" ,
55+ srcs = glob ([
56+ "google/protobuf/*.js" ,
57+ "google/protobuf/compiler/*.js"
58+ ]) + [
59+ "google-protobuf.js" ,
60+ "package.json" ,
61+ "README.md" ,
62+ "LICENSE.md" ,
63+ "LICENSE-asserts.md" ,
64+ ],
65+ strip_prefix = strip_prefix .from_root ("" ),
66+ )
67+
68+ pkg_tar (
69+ name = "dist_tar" ,
3270 srcs = [
33- "asserts.js" ,
34- "binary/any_field_type.js" ,
35- "binary/arith.js" ,
36- "binary/binary_constants.js" ,
37- "binary/bytesource.js" ,
38- "binary/bytesource_alias.js" ,
39- "binary/decoder.js" ,
40- "binary/decoder_alias.js" ,
41- "binary/encoder.js" ,
42- "binary/encoder_alias.js" ,
43- "binary/errors.js" ,
44- "binary/internal_buffer.js" ,
45- "binary/reader.js" ,
46- "binary/reader_alias.js" ,
47- "binary/repeated_field_type.js" ,
48- "binary/scalar_field_type.js" ,
49- "binary/test_utils.js" ,
50- "binary/utf8.js" ,
51- "binary/utils.js" ,
52- "binary/writer.js" ,
53- "binary/writer_alias.js" ,
54- "bytestring.js" ,
55- "debug.js" ,
56- "internal_bytes.js" ,
57- "internal_options.js" ,
58- "internal_public.js" ,
59- "map.js" ,
60- "message.js" ,
61- "unsafe_bytestring.js" ,
71+ ":dist_files" ,
72+ ":plugin_files" ,
6273 ],
63- visibility = ["//visibility:public" ],
74+ extension = "tar.gz" ,
75+ package_file_name = "protobuf-javascript-{version}-{platform}.tar.gz" ,
76+ package_variables = ":protobuf_javascript_pkg_naming" ,
77+ )
78+
79+ pkg_zip (
80+ name = "dist_zip" ,
81+ srcs = [
82+ ":dist_files" ,
83+ ":plugin_files" ,
84+ ],
85+ package_file_name = "protobuf-javascript-{version}-{platform}.zip" ,
86+ package_variables = ":protobuf_javascript_pkg_naming" ,
87+ )
88+
89+ filegroup (
90+ name = "dist_all" ,
91+ srcs = [
92+ ":dist_tar" ,
93+ ":dist_zip" ,
94+ ]
6495)
0 commit comments