Add worktree-isolated tmpfs build outputs

This commit is contained in:
BruceChen 2026-04-12 20:07:15 +08:00
parent e0752d8d98
commit 0a041b37c5
3 changed files with 38 additions and 4 deletions

11
Directory.Build.props Normal file
View file

@ -0,0 +1,11 @@
<Project>
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);**/bin/**;**/obj/**</DefaultItemExcludes>
</PropertyGroup>
<PropertyGroup Condition="'$(MCC_BUILD_ROOT)' != ''">
<BaseOutputPath>$(MCC_BUILD_ROOT)/$(MSBuildProjectName)/bin/</BaseOutputPath>
<BaseIntermediateOutputPath>$(MCC_BUILD_ROOT)/$(MSBuildProjectName)/obj/</BaseIntermediateOutputPath>
<MSBuildProjectExtensionsPath>$(BaseIntermediateOutputPath)</MSBuildProjectExtensionsPath>
</PropertyGroup>
</Project>

View file

@ -121,6 +121,20 @@ _mcc_build_root() {
printf '%s\n' "$MCC_REPO_ROOT" printf '%s\n' "$MCC_REPO_ROOT"
} }
_mcc_dotnet_env() {
local -n env_ref="$1"
env_ref=()
if [[ "${MCC_BUILD_MODE:-local}" != "tmpfs" ]]; then
return 0
fi
local build_root
build_root="$(_mcc_build_root)"
mkdir -p "$build_root"
env_ref+=("MCC_BUILD_ROOT=$build_root")
}
# Helper: convert version to tmux session name (dots -> underscores) # Helper: convert version to tmux session name (dots -> underscores)
_mc-session() { echo "mc-${1//\./_}"; } _mc-session() { echo "mc-${1//\./_}"; }
@ -141,15 +155,20 @@ mc-rcon() { bash "$MCC_REPO/tools/mc-rcon.sh" "$@"; }
# --- MCC Build/Run --- # --- MCC Build/Run ---
mcc-build() { mcc-build() {
local repo_root local repo_root
local -a dotnet_env
repo_root="$(_mcc_repo_root)" repo_root="$(_mcc_repo_root)"
_mcc_dotnet_env dotnet_env
env "${dotnet_env[@]}" dotnet build "$repo_root/MinecraftClient.sln" -c Release
}
mcc-build-clean() {
if [[ "${MCC_BUILD_MODE:-local}" == "tmpfs" ]]; then if [[ "${MCC_BUILD_MODE:-local}" == "tmpfs" ]]; then
local build_root local build_root
build_root="$(_mcc_build_root)" build_root="$(_mcc_build_root)"
mkdir -p "$build_root" rm -rf "$build_root"
MCC_BUILD_ROOT="$build_root" dotnet build "$repo_root/MinecraftClient.sln" -c Release return 0
else
dotnet build "$repo_root/MinecraftClient.sln" -c Release
fi fi
dotnet clean "$(_mcc_repo_root)/MinecraftClient.sln" -c Release
} }
mcc-run() { mcc-run() {
local port="${1:-25565}" local port="${1:-25565}"

View file

@ -75,6 +75,10 @@ if [[ "$build_root" != "$expected_prefix"* ]]; then
exit 1 exit 1
fi fi
mkdir -p "$build_root/probe"
mcc-build-clean
[[ ! -e "$build_root/probe" ]]
session="wrapper-smoke" session="wrapper-smoke"
input_file="$(_mcc_session_input_file "$session")" input_file="$(_mcc_session_input_file "$session")"
rm -rf "$(_mcc_session_root "$session")" rm -rf "$(_mcc_session_root "$session")"