nectar/build-release.py
2024-01-15 19:51:07 -03:00

43 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python3
import os
import shutil
import subprocess
def build_and_move(feature, tmp_dir):
print("\n" + "=" * 50)
print(f"BUILDING {feature if feature else 'default'}")
print("=" * 50 + "\n")
if feature:
subprocess.run(["cargo", "+nightly", "build", "--release", "--features", feature], check=True)
binary_name = f"kinode-{feature}"
else:
subprocess.run(["cargo", "+nightly", "build", "--release"], check=True)
binary_name = "kinode"
# Move and rename the binary
source_path = "target/release/kinode"
dest_path = os.path.join(tmp_dir, binary_name)
shutil.move(source_path, dest_path)
def main():
# Features to compile with
features = ["", "simulation-mode"] # Add more features as needed
# Ensure the tmp directory is clean
tmp_dir = "/tmp/kinode-release"
if os.path.exists(tmp_dir):
shutil.rmtree(tmp_dir)
os.makedirs(tmp_dir)
# Loop through the features and build
for feature in features:
build_and_move(feature, tmp_dir)
print(f"Build and move process completed.\nFind release in {tmp_dir}.")
if __name__ == "__main__":
main()