fix(build): 按平台配置 Rust 链接参数

This commit is contained in:
Codex
2026-09-13 09:10:06 +08:00
parent 96fd7aa74c
commit 3b653176dc
@@ -3,6 +3,7 @@ import hashlib
import json import json
import re import re
import subprocess import subprocess
import sys
import tempfile import tempfile
import zipfile import zipfile
from pathlib import Path from pathlib import Path
@@ -24,12 +25,15 @@ def build(output: Path | None = None) -> dict:
if identity == 'markdown-workbench': if identity == 'markdown-workbench':
with tempfile.TemporaryDirectory(prefix='opennexus-community-') as directory: with tempfile.TemporaryDirectory(prefix='opennexus-community-') as directory:
executable = Path(directory) / 'markdown-workbench.exe' executable = Path(directory) / 'markdown-workbench.exe'
subprocess.run([ rustc_command = [
'rustc', '--edition=2021', '--crate-name', 'markdown_workbench', 'rustc', '--edition=2021', '--crate-name', 'markdown_workbench',
'-C', 'metadata=opennexus-community-v1', '-C', 'opt-level=s', '-C', 'metadata=opennexus-community-v1', '-C', 'opt-level=s',
'-C', 'strip=symbols', '-C', 'link-arg=-Wl,--no-insert-timestamp', '-C', 'strip=symbols',
str(source / 'server.rs'), '-o', str(executable), ]
], check=True) if sys.platform == 'win32':
rustc_command.extend(['-C', 'link-arg=-Wl,--no-insert-timestamp'])
rustc_command.extend([str(source / 'server.rs'), '-o', str(executable)])
subprocess.run(rustc_command, check=True)
generated[executable.name] = executable.read_bytes() generated[executable.name] = executable.read_bytes()
manifest = (source / f'{kind}.yaml').read_text(encoding='utf-8') manifest = (source / f'{kind}.yaml').read_text(encoding='utf-8')
version = re.search(r'^version: (\d+\.\d+\.\d+)$', manifest, re.M)[1] version = re.search(r'^version: (\d+\.\d+\.\d+)$', manifest, re.M)[1]