Add a few opts to build_openssl_win.py

This commit is contained in:
John Colvin committed 2022-02-23 14:16:38 -05:00
1 parent 5887b409a2
commit 1dffb78a8e
1 file changed
+75 -11
+75 -11
View File
@@ -1,3 +1,4 @@
import argparse
import os
import shutil
import subprocess
@@ -57,12 +58,72 @@ def install_release(build_dir, target_dir):
os.path.join(build_dir, 'include', 'openssl'), target_include_dir)
def add_toggle_opt(parser: argparse.ArgumentParser, name, **kwargs):
parser.add_argument(f'--{name}', action=f'store_true', dest=name, **kwargs)
parser.add_argument(f'--no-{name}', action=f'store_false', dest=name)
return parser
def get_arg(args, name, value_or=None):
if name in args:
return args[name]
return value_or
def _get_arg_parser():
parser = argparse.ArgumentParser(description='Build openssl for windows')
parser.add_argument(
'--configuration',
metavar='debug|release',
type=str,
nargs='?',
help='The build configuration',
default='Debug')
parser.add_argument(
'-o',
'--output-dir',
metavar='path',
type=str,
nargs='?',
help='The directory in which to build')
add_toggle_opt(
parser,
'clean',
help=
'Whether or not to delete and overwrite an existing build directory')
parser.set_defaults(clean=True)
return parser
def _main():
parser = _get_arg_parser()
args = parser.parse_args()
args_dict = vars(args)
openssl_dirname = "openssl-1_1_1"
externals_root_dir = os.path.abspath("../..")
openssl_zip_path = os.path.join(
externals_root_dir, 'src', 'openssl', f'{openssl_dirname}.zip')
work_dir = os.path.join(externals_root_dir, "work")
work_dir = get_arg(args_dict, 'output_dir') or os.path.join(externals_root_dir, "work")
work_dir = os.path.abspath(work_dir)
clean = args.clean
def get_configurations():
conf = get_arg(args_dict, 'configuration')
if conf is not None:
return [conf]
return ['debug', 'release']
configurations = get_configurations()
print(args_dict)
print(f'work_dir: {work_dir}')
print(f'configurations: {configurations}')
target_dir = os.path.join(externals_root_dir, "windows")
cmake_dir = os.path.join(work_dir, openssl_dirname)
@@ -74,18 +135,21 @@ def _main():
zip_ref.extractall(work_dir)
with CWD(cmake_dir):
# debug
dbg_build_dir = os.path.join(work_dir, openssl_dirname, 'build_debug')
build_debug(dbg_build_dir)
install_debug(dbg_build_dir, target_dir)
if 'debug' in configurations:
# debug
dbg_build_dir = os.path.join(work_dir, openssl_dirname, 'build_debug')
build_debug(dbg_build_dir)
install_debug(dbg_build_dir, target_dir)
# release
rel_build_dir = os.path.join(
work_dir, openssl_dirname, 'build_release')
build_release(rel_build_dir)
install_release(rel_build_dir, target_dir)
if 'release' in configurations:
# release
rel_build_dir = os.path.join(
work_dir, openssl_dirname, 'build_release')
build_release(rel_build_dir)
install_release(rel_build_dir, target_dir)
shutil.rmtree(work_dir)
if clean:
shutil.rmtree(work_dir)
if __name__ == '__main__':