mirror of
https://github.com/google/pebble.git
synced 2025-08-18 04:16:32 -04:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
39
third_party/nanopb/generator/protoc
vendored
Executable file
39
third_party/nanopb/generator/protoc
vendored
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env python3
|
||||
# This file acts as a drop-in replacement of binary protoc.exe.
|
||||
# It will use either Python-based protoc from grpcio-tools package,
|
||||
# or if it is not available, protoc.exe from path if found.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
from nanopb_generator import invoke_protoc
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Get path of the directory where this script is stored.
|
||||
if getattr(sys, 'frozen', False):
|
||||
mypath = os.path.dirname(sys.executable) # For pyInstaller
|
||||
else:
|
||||
mypath = os.path.dirname(__file__)
|
||||
|
||||
# Avoid recursive calls to self
|
||||
env_paths = os.environ["PATH"].split(os.pathsep)
|
||||
if mypath in env_paths:
|
||||
env_paths.remove(mypath)
|
||||
os.environ["PATH"] = os.pathsep.join(env_paths)
|
||||
|
||||
# Add argument for finding the nanopb generator when using --nanopb_out=
|
||||
# argument to protoc.
|
||||
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")
|
||||
|
||||
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)
|
||||
sys.exit(status)
|
Loading…
Add table
Add a link
Reference in a new issue