adapt to win32

This commit is contained in:
fanlumaster
2025-01-02 06:19:47 +08:00
parent 155d6eb410
commit 12abe936bf
13 changed files with 2864 additions and 2714 deletions

26
scripts/lcompile.ps1 Normal file
View File

@ -0,0 +1,26 @@
# generate compile to exe files
$currentDirectory = Get-Location
$cmakeListsPath = Join-Path -Path $currentDirectory -ChildPath "CMakeLists.txt"
if (-not (Test-Path $cmakeListsPath))
{
Write-Host("No CMakeLists.txt in current directory, please check.")
return
}
Write-Host "Start generating and compiling..."
$buildFolderPath = ".\build"
if (-not (Test-Path $buildFolderPath))
{
New-Item -ItemType Directory -Path $buildFolderPath | Out-Null
Write-Host "build folder created."
}
cmake -G "Visual Studio 17 2022" -A x64 -S . -B ./build/
if ($LASTEXITCODE -eq 0)
{
cmake --build ./build/ --config DEBUG
}

23
scripts/lcompile.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
currentDirectory=$(pwd)
cmakeListsPath="${currentDirectory}/CMakeLists.txt"
if [ ! -f "$cmakeListsPath" ]; then
echo "No CMakeLists.txt in current directory, please check."
exit 1
fi
echo "Start generating and compiling..."
buildFolderPath="./build"
if [ ! -d "$buildFolderPath" ]; then
mkdir -p "$buildFolderPath"
echo "build folder created."
fi
cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -S . -B ./build/
if [ $? -eq 0 ]; then
cmake --build ./build/ --config DEBUG
fi

45
scripts/llaunch.ps1 Normal file
View File

@ -0,0 +1,45 @@
#
# generate, compile and run exe files
#
function getExePathFromCMakeLists() {
$content = Get-Content -Raw -Path "./CMakeLists.txt"
$exePath = ""
foreach ($line in $content -split "`n") {
if ($line -match 'set\(MY_EXECUTABLE_NAME[^\"]*\"([^\"]+)\"') {
$exeName = $matches[1]
$exePath = "./build/bin/Debug/$exeName" + ".exe"
break
}
}
return $exePath
}
$currentDirectory = Get-Location
$cmakeListsPath = Join-Path -Path $currentDirectory -ChildPath "CMakeLists.txt"
if (-not (Test-Path $cmakeListsPath)) {
Write-Host("No CMakeLists.txt in current directory, please check.")
return
}
Write-Host "Start generating and compiling..."
$buildFolderPath = ".\build"
if (-not (Test-Path $buildFolderPath)) {
New-Item -ItemType Directory -Path $buildFolderPath | Out-Null
Write-Host "build folder created."
}
cmake -G "Visual Studio 17 2022" -A x64 -S . -B ./build/
if ($LASTEXITCODE -eq 0) {
cmake --build ./build/ --config DEBUG
if ($LASTEXITCODE -eq 0) {
$exePath = getExePathFromCMakeLists
Write-Host "start running as follows..."
Write-Host "=================================================="
Invoke-Expression $exePath
}
}

45
scripts/llaunch.sh Normal file
View File

@ -0,0 +1,45 @@
#!/bin/bash
currentDirectory=$(pwd)
cmakeListsPath="${currentDirectory}/CMakeLists.txt"
if [ ! -f "$cmakeListsPath" ]; then
echo "No CMakeLists.txt in current directory, please check."
exit 1
fi
echo "Start generating and compiling..."
buildFolderPath="./build"
if [ ! -d "$buildFolderPath" ]; then
mkdir -p "$buildFolderPath"
echo "build folder created."
fi
cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -S . -B ./build/
if [ $? -eq 0 ]; then
cmake --build ./build/ --config DEBUG
if [ $? -eq 0 ]; then
content=$(<"./CMakeLists.txt")
exePath=""
while IFS= read -r line; do
if [[ $line == "set(MY_EXECUTABLE_NAME"* ]]; then
pattern="\"([^\"]+)\""
if [[ $line =~ $pattern ]]; then
contentInParentheses="${BASH_REMATCH[1]}"
result=($contentInParentheses)
exePath="./build/bin/${result[0]}"
echo "start running as follows..."
echo "=================================================="
fi
fi
done <<<"$content"
# execute the binary file
if [ -n "$exePath" ]; then
$exePath
else
echo "cannot find executable file path"
fi
fi
fi

20
scripts/lrun.ps1 Normal file
View File

@ -0,0 +1,20 @@
#
# run exe file that has already been compiled before
#
function getExePathFromCMakeLists() {
$content = Get-Content -Raw -Path "./CMakeLists.txt"
$exePath = ""
foreach ($line in $content -split "`n") {
if ($line -match 'set\(MY_EXECUTABLE_NAME[^\"]*\"([^\"]+)\"') {
$exeName = $matches[1]
$exePath = "./build/bin/Debug/$exeName" + ".exe"
break
}
}
return $exePath
}
$exePath = getExePathFromCMakeLists
#Write-Host "start running as follows..."
#Write-Host "=================================================="
Invoke-Expression $exePath

18
scripts/lrun.sh Normal file
View File

@ -0,0 +1,18 @@
content=$(<"./CMakeLists.txt")
exePath=""
while IFS= read -r line; do
if [[ $line == "set(MY_EXECUTABLE_NAME"* ]]; then
pattern="\"([^\"]+)\""
if [[ $line =~ $pattern ]]; then
contentInParentheses="${BASH_REMATCH[1]}"
result=($contentInParentheses)
exePath="./build/bin/${result[0]}"
fi
fi
done <<<"$content"
if [ -n "$exePath" ]; then
$exePath
else
echo "cannot find executable file path"
fi