blob: 8b7030075acc52f47b62b1eea1bb70efe7d1654d [file] [log] [blame]
#!/usr/bin/env python3
import sys
import os
import os.path
# PEP 366 package name setting to allow relative imports in Python 3
if __name__ == "__main__" and __package__ is None:
nanopb_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, nanopb_dir)
import generator
__package__ = str("generator")
from .proto._utils import invoke_protoc
if __name__ == '__main__':
# Add argument so that protoc-gen-nanopb gets found
if getattr(sys, 'frozen', False):
mypath = os.path.dirname(sys.executable) # For pyInstaller
mypath = os.path.dirname(__file__)
if os.path.isfile(os.path.join(mypath, "protoc-gen-nanopb.exe")):
protoc_gen_nanopb = os.path.join(mypath, "protoc-gen-nanopb.exe")
elif == 'nt':
protoc_gen_nanopb = os.path.join(mypath, "protoc-gen-nanopb.bat")
protoc_gen_nanopb = os.path.join(mypath, "protoc-gen-nanopb")
args = sys.argv[1:]
if os.path.isfile(protoc_gen_nanopb):
args = ['--plugin=protoc-gen-nanopb=%s' % protoc_gen_nanopb] + args
status = invoke_protoc(['protoc'] + args)