Skip to content
Snippets Groups Projects
Commit 6e369cc8 authored by Christoph.Fischer's avatar Christoph.Fischer
Browse files

fix in windows compilation

parent b72c93c6
No related branches found
No related tags found
No related merge requests found
......@@ -24,10 +24,10 @@ python_out = os.path.join(working_dir, '_proto_gen')
for path in proto_files_g:
path_dir = os.path.dirname(path)
if path_dir.endswith("/feature/identification"):
if path.parts[-3:] == ('feature', 'identification', 'identification.proto'):
id_path_dir = path_dir
id_path = id_path_dir + "/identification.proto"
id_path = os.path.join(id_path_dir, "identification.proto")
if not os.path.exists(id_path):
print("Could not find identification.proto main file.")
......@@ -49,7 +49,7 @@ for path in proto_files_g:
# merge path_dir and id_path_dir files (Properties by method and base file)
# wish there was an easier solution
# create temporal file to merge them, compile, and delete at end
with tempfile.NamedTemporaryFile() as tmp:
with tempfile.NamedTemporaryFile(delete=False) as tmp:
files = [path, id_path]
for fname in files:
......@@ -60,14 +60,17 @@ for path in proto_files_g:
protoc_command = [protoc, '-I=' + os.path.dirname(tmp.name), '--python_out=' + python_out, tmp.name]
print("Execute protoc for: " + str(path))
if subprocess.call(protoc_command) != 0:
sys.exit(1)
num_compied_files += 1
# need to call protoc outside (for windows compatibility), otherwise protoc cant access file.
if subprocess.call(protoc_command) != 0:
sys.exit(1)
num_compied_files += 1
os.rename(
os.rename(
os.path.join(python_out, os.path.basename(tmp.name)) + "_pb2.py",
os.path.join(python_out + "/" + os.path.basename(path)[:-6]) + "_pb2.py"
)
# delete temp now
os.remove(tmp.name)
if num_compied_files:
print("Compiled " + str(num_compied_files) + " proto files.")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment