Files
ce_cdm/cdm/create_cert_cc.py
John "Juce" Bruce f11df1e144 Source release 17.1.1
2022-11-29 12:54:04 -08:00

35 lines
1.0 KiB
Python
Executable File

#!/usr/bin/python3
# Copyright 2022 Google LLC. All Rights Reserved. This file and proprietary
# source code may only be used and distributed under the Widevine License
# Agreement.
"""Creates a cert.cc file from a cert.bin file."""
import argparse
import pathlib
import sys
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('input')
parser.add_argument('output')
parser.add_argument('--variable', default='DeviceCert')
options = parser.parse_args(sys.argv[1:])
in_path = pathlib.Path(options.input)
dat = ', '.join(str(x) for x in in_path.read_bytes())
out_path = pathlib.Path(options.output)
out_path.write_text(f"""// Copyright 2021 Google LLC. All Rights Reserved.
#include <stdint.h>
#include <stddef.h>
namespace widevine {{
extern const uint8_t k{options.variable}[];
const uint8_t k{options.variable}[] = {{ {dat} }};
extern const size_t k{options.variable}Size;
const size_t k{options.variable}Size = sizeof(k{options.variable});
}} // namespace widevine""")