增加打包工具

This commit is contained in:
Luke 2025-05-09 10:12:53 +08:00
parent f29e6eccb5
commit eaf7a8f9dc
3 changed files with 44 additions and 0 deletions

1
.gitignore vendored
View File

@ -42,3 +42,4 @@ target/
/.idea/
/src.tar
/src/main/java/org/jcnc/snow/compiler/ir.tar
/SCompiler.tar

View File

@ -0,0 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="build_project2tar.ps1" type="PowerShellRunType" factoryName="PowerShell" scriptUrl="$PROJECT_DIR$/build/build_project2tar.ps1" executablePath="C:/WINDOWS/System32/WindowsPowerShell/v1.0/powershell.exe">
<envs />
<method v="2" />
</configuration>
</component>

View File

@ -0,0 +1,37 @@
$tarName = "SCompiler.tar"
# 切换到脚本所在目录的上一级目录(假设作为项目根目录)
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$projectRoot = Split-Path -Parent $scriptDir
Set-Location $projectRoot
Write-Output "当前工作目录:$(Get-Location)"
# 如果旧的 tar 包存在,先删除
if (Test-Path $tarName) {
Write-Output "发现旧的 $tarName,正在删除..."
Remove-Item $tarName
}
# 创建新的 tar 包并排除某些文件和目录
Write-Output "正在创建新的 $tarName ..."
$excludeOptions = @(
"--exclude=$tarName"
"--exclude=build_project2tar.ps1"
"--exclude=.git"
"--exclude=.idea"
"--exclude=.run"
"--exclude=target"
"--exclude=.gitignore"
)
# 调用 tar 命令
& tar -cf $tarName $excludeOptions *
# 验证结果
if (Test-Path $tarName) {
Write-Output "✅ 成功创建 $tarName"
} else {
Write-Output "❌ 创建失败,请检查 tar 命令或排除项"
}