rust/hgcli/pyoxidizer.bzl
changeset 44822 118f067f6bd1
parent 44763 94f4f2ec7dee
child 45685 57b5452a55d5
equal deleted inserted replaced
44810:62435a5b46fe 44822:118f067f6bd1
     1 ROOT = CWD + "/../.."
     1 ROOT = CWD + "/../.."
     2 
     2 
     3 # Code to run in Python interpreter.
     3 # Code to run in Python interpreter.
     4 RUN_CODE = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()"
     4 RUN_CODE = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()"
     5 
     5 
     6 
       
     7 set_build_path(ROOT + "/build/pyoxidizer")
     6 set_build_path(ROOT + "/build/pyoxidizer")
     8 
       
     9 
     7 
    10 def make_distribution():
     8 def make_distribution():
    11     return default_python_distribution()
     9     return default_python_distribution()
    12 
    10 
    13 
       
    14 def make_distribution_windows():
    11 def make_distribution_windows():
    15     return default_python_distribution(flavor="standalone_dynamic")
    12     return default_python_distribution(flavor = "standalone_dynamic")
    16 
       
    17 
    13 
    18 def make_exe(dist):
    14 def make_exe(dist):
       
    15     """Builds a Rust-wrapped Mercurial binary."""
    19     config = PythonInterpreterConfig(
    16     config = PythonInterpreterConfig(
    20         raw_allocator = "system",
    17         raw_allocator = "system",
    21         run_eval = RUN_CODE,
    18         run_eval = RUN_CODE,
    22         # We want to let the user load extensions from the file system
    19         # We want to let the user load extensions from the file system
    23         filesystem_importer = True,
    20         filesystem_importer = True,
    56             exe.add_python_resource(resource)
    53             exe.add_python_resource(resource)
    57 
    54 
    58     # On Windows, we install extra packages for convenience.
    55     # On Windows, we install extra packages for convenience.
    59     if "windows" in BUILD_TARGET_TRIPLE:
    56     if "windows" in BUILD_TARGET_TRIPLE:
    60         exe.add_python_resources(
    57         exe.add_python_resources(
    61             dist.pip_install(["-r", ROOT + "/contrib/packaging/requirements_win32.txt"])
    58             dist.pip_install(["-r", ROOT + "/contrib/packaging/requirements_win32.txt"]),
    62         )
    59         )
    63 
    60 
    64     return exe
    61     return exe
    65 
       
    66 
    62 
    67 def make_manifest(dist, exe):
    63 def make_manifest(dist, exe):
    68     m = FileManifest()
    64     m = FileManifest()
    69     m.add_python_resource(".", exe)
    65     m.add_python_resource(".", exe)
    70 
    66 
    71     return m
    67     return m
    72 
    68 
    73 
       
    74 def make_embedded_resources(exe):
    69 def make_embedded_resources(exe):
    75     return exe.to_embedded_resources()
    70     return exe.to_embedded_resources()
    76 
       
    77 
    71 
    78 register_target("distribution_posix", make_distribution)
    72 register_target("distribution_posix", make_distribution)
    79 register_target("distribution_windows", make_distribution_windows)
    73 register_target("distribution_windows", make_distribution_windows)
    80 
    74 
    81 register_target("exe_posix", make_exe, depends = ["distribution_posix"])
    75 register_target("exe_posix", make_exe, depends = ["distribution_posix"])