Skip to content

bzlmod support #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel
# https://github.com/protocolbuffers/protobuf/issues/14313
common --noenable_bzlmod
common --enable_bzlmod
4 changes: 2 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pkg_files(
name = "dist_files",
srcs = glob([
"google/protobuf/*.js",
"google/protobuf/compiler/*.js"
"google/protobuf/compiler/*.js",
]) + [
"google-protobuf.js",
"package.json",
Expand Down Expand Up @@ -58,5 +58,5 @@ filegroup(
srcs = [
":dist_tar",
":dist_zip",
]
],
)
21 changes: 19 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
module(name = "protobuf_javascript_gonzojive", version = "3.21.5")
module(
name = "protobuf_javascript_gonzojive",
version = "3.21.5",
)

bazel_dep(name = "protobuf", version = "27.1", repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
bazel_dep(name = "abseil-cpp", version = "20211102.0")
bazel_dep(name = "rules_pkg", version = "0.7.0")

# For VS Code autocompletion:
# https://github.com/hedronvision/bazel-compile-commands-extractor#usage
#
# Not currently working due to https://github.com/hedronvision/bazel-compile-commands-extractor/issues/199
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
git_override(
module_name = "hedron_compile_commands",
commit = "0e990032f3c5a866e72615cf67e5ce22186dcb97",
remote = "https://github.com/hedronvision/bazel-compile-commands-extractor.git",
# Replace the commit hash (above) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main).
# Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
)
110 changes: 110 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion generator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ cc_binary(
],
visibility = ["//visibility:public"],
deps = [
"@abseil-cpp//absl/strings:str_format",
"@com_google_protobuf//:protobuf",
"@com_google_protobuf//:protoc_lib",
],
)

12 changes: 6 additions & 6 deletions generator/js_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/stringprintf.h>
#include "absl/strings/str_format.h"
#include <google/protobuf/stubs/strutil.h>

#include <algorithm>
Expand Down Expand Up @@ -679,9 +679,9 @@ bool EscapeJSString(const std::string& in, std::string* out) {
if (codepoint >= 0x20 && codepoint <= 0x7e) {
*out += static_cast<char>(codepoint);
} else if (codepoint >= 0x100) {
*out += StringPrintf("\\u%04x", codepoint);
*out += absl::StrFormat("\\u%04x", codepoint);
} else {
*out += StringPrintf("\\x%02x", codepoint);
*out += absl::StrFormat("\\x%02x", codepoint);
}
break;
}
Expand Down Expand Up @@ -1276,7 +1276,7 @@ std::string FieldDefinition(const GeneratorOptions& options,
} else {
value_type = ProtoTypeName(options, value_field);
}
return StringPrintf("map<%s, %s> %s = %d;", key_type.c_str(),
return absl::StrFormat("map<%s, %s> %s = %d;", key_type.c_str(),
value_type.c_str(), field->name().c_str(),
field->number());
} else {
Expand All @@ -1295,7 +1295,7 @@ std::string FieldDefinition(const GeneratorOptions& options,
type = ProtoTypeName(options, field);
name = field->name();
}
return StringPrintf("%s %s %s = %d;", qualifier.c_str(), type.c_str(),
return absl::StrFormat("%s %s %s = %d;", qualifier.c_str(), type.c_str(),
name.c_str(), field->number());
}
}
Expand Down Expand Up @@ -3676,7 +3676,7 @@ void Generator::GenerateExtension(const GeneratorOptions& options,
" * @type {!jspb.ExtensionFieldInfo<$extensionType$>}\n"
" */\n"
"$class$.$name$ = new jspb.ExtensionFieldInfo(\n",
"class", extension_scope_name, "name", extension_object_field_name, "extensionType",
"class", extension_scope_name, "name", extension_object_field_name, "extensionType",
JSFieldTypeAnnotation(options, field,
/* is_setter_argument = */ false,
/* force_present = */ true,
Expand Down
Loading