86 lines
2.3 KiB
Python
86 lines
2.3 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""
|
||
|
|
Build script for NotePad application
|
||
|
|
Creates distributable binaries for Linux and Windows
|
||
|
|
"""
|
||
|
|
|
||
|
|
import subprocess
|
||
|
|
import sys
|
||
|
|
import os
|
||
|
|
import shutil
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
def run_command(cmd, description):
|
||
|
|
"""Run a shell command and print status"""
|
||
|
|
print(f"\n{'='*60}")
|
||
|
|
print(f"{description}")
|
||
|
|
print(f"{'='*60}")
|
||
|
|
print(f"Command: {' '.join(cmd)}\n")
|
||
|
|
|
||
|
|
result = subprocess.run(cmd, capture_output=False, text=True)
|
||
|
|
|
||
|
|
if result.returncode != 0:
|
||
|
|
print(f"\n❌ ERROR: {description} failed!")
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
print(f"\n✅ {description} completed successfully!")
|
||
|
|
return result
|
||
|
|
|
||
|
|
def publish_platform(platform):
|
||
|
|
"""Publish for a specific platform"""
|
||
|
|
runtime_id = f"{platform}-x64"
|
||
|
|
|
||
|
|
cmd = [
|
||
|
|
"dotnet", "publish",
|
||
|
|
"-c", "Release",
|
||
|
|
"-r", runtime_id,
|
||
|
|
"--self-contained", "true",
|
||
|
|
"-p:PublishSingleFile=true",
|
||
|
|
"-p:IncludeNativeLibrariesForSelfExtract=true",
|
||
|
|
"-p:PublishTrimmed=false" # Avalonia doesn't work well with trimming
|
||
|
|
]
|
||
|
|
|
||
|
|
run_command(cmd, f"Building for {platform.upper()}")
|
||
|
|
|
||
|
|
# Show the output location
|
||
|
|
output_dir = Path(f"bin/Release/net8.0/{runtime_id}/publish")
|
||
|
|
if output_dir.exists():
|
||
|
|
files = list(output_dir.glob("*"))
|
||
|
|
print(f"\n📦 Output files in: {output_dir.absolute()}")
|
||
|
|
for file in files:
|
||
|
|
size_mb = file.stat().st_size / (1024 * 1024)
|
||
|
|
print(f" - {file.name} ({size_mb:.2f} MB)")
|
||
|
|
|
||
|
|
def main():
|
||
|
|
"""Main entry point"""
|
||
|
|
# Parse arguments
|
||
|
|
if len(sys.argv) > 1:
|
||
|
|
target = sys.argv[1].lower()
|
||
|
|
if target not in ['linux', 'windows', 'both', 'all']:
|
||
|
|
print("Usage: python3 publish.py [linux|windows|both]")
|
||
|
|
print(" Default: both")
|
||
|
|
sys.exit(1)
|
||
|
|
else:
|
||
|
|
target = 'both'
|
||
|
|
|
||
|
|
# Change to script directory
|
||
|
|
script_dir = Path(__file__).parent
|
||
|
|
os.chdir(script_dir)
|
||
|
|
|
||
|
|
print(f"🚀 NotePad Build Script")
|
||
|
|
print(f"Target platform(s): {target.upper()}")
|
||
|
|
|
||
|
|
# Build for requested platform(s)
|
||
|
|
if target in ['linux', 'both', 'all']:
|
||
|
|
publish_platform('linux')
|
||
|
|
|
||
|
|
if target in ['windows', 'both', 'all']:
|
||
|
|
publish_platform('win')
|
||
|
|
|
||
|
|
print(f"\n{'='*60}")
|
||
|
|
print("🎉 All builds completed successfully!")
|
||
|
|
print(f"{'='*60}\n")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|