2023-07-06 12:18:33 +08:00
|
|
|
$myRoot = $PSScriptRoot
|
|
|
|
$AX_ROOT = $myRoot
|
|
|
|
|
2023-07-06 20:24:41 +08:00
|
|
|
$build1kPath = Join-Path $myRoot '1k/build1k.ps1'
|
2023-07-06 12:18:33 +08:00
|
|
|
$prefix = Join-Path $myRoot 'tools/external'
|
|
|
|
if (!(Test-Path $prefix -PathType Container)) {
|
|
|
|
mkdir $prefix | Out-Null
|
|
|
|
}
|
|
|
|
|
|
|
|
# setup toolchains: glslcc, cmake, ninja, ndk, jdk, ...
|
|
|
|
. $build1kPath -setupOnly $true -prefix $prefix
|
|
|
|
|
|
|
|
$AX_CONSOLE_BIN = Join-Path $AX_ROOT 'tools/console/bin'
|
|
|
|
|
|
|
|
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables
|
|
|
|
$IsWin = $IsWindows -or ("$env:OS" -eq 'Windows_NT')
|
|
|
|
|
|
|
|
if ($IsWin) {
|
|
|
|
if ($env:AX_ROOT -ne $AX_ROOT) {
|
|
|
|
[Environment]::SetEnvironmentVariable('AX_ROOT', $AX_ROOT, 'User')
|
|
|
|
}
|
|
|
|
|
|
|
|
$pathList = [System.Collections.ArrayList]$env:PATH.Split(';')
|
|
|
|
if (!$pathList.IndexOf($AX_CONSOLE_BIN) -eq -1) {
|
|
|
|
$pathList = [Environment]::GetEnvironmentVariable('PATH', 'User').Split(';')
|
|
|
|
$pathList.Insert(0, $AX_CONSOLE_BIN)
|
|
|
|
$PATH = $pathList -join ';'
|
|
|
|
[Environment]::SetEnvironmentVariable('PATH', $PATH, 'User')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$PATH = [System.Collections.ArrayList]$env:PATH.Split(':')
|
|
|
|
if (Test-Path $PROFILE -PathType Leaf) {
|
2023-07-08 12:37:02 +08:00
|
|
|
$profileContent = Get-Content $PROFILE -raw
|
2023-07-06 12:18:33 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$profileContent = ''
|
|
|
|
}
|
|
|
|
|
2023-07-08 12:37:02 +08:00
|
|
|
$needSave = $false
|
2023-07-06 12:18:33 +08:00
|
|
|
if ($profileContent.IndexOf('$env:AX_ROOT = ') -eq -1) {
|
|
|
|
$profileContent += '$env:AX_ROOT = "{0}"{1}' -f $AX_ROOT, "`n"
|
2023-07-08 12:37:02 +08:00
|
|
|
$needSave = $true
|
2023-07-06 12:18:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($profileContent.IndexOf('$env:PATH = ') -eq -1) {
|
|
|
|
$profileContent += '$env:PATH = "{0}:$env:PATH"' -f $AX_CONSOLE_BIN
|
2023-07-08 12:37:02 +08:00
|
|
|
$needSave = $true
|
2023-07-06 12:18:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$profileDir = Split-Path $PROFILE -Parent
|
|
|
|
if (!(Test-Path $profileDir -PathType Container)) {
|
|
|
|
mkdir $profileDir | Out-Null
|
|
|
|
}
|
|
|
|
|
2023-07-08 12:37:02 +08:00
|
|
|
if ($needSave) {
|
|
|
|
Set-Content $PROFILE -Value $profileContent
|
|
|
|
}
|
2023-07-06 12:18:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($IsLinux) {
|
2023-07-08 12:37:02 +08:00
|
|
|
Write-Host "Are you continue install linux dependencies for axmol? (y/n) " -NoNewline
|
2023-07-06 12:18:33 +08:00
|
|
|
$answer = Read-Host
|
|
|
|
if ($answer -like 'y*') {
|
|
|
|
b1k_print "It will take few minutes"
|
|
|
|
sudo apt update
|
|
|
|
# for vm, libxxf86vm-dev also required
|
|
|
|
|
2023-07-06 13:15:54 +08:00
|
|
|
$DEPENDS = @()
|
2023-07-06 12:18:33 +08:00
|
|
|
|
2023-07-06 13:20:56 +08:00
|
|
|
$DEPENDS += 'libx11-dev'
|
2023-07-06 13:15:54 +08:00
|
|
|
$DEPENDS += 'automake'
|
|
|
|
$DEPENDS += 'libtool'
|
|
|
|
$DEPENDS += 'cmake'
|
|
|
|
$DEPENDS += 'libxmu-dev'
|
|
|
|
$DEPENDS += 'libglu1-mesa-dev'
|
|
|
|
$DEPENDS += 'libgl2ps-dev'
|
|
|
|
$DEPENDS += 'libxi-dev'
|
|
|
|
$DEPENDS += 'libzip-dev'
|
|
|
|
$DEPENDS += 'libpng-dev'
|
|
|
|
$DEPENDS += 'libfontconfig1-dev'
|
|
|
|
$DEPENDS += 'libgtk-3-dev'
|
|
|
|
$DEPENDS += 'binutils'
|
|
|
|
$DEPENDS += 'libbsd-dev'
|
|
|
|
$DEPENDS += 'libasound2-dev'
|
|
|
|
$DEPENDS += 'libxxf86vm-dev'
|
2023-07-06 13:20:56 +08:00
|
|
|
$DEPENDS += 'libvlc-dev', 'libvlccore-dev', 'vlc'
|
2023-07-06 12:18:33 +08:00
|
|
|
|
|
|
|
# if vlc encouter codec error, install
|
|
|
|
# sudo apt install ubuntu-restricted-extras
|
|
|
|
|
|
|
|
sudo apt install --allow-unauthenticated --yes $DEPENDS > /dev/null
|
|
|
|
|
|
|
|
b1k_print "Installing latest freetype for linux ..."
|
|
|
|
mkdir buildsrc
|
|
|
|
Set-Location buildsrc
|
|
|
|
git clone 'https://github.com/freetype/freetype.git'
|
|
|
|
Set-Location freetype
|
|
|
|
git checkout 'VER-2-13-0'
|
|
|
|
sh autogen.sh
|
|
|
|
./configure '--prefix=/usr' '--enable-freetype-config' '--disable-static'
|
|
|
|
sudo make install
|
|
|
|
Set-Location ..
|
|
|
|
Set-Location ..
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($IsWin) {
|
|
|
|
$myProcess = [System.Diagnostics.Process]::GetCurrentProcess()
|
|
|
|
$parentProcess = $myProcess.Parent
|
|
|
|
if (!$parentProcess) {
|
|
|
|
$myPID = $myProcess.Id
|
|
|
|
$instance = Get-WmiObject Win32_Process -Filter "ProcessId = $myPID"
|
|
|
|
$parentProcess = Get-Process -Id $instance.ParentProcessID
|
|
|
|
}
|
|
|
|
$parentProcessName = $parentProcess.ProcessName
|
2023-07-06 16:09:54 +08:00
|
|
|
if ($parentProcessName -like "explorer") {
|
2023-07-08 12:37:02 +08:00
|
|
|
b1k_print "setup successfully, press any key to exit . . ." -NoNewline
|
2023-07-06 16:09:54 +08:00
|
|
|
cmd /c pause 1>$null
|
|
|
|
exit 0
|
|
|
|
}
|
2023-07-06 12:18:33 +08:00
|
|
|
}
|
|
|
|
|
2023-07-06 16:09:54 +08:00
|
|
|
b1k_print 'setup successfully.'
|
|
|
|
|