Changeset View
Changeset View
Standalone View
Standalone View
rust/hgcli/pyoxidizer.bzl
ROOT = CWD + "/../.." | ROOT = CWD + "/../.." | ||||
IS_WINDOWS = "windows" in BUILD_TARGET_TRIPLE | IS_WINDOWS = "windows" in BUILD_TARGET_TRIPLE | ||||
# Code to run in Python interpreter. | # Code to run in Python interpreter. | ||||
RUN_CODE = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()" | RUN_CODE = "import hgdemandimport; hgdemandimport.enable(); from mercurial import dispatch; dispatch.run()" | ||||
set_build_path(ROOT + "/build/pyoxidizer") | set_build_path(ROOT + "/build/pyoxidizer") | ||||
def make_distribution(): | def make_distribution(): | ||||
return default_python_distribution(python_version = "3.8") | return default_python_distribution(python_version = "3.8") | ||||
def make_distribution_windows(): | |||||
return default_python_distribution(flavor = "standalone_dynamic") | |||||
def resource_callback(policy, resource): | def resource_callback(policy, resource): | ||||
if not IS_WINDOWS: | if not IS_WINDOWS: | ||||
resource.add_location = "in-memory" | resource.add_location = "in-memory" | ||||
return | return | ||||
# We use a custom resource routing policy to influence where things are loaded | # We use a custom resource routing policy to influence where things are loaded | ||||
# from. | # from. | ||||
# | # | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | def make_exe(dist): | ||||
return exe | return exe | ||||
def make_manifest(dist, exe): | def make_manifest(dist, exe): | ||||
m = FileManifest() | m = FileManifest() | ||||
m.add_python_resource(".", exe) | m.add_python_resource(".", exe) | ||||
return m | return m | ||||
def make_embedded_resources(exe): | register_target("distribution", make_distribution) | ||||
return exe.to_embedded_resources() | register_target("exe", make_exe, depends = ["distribution"]) | ||||
register_target("app", make_manifest, depends = ["distribution", "exe"], default = True) | |||||
register_target("distribution_posix", make_distribution) | |||||
register_target("distribution_windows", make_distribution_windows) | |||||
register_target("exe_posix", make_exe, depends = ["distribution_posix"]) | |||||
register_target("exe_windows", make_exe, depends = ["distribution_windows"]) | |||||
register_target( | |||||
"app_posix", | |||||
make_manifest, | |||||
depends = ["distribution_posix", "exe_posix"], | |||||
default = "windows" not in BUILD_TARGET_TRIPLE, | |||||
) | |||||
register_target( | |||||
"app_windows", | |||||
make_manifest, | |||||
depends = ["distribution_windows", "exe_windows"], | |||||
default = "windows" in BUILD_TARGET_TRIPLE, | |||||
) | |||||
resolve_targets() | resolve_targets() |