|
29 | 29 |
|
30 | 30 | """
|
31 | 31 |
|
| 32 | +import argparse |
32 | 33 | import utils
|
33 | 34 |
|
34 | 35 | def main():
|
35 |
| - # Install protobuf on linux/mac if its not installed already |
36 |
| - if not utils.is_command_installed('protoc'): |
37 |
| - if utils.is_linux_os(): |
38 |
| - # sudo apt install protobuf-compiler |
39 |
| - utils.run_command(['apt', 'install', '-y','protobuf-compiler'], as_root=True) |
40 |
| - elif utils.is_mac_os(): |
41 |
| - # brew install protobuf |
42 |
| - utils.run_command(['brew', 'install', 'protobuf']) |
43 |
| - |
44 |
| - # Install go on linux/mac if its not installed already |
45 |
| - if not utils.is_command_installed('go'): |
46 |
| - if utils.is_linux_os(): |
47 |
| - # sudo apt install -y golang |
48 |
| - utils.run_command(['apt', 'install', '-y','golang'], as_root=True) |
49 |
| - elif utils.is_mac_os(): |
50 |
| - # brew install protobuf |
51 |
| - utils.run_command(['brew', 'install', 'go']) |
52 |
| - |
53 |
| - # Install openssl on linux/mac if its not installed already |
54 |
| - if not utils.is_command_installed('go'): |
55 |
| - if utils.is_linux_os(): |
56 |
| - # sudo apt install -y openssl |
57 |
| - utils.run_command(['apt', 'install', '-y','openssl'], as_root=True) |
58 |
| - elif utils.is_mac_os(): |
59 |
| - # brew install protobuf |
60 |
| - utils.run_command(['brew', 'install', 'openssl']) |
61 |
| - |
62 |
| - # Install ccache on linux/mac if its not installed already |
63 |
| - if not utils.is_command_installed('ccache'): |
64 |
| - if utils.is_linux_os(): |
65 |
| - # sudo apt install ccache |
66 |
| - utils.run_command(['apt', 'install', '-y', 'ccache'], as_root=True) |
67 |
| - elif utils.is_mac_os(): |
68 |
| - # brew install ccache |
69 |
| - utils.run_command(['brew', 'install', 'ccache']) |
70 |
| - |
71 |
| - # Install clang-format on linux/mac if its not installed already |
72 |
| - if not utils.is_command_installed('clang-format'): |
73 |
| - if utils.is_linux_os(): |
74 |
| - # sudo apt install clang-format |
75 |
| - utils.run_command(['apt', 'install', '-y','clang-format'], as_root=True) |
76 |
| - elif utils.is_mac_os(): |
77 |
| - # brew install protobuf |
78 |
| - utils.run_command(['brew', 'install', 'clang-format']) |
79 |
| - |
80 |
| - # Install required python dependencies. |
81 |
| - # On Catalina, python2 in installed as default python. |
82 |
| - # Example command: |
83 |
| - # python3 -m pip install -r external/pip_requirements.txt --user |
84 |
| - utils.run_command( |
85 |
| - ['python3' if utils.is_command_installed('python3') else 'python', '-m', |
86 |
| - 'pip', 'install', '-r', 'external/pip_requirements.txt', '--user'] ) |
| 36 | + args = parse_cmdline_args() |
87 | 37 |
|
| 38 | + if not args.running_only: |
| 39 | + # Install protobuf on linux/mac if its not installed already |
| 40 | + if not utils.is_command_installed('protoc'): |
| 41 | + if utils.is_linux_os(): |
| 42 | + # sudo apt install protobuf-compiler |
| 43 | + utils.run_command(['apt', 'install', '-y','protobuf-compiler'], as_root=True) |
| 44 | + elif utils.is_mac_os(): |
| 45 | + # brew install protobuf |
| 46 | + utils.run_command(['brew', 'install', 'protobuf']) |
| 47 | + |
| 48 | + # Install go on linux/mac if its not installed already |
| 49 | + if not utils.is_command_installed('go'): |
| 50 | + if utils.is_linux_os(): |
| 51 | + # sudo apt install -y golang |
| 52 | + utils.run_command(['apt', 'install', '-y','golang'], as_root=True) |
| 53 | + elif utils.is_mac_os(): |
| 54 | + # brew install go |
| 55 | + utils.run_command(['brew', 'install', 'go']) |
| 56 | + |
| 57 | + # Install openssl on linux/mac if its not installed already |
| 58 | + if args.ssl == 'openssl' and not utils.is_command_installed('openssl'): |
| 59 | + if utils.is_linux_os(): |
| 60 | + # sudo apt install -y openssl |
| 61 | + utils.run_command(['apt', 'install', '-y','openssl'], as_root=True) |
| 62 | + elif utils.is_mac_os(): |
| 63 | + # brew install openssl |
| 64 | + utils.run_command(['brew', 'install', 'openssl']) |
| 65 | + |
| 66 | + # Install ccache on linux/mac if its not installed already |
| 67 | + if not utils.is_command_installed('ccache'): |
| 68 | + if utils.is_linux_os(): |
| 69 | + # sudo apt install ccache |
| 70 | + utils.run_command(['apt', 'install', '-y', 'ccache'], as_root=True) |
| 71 | + elif utils.is_mac_os(): |
| 72 | + # brew install ccache |
| 73 | + utils.run_command(['brew', 'install', 'ccache']) |
| 74 | + |
| 75 | + # Install clang-format on linux/mac if its not installed already |
| 76 | + if not utils.is_command_installed('clang-format'): |
| 77 | + if utils.is_linux_os(): |
| 78 | + # sudo apt install clang-format |
| 79 | + utils.run_command(['apt', 'install', '-y','clang-format'], as_root=True) |
| 80 | + elif utils.is_mac_os(): |
| 81 | + # brew install protobuf |
| 82 | + utils.run_command(['brew', 'install', 'clang-format']) |
| 83 | + |
| 84 | + # Install required python dependencies. |
| 85 | + # On Catalina, python2 in installed as default python. |
| 86 | + # Example command: |
| 87 | + # python3 -m pip install -r external/pip_requirements.txt --user |
| 88 | + utils.run_command( |
| 89 | + ['python3' if utils.is_command_installed('python3') else 'python', '-m', |
| 90 | + 'pip', 'install', '-r', 'external/pip_requirements.txt', '--user'] ) |
| 91 | + |
| 92 | + if args.arch == 'x86': |
| 93 | + utils.install_x86_support_libraries(args.gha_build) |
| 94 | + |
| 95 | +def parse_cmdline_args(): |
| 96 | + parser = argparse.ArgumentParser(description='Install prerequisites for building cpp sdk') |
| 97 | + parser.add_argument('--arch', default=None, help='Install support libraries to build a specific architecture (currently supported: x86)') |
| 98 | + parser.add_argument('--running_only', action='store_true', help='Only install prerequisites for running, not for building') |
| 99 | + parser.add_argument('--gha_build', action='store_true', default=None, help='Set this option when building on GitHub, changing some prerequisite installation behavior') |
| 100 | + parser.add_argument('--ssl', default='openssl', help='Which SSL is this build using (supported: openssl, boringssl)') |
| 101 | + args = parser.parse_args() |
| 102 | + return args |
88 | 103 |
|
89 | 104 | if __name__ == '__main__':
|
90 | 105 | main()
|
0 commit comments