Skip to content
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

experiment: changing protobuf directory to match Python package name #142

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 1 addition & 1 deletion internal/generateProto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("generateProto", () => {

syntax = "proto3";

import "foxglove/NestedMessage.proto";
import "foxglove_schemas_protobuf/NestedMessage.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

Expand Down
2 changes: 1 addition & 1 deletion internal/generateProto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function generateProto(
break;
case "nested":
qualifiers.push(`foxglove.${field.type.schema.name}`);
imports.add(`foxglove/${field.type.schema.name}`);
imports.add(`foxglove_schemas_protobuf/${field.type.schema.name}`);
break;
case "primitive":
if (field.type.name === "time") {
Expand Down
11 changes: 3 additions & 8 deletions python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,10 @@ generate-flatbuffer:
generate-protobuf:
rm -rf foxglove-schemas-protobuf/foxglove_schemas_protobuf/*_pb2*
pipenv run protoc \
--python_out=foxglove-schemas-protobuf/foxglove_schemas_protobuf \
--mypy_out=foxglove-schemas-protobuf/foxglove_schemas_protobuf \
--python_out=foxglove-schemas-protobuf \
--mypy_out=foxglove-schemas-protobuf \
--proto_path ../schemas/proto \
../schemas/proto/foxglove/*.proto
mv foxglove-schemas-protobuf/foxglove_schemas_protobuf/foxglove/* foxglove-schemas-protobuf/foxglove_schemas_protobuf
rmdir foxglove-schemas-protobuf/foxglove_schemas_protobuf/foxglove
sed -E $(SED_ARGS) 's/from foxglove import/from . import/g' foxglove-schemas-protobuf/foxglove_schemas_protobuf/*_pb2.py
sed -E $(SED_ARGS) 's/import foxglove\.(.+)$$/from . import \1 as foxglove_\1/g' foxglove-schemas-protobuf/foxglove_schemas_protobuf/*_pb2.pyi
sed -E $(SED_ARGS) 's/foxglove\./foxglove_/g' foxglove-schemas-protobuf/foxglove_schemas_protobuf/*_pb2.pyi
../schemas/proto/foxglove_schemas_protobuf/*.proto

.PHONY: build
build: pipenv generate-flatbuffer generate-protobuf
Expand Down

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

4 changes: 2 additions & 2 deletions scripts/updateGeneratedFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ async function main({ outDir, rosOutDir }: { outDir: string; rosOutDir: string }
});

await logProgress("Generating Protobuf definitions", async () => {
await fs.mkdir(path.join(outDir, "proto", "foxglove"), { recursive: true });
await fs.mkdir(path.join(outDir, "proto", "foxglove_schemas_protobuf"), { recursive: true });
for (const schema of Object.values(foxgloveMessageSchemas)) {
const enums = Object.values(foxgloveEnumSchemas).filter(
(enumSchema) => enumSchema.parentSchemaName === schema.name,
);
await fs.writeFile(
path.join(outDir, "proto", "foxglove", `${schema.name}.proto`),
path.join(outDir, "proto", "foxglove_schemas_protobuf", `${schema.name}.proto`),
generateProto(schema, enums),
);
}
Expand Down
Loading