tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

gen_ntdll_freestanding_lib.py (905B)


      1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
      2 # vim: set filetype=python:
      3 # This Source Code Form is subject to the terms of the Mozilla Public
      4 # License, v. 2.0. If a copy of the MPL was not distributed with this
      5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      6 
      7 import os
      8 import subprocess
      9 import tempfile
     10 
     11 
     12 def main(output_fd, def_file, llvm_dlltool, *llvm_dlltool_args):
     13    # llvm-dlltool can't output to stdout, so we create a temp file, use that
     14    # to write out the lib, and then copy it over to output_fd
     15    (tmp_fd, tmp_output) = tempfile.mkstemp()
     16    os.close(tmp_fd)
     17 
     18    try:
     19        cmd = [llvm_dlltool]
     20        cmd.extend(llvm_dlltool_args)
     21        cmd += ["-d", def_file, "-l", tmp_output]
     22 
     23        subprocess.check_call(cmd)
     24 
     25        with open(tmp_output, "rb") as tmplib:
     26            output_fd.write(tmplib.read())
     27    finally:
     28        os.remove(tmp_output)