- Update build-linux.yaml to use standard Ubuntu runner. - Update build-windows.yaml to use tobix/pywine container for cross-compilation on Linux. - Add build_app.py and check_ttx6.py helper scripts.
61 lines
1.6 KiB
Python
61 lines
1.6 KiB
Python
import sys
|
|
import os
|
|
import subprocess
|
|
import shutil
|
|
import platform
|
|
|
|
def clean_build_dirs():
|
|
"""Removes build and dist directories if they exist."""
|
|
for d in ["build", "dist"]:
|
|
if os.path.exists(d):
|
|
print(f"Cleaning {d}...")
|
|
shutil.rmtree(d)
|
|
|
|
spec_file = "TeletextEditor_Linux.spec" if platform.system() == "Linux" else "TeletextEditor_Windows.spec"
|
|
if os.path.exists(spec_file):
|
|
os.remove(spec_file)
|
|
|
|
def build():
|
|
system = platform.system()
|
|
print(f"Detected OS: {system}")
|
|
|
|
base_cmd = [
|
|
sys.executable, "-m", "PyInstaller",
|
|
"--onefile",
|
|
"--windowed",
|
|
"--paths", "src",
|
|
"src/main.py"
|
|
]
|
|
|
|
if system == "Linux":
|
|
name = "TeletextEditor_Linux"
|
|
elif system == "Windows":
|
|
name = "TeletextEditor_Windows.exe"
|
|
else:
|
|
print(f"Unsupported platform: {system}")
|
|
return
|
|
|
|
cmd = base_cmd + ["--name", name]
|
|
|
|
print("Running build command:")
|
|
print(" ".join(cmd))
|
|
|
|
try:
|
|
subprocess.check_call(cmd)
|
|
print("\n" + "="*40)
|
|
print(f"Build successful! Executable is in 'dist/{name}'")
|
|
print("="*40)
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"Build failed with error code {e.returncode}")
|
|
sys.exit(1)
|
|
|
|
# Cross-compilation note
|
|
if system == "Linux":
|
|
print("\nNote: To build the Windows executable, please run this script on Windows.")
|
|
elif system == "Windows":
|
|
print("\nNote: To build the Linux executable, please run this script on Linux.")
|
|
|
|
if __name__ == "__main__":
|
|
clean_build_dirs()
|
|
build()
|