|
4 | 4 | import zipfile |
5 | 5 |
|
6 | 6 |
|
| 7 | +RIDS = [ |
| 8 | + ("linux-x64", ".tar.gz"), |
| 9 | + ("linux-arm64", ".tar.gz"), |
| 10 | + ("win-x64", ".zip"), |
| 11 | + ("win-arm64", ".zip"), |
| 12 | + ("osx-x64", ".tar.gz"), |
| 13 | + ("osx-arm64", ".tar.gz"), |
| 14 | +] |
| 15 | + |
| 16 | + |
7 | 17 | def get_version(): |
8 | 18 | """ |
9 | 19 | Extracts the version from the specified __about__.py file. |
@@ -50,57 +60,47 @@ def cleanup_old_builds(dist_dir, current_version): |
50 | 60 | print(f"Deleted old build file: {file}") |
51 | 61 |
|
52 | 62 |
|
53 | | -def main(): |
54 | | - version = get_version() |
55 | | - print(f"Version: {version}") |
56 | | - |
57 | | - dist_dir = "./src/python_redlines/dist/" |
58 | | - |
59 | | - # Build for Linux x64 |
60 | | - print("Building for Linux x64...") |
61 | | - run_command('dotnet publish ./csproj -c Release -r linux-x64 --self-contained') |
62 | | - |
63 | | - # Build for Linux ARM64 |
64 | | - print("Building for Linux ARM64...") |
65 | | - run_command('dotnet publish ./csproj -c Release -r linux-arm64 --self-contained') |
66 | | - |
67 | | - # Build for Windows x64 |
68 | | - print("Building for Windows x64...") |
69 | | - run_command('dotnet publish ./csproj -c Release -r win-x64 --self-contained') |
70 | | - |
71 | | - # Build for Windows ARM64 |
72 | | - print("Building for Windows ARM64...") |
73 | | - run_command('dotnet publish ./csproj -c Release -r win-arm64 --self-contained') |
74 | | - |
75 | | - # Build for macOS x64 |
76 | | - print("Building for macOS x64...") |
77 | | - run_command('dotnet publish ./csproj -c Release -r osx-x64 --self-contained') |
78 | | - |
79 | | - # Build for macOS ARM64 |
80 | | - print("Building for macOS ARM64...") |
81 | | - run_command('dotnet publish ./csproj -c Release -r osx-arm64 --self-contained') |
| 63 | +def build_engine(csproj_path, dist_dir, version): |
| 64 | + """ |
| 65 | + Builds a C# engine for all platform targets, compresses the output, and cleans up old builds. |
82 | 66 |
|
83 | | - # Compress the Linux x64 build |
84 | | - linux_x64_build_dir = './csproj/bin/Release/net8.0/linux-x64' |
85 | | - compress_files(linux_x64_build_dir, f"{dist_dir}/linux-x64-{version}.tar.gz") |
| 67 | + :param csproj_path: Path to the .csproj directory (e.g. './csproj' or './docxodus/tools/redline') |
| 68 | + :param dist_dir: Path to the distribution directory for compressed binaries |
| 69 | + :param version: Version string for archive naming |
| 70 | + """ |
| 71 | + # Build for each RID |
| 72 | + for rid, _ in RIDS: |
| 73 | + print(f"Building {csproj_path} for {rid}...") |
| 74 | + run_command(f'dotnet publish {csproj_path} -c Release -r {rid} --self-contained') |
| 75 | + |
| 76 | + # Determine the build output base directory |
| 77 | + # dotnet publish outputs to <csproj_path>/bin/Release/net8.0/<rid> |
| 78 | + build_base = os.path.join(csproj_path, 'bin', 'Release', 'net8.0') |
| 79 | + |
| 80 | + # Compress each build |
| 81 | + for rid, ext in RIDS: |
| 82 | + build_dir = os.path.join(build_base, rid) |
| 83 | + archive_path = os.path.join(dist_dir, f"{rid}-{version}{ext}") |
| 84 | + print(f"Compressing {rid} to {archive_path}...") |
| 85 | + compress_files(build_dir, archive_path) |
86 | 86 |
|
87 | | - # Compress the Linux ARM64 build |
88 | | - linux_arm64_build_dir = './csproj/bin/Release/net8.0/linux-arm64' |
89 | | - compress_files(linux_arm64_build_dir, f"{dist_dir}/linux-arm64-{version}.tar.gz") |
| 87 | + cleanup_old_builds(dist_dir, version) |
90 | 88 |
|
91 | | - # Compress the Windows x64 build |
92 | | - windows_build_dir = './csproj/bin/Release/net8.0/win-x64' |
93 | | - compress_files(windows_build_dir, f"{dist_dir}/win-x64-{version}.zip") |
94 | 89 |
|
95 | | - # Compress the macOS x64 build |
96 | | - macos_x64_build_dir = './csproj/bin/Release/net8.0/osx-x64' |
97 | | - compress_files(macos_x64_build_dir, f"{dist_dir}/osx-x64-{version}.tar.gz") |
| 90 | +def main(): |
| 91 | + version = get_version() |
| 92 | + print(f"Version: {version}") |
98 | 93 |
|
99 | | - # Compress the macOS ARM64 build |
100 | | - macos_arm64_build_dir = './csproj/bin/Release/net8.0/osx-arm64' |
101 | | - compress_files(macos_arm64_build_dir, f"{dist_dir}/osx-arm64-{version}.tar.gz") |
| 94 | + # Build the XmlPowerTools engine (original) |
| 95 | + build_engine('./csproj', './src/python_redlines/dist/', version) |
102 | 96 |
|
103 | | - cleanup_old_builds(dist_dir, version) |
| 97 | + # Build the Docxodus engine (if submodule is available) |
| 98 | + docxodus_csproj = './docxodus/tools/redline' |
| 99 | + if os.path.exists(os.path.join(docxodus_csproj, 'redline.csproj')): |
| 100 | + build_engine(docxodus_csproj, './src/python_redlines/dist_docxodus/', version) |
| 101 | + else: |
| 102 | + print("WARNING: Docxodus submodule not found at docxodus/tools/redline/redline.csproj — skipping Docxodus build.") |
| 103 | + print("Run 'git submodule update --init --recursive' to initialize the submodule.") |
104 | 104 |
|
105 | 105 | print("Build and compression complete.") |
106 | 106 |
|
|
0 commit comments