22from build .utils import filenamesmatchingof , collectattrs
33from os .path import join , abspath , dirname , relpath
44from build .pkg import has_package
5+ import platform
56
67G .setdefault ("PROTOC" , "protoc" )
78G .setdefault ("HOSTPROTOC" , "hostprotoc" )
89
910assert has_package ("protobuf" ), "required package 'protobuf' not installed"
1011
12+ PROTO_SEPARATOR = ";" if (platform .system () == "Windows" ) else ":"
1113
1214def _getprotodeps (deps ):
1315 r = set ()
@@ -19,7 +21,7 @@ def _getprotodeps(deps):
1921@Rule
2022def proto (self , name , srcs : Targets = [], deps : Targets = []):
2123 protodeps = _getprotodeps (deps )
22- descriptorlist = ":" .join (
24+ descriptorlist = PROTO_SEPARATOR .join (
2325 [
2426 relpath (f , start = self .dir )
2527 for f in filenamesmatchingof (protodeps , "*.descriptor" )
@@ -46,7 +48,7 @@ def proto(self, name, srcs: Targets = [], deps: Targets = []):
4648 f"--descriptor_set_out={ self .localname } .descriptor" ,
4749 ]
4850 + (
49- [f"--descriptor_set_in={ descriptorlist } " ]
51+ [f"--descriptor_set_in=' { descriptorlist } ' " ]
5052 if descriptorlist
5153 else []
5254 )
@@ -89,7 +91,7 @@ def protocc(self, name, srcs: Targets = [], deps: Targets = []):
8991 outs += ["=" + cc , "=" + h ]
9092
9193 protodeps = _getprotodeps (deps + srcs )
92- descriptorlist = ":" .join (
94+ descriptorlist = PROTO_SEPARATOR .join (
9395 [
9496 relpath (f , start = self .dir )
9597 for f in filenamesmatchingof (protodeps , "*.descriptor" )
@@ -110,7 +112,7 @@ def protocc(self, name, srcs: Targets = [], deps: Targets = []):
110112 "$(PROTOC)" ,
111113 "--proto_path=." ,
112114 "--cpp_out=." ,
113- f"--descriptor_set_in={ descriptorlist } " ,
115+ f"--descriptor_set_in=' { descriptorlist } ' " ,
114116 ]
115117 + protos
116118 )
@@ -142,7 +144,7 @@ def protojava(self, name, srcs: Targets = [], deps: Targets = []):
142144 protos += [f ]
143145 srcs += [f ]
144146
145- descriptorlist = ":" .join (
147+ descriptorlist = PROTO_SEPARATOR .join (
146148 [abspath (f ) for f in filenamesmatchingof (srcs + deps , "*.descriptor" )]
147149 )
148150
@@ -161,7 +163,7 @@ def protojava(self, name, srcs: Targets = [], deps: Targets = []):
161163 "$(PROTOC)" ,
162164 "--proto_path=." ,
163165 "--java_out=." ,
164- f"--descriptor_set_in={ descriptorlist } " ,
166+ f"--descriptor_set_in=' { descriptorlist } ' " ,
165167 ]
166168 + protos
167169 )
0 commit comments