Skip to content

Commit

Permalink
Improve setup.ps1 on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Feb 6, 2025
1 parent 1185425 commit 48fdc59
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ if ($IsWin) {
else {
# update pwsh profile
if (Test-Path $PROFILE -PathType Leaf) {
$profileContent = Get-Content $PROFILE -raw
$profileContent = "$(Get-Content $PROFILE -raw)"
}
else {
$profileContent = ''
Expand Down Expand Up @@ -225,8 +225,11 @@ else {
# update ~/.bashrc, ~/.zshrc
function updateUnixProfile($profileFile) {
if (!(Test-Path $profileFile -PathType Leaf)) {
touch $profileFile
}
$profileMods = 0
$profileContent = Get-Content $profileFile -raw
$profileContent = "$(Get-Content $profileFile -raw)"
$matchRet = [Regex]::Match($profileContent, "export AX_ROOT\=.*")
if (!$matchRet.Success) {
$profileContent += "# Add environment variable AX_ROOT for axmol`n"
Expand All @@ -251,22 +254,25 @@ else {
}
}
if (Test-Path ~/.bashrc -PathType Leaf) {
updateUnixProfile ~/.bashrc
}
if (Test-Path ~/.zshrc -PathType Leaf) {
if ($env:SHELL -like '*/zsh') {
updateUnixProfile ~/.zshrc
}
elseif($env:SHELL -like '*/bash') {
if (!$IsMacOS) {
updateUnixProfile ~/.bashrc
} else {
updateUnixProfile ~/.bash_profile
}
} else {
Write-Error "Warning: current shell: $env:SHELL isn't officially supported by axmol community"
}
# update macos launchctl
if ($IsMacOS) {
# for GUI app, android studio can find AX_ROOT
launchctl setenv AX_ROOT $env:AX_ROOT
}
}
if ($IsLinux) {
if ($(Get-Command 'dpkg' -ErrorAction SilentlyContinue)) {
$LinuxDistro = 'Debian'
Expand Down Expand Up @@ -400,7 +406,7 @@ if ($updateAdt) {
}
$testList = @('cpp-tests', 'fairygui-tests', 'live2d-tests', 'lua-tests', 'unit-tests')
foreach($testName in $testList) {
foreach ($testName in $testList) {
update_gradle_for_test($testName)
}
Expand All @@ -419,7 +425,7 @@ if ($updateAdt) {
}
update_agp('templates/common')
foreach($testName in $testList) {
foreach ($testName in $testList) {
update_gradle_for_test($testName)
update_agp_for_test($testName)
}
Expand Down

0 comments on commit 48fdc59

Please sign in to comment.