Add verbosity to protogen

This commit is contained in:
Sebastien L
2022-01-04 17:12:51 -05:00
parent e5516db60f
commit 3a99c65eb3
2 changed files with 11 additions and 8 deletions

View File

@@ -7,22 +7,25 @@ from nanopb_generator import invoke_protoc
if __name__ == '__main__':
# Add argument so that protoc-gen-nanopb gets found
print("Getting path to protoc-gen-nanopb")
if getattr(sys, 'frozen', False):
mypath = os.path.dirname(sys.executable) # For pyInstaller
else:
mypath = os.path.dirname(__file__)
print("Looking for executable file name")
if os.path.isfile(os.path.join(mypath, "protoc-gen-nanopb.exe")):
protoc_gen_nanopb = os.path.join(mypath, "protoc-gen-nanopb.exe")
elif os.name == 'nt':
protoc_gen_nanopb = os.path.join(mypath, "protoc-gen-nanopb.bat")
else:
protoc_gen_nanopb = os.path.join(mypath, "protoc-gen-nanopb")
print("Found executable file name: " + protoc_gen_nanopb)
args = sys.argv[1:]
if os.path.isfile(protoc_gen_nanopb):
args = ['--plugin=protoc-gen-nanopb=%s' % protoc_gen_nanopb] + args
# print the command line that we are about to execute
print("invoking protoc with parameters: ".join(args))
status = invoke_protoc(['protoc'] + args)
sys.exit(status)