Skip to content

Commit c25d276

Browse files
MikotoZeroclaude
andcommitted
fix(ci): fix macOS Intel build and Linux ARM64 cross-compile
- macOS: Source cargo env before build to ensure Rust in PATH - Linux ARM64: Use zig for cross-compilation from x86_64 - pathResolver: Use EnvConfig.workspaceRoot for env var compat (Fix: TAPTAP_MCP_WORKSPACE_ROOT was not being read because pathResolver directly used process.env.WORKSPACE_ROOT) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 862413f commit c25d276

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ jobs:
8181
- host: macos-13
8282
target: x86_64-apple-darwin
8383
build: |
84+
# 确保 Rust 在 PATH 中
85+
source "$HOME/.cargo/env" 2>/dev/null || true
8486
cd native
8587
npm run build
8688
strip -x *.node
@@ -89,6 +91,8 @@ jobs:
8991
- host: macos-latest
9092
target: aarch64-apple-darwin
9193
build: |
94+
# 确保 Rust 在 PATH 中
95+
source "$HOME/.cargo/env" 2>/dev/null || true
9296
cd native
9397
npm run build -- --target aarch64-apple-darwin
9498
strip -x *.node
@@ -114,14 +118,21 @@ jobs:
114118
strip *.node
115119
116120
# Linux Musl ARM64 (Alpine on ARM servers / Apple Silicon Docker)
121+
# 使用 zig 作为交叉编译器
117122
- host: ubuntu-latest
118123
target: aarch64-unknown-linux-musl
119124
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
120125
build: |
126+
# 安装 zig 用于交叉编译
127+
apk add --no-cache zig
128+
# 更新 Rust 并添加 ARM64 target
121129
rustup update stable && rustup default stable
130+
rustup target add aarch64-unknown-linux-musl
122131
cd native
123-
npm run build -- --target aarch64-unknown-linux-musl
124-
strip *.node
132+
# 使用 zig 作为链接器进行交叉编译
133+
npm run build -- --target aarch64-unknown-linux-musl --zig
134+
# ARM64 需要使用 llvm-strip 或跳过 strip
135+
llvm-strip *.node 2>/dev/null || aarch64-linux-gnu-strip *.node 2>/dev/null || echo "Skip strip for cross-compiled binary"
125136
126137
# Windows
127138
- host: windows-latest

src/core/utils/pathResolver.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ import * as path from 'node:path';
1717
import * as fs from 'node:fs';
1818
import type { ResolvedContext } from '../types/context.js';
1919
import { logger } from './logger.js';
20+
import { EnvConfig } from './env.js';
2021

2122
/**
2223
* 工作空间根路径
23-
* 优先级:环境变量 > process.cwd()
24+
* 优先级:TAPTAP_MCP_WORKSPACE_ROOT > WORKSPACE_ROOT(向后兼容)> process.cwd()
25+
*
26+
* 注意:使用 EnvConfig.workspaceRoot 来支持新旧环境变量名的兼容
2427
*/
25-
const WORKSPACE_ROOT = process.env.WORKSPACE_ROOT || process.cwd();
28+
const WORKSPACE_ROOT = EnvConfig.workspaceRoot;
2629

2730
/**
2831
* 路径输入类型

0 commit comments

Comments
 (0)