mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
build-deps - move some code to powershell
This commit is contained in:
+18
-68
@@ -793,76 +793,31 @@ exit %IFCOS_SCRIPT_RET%
|
|||||||
|
|
||||||
:: DownloadFile - Downloads a file using PowerShell
|
:: DownloadFile - Downloads a file using PowerShell
|
||||||
:: Params: %1 url, %2 destinationDir, %3 filename
|
:: Params: %1 url, %2 destinationDir, %3 filename
|
||||||
|
:: Required vars:
|
||||||
|
:: - DEPENDENCY_NAME
|
||||||
:DownloadFile
|
:DownloadFile
|
||||||
mkdir "%2"
|
%PWSH_TOOLS% download_file "%DEPENDENCY_NAME%" "%1" "%2" "%3"
|
||||||
pushd "%2"
|
IF NOT %ERRORLEVEL%==0 GOTO :Error
|
||||||
if not exist "%~3". (
|
exit /b 0
|
||||||
call cecho.cmd 0 13 "Downloading %DEPENDENCY_NAME% into %~2."
|
|
||||||
powershell -Command "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; $webClient = new-object System.Net.WebClient; $webClient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials; $webClient.DownloadFile('%1', '%3')"
|
|
||||||
REM Old wget version in case someone has problem with PowerShell: wget --no-check-certificate %1
|
|
||||||
) else (
|
|
||||||
call cecho.cmd 0 13 "%DEPENDENCY_NAME% already downloaded. Skipping."
|
|
||||||
)
|
|
||||||
set RET=%ERRORLEVEL%
|
|
||||||
set LAST_ACTION=DownloadFile '%DEPENDENCY_NAME%'.
|
|
||||||
popd
|
|
||||||
exit /b %RET%
|
|
||||||
|
|
||||||
:: ExtractArchive - Extracts an archive file using 7-zip
|
:: ExtractArchive - Extracts an archive file using 7-zip
|
||||||
:: Params: %1 filename, %2 destinationDir, %3 dirAfterExtraction
|
:: Params: %1 filename, %2 destinationDir, %3 dirAfterExtraction
|
||||||
|
:: Required vars:
|
||||||
|
:: - DEPENDENCY_NAME
|
||||||
:ExtractArchive
|
:ExtractArchive
|
||||||
if not exist "%~3". (
|
%PWSH_TOOLS% extract_file "%DEPENDENCY_NAME%" "%1" "%2" "%3"
|
||||||
call cecho.cmd 0 13 "Extracting %DEPENDENCY_NAME% into %~2 from %1"
|
IF NOT %ERRORLEVEL%==0 GOTO :Error
|
||||||
7za x %1 -y -o%2 > nul
|
exit /b 0
|
||||||
) else (
|
|
||||||
call cecho.cmd 0 13 "%DEPENDENCY_NAME% already extracted into %~3. Skipping."
|
|
||||||
)
|
|
||||||
set RET=%ERRORLEVEL%
|
|
||||||
set LAST_ACTION=ExtractArchive '%DEPENDENCY_NAME%'.
|
|
||||||
exit /b %RET%
|
|
||||||
|
|
||||||
:: GitCloneOrPullRepository - Clones or pulls (if repository already cloned) a Git repository
|
|
||||||
:: Params: %1 gitUrl, %2 destDir
|
|
||||||
:: F.ex. call :GitCloneRepository https://github.com/KhronosGroup/OpenCOLLADA.git "%DEPS_DIR%\OpenCOLLADA\"
|
|
||||||
:GitCloneOrPullRepository
|
|
||||||
if not exist "%~2". (
|
|
||||||
call cecho.cmd 0 13 "Cloning %DEPENDENCY_NAME% into %~2."
|
|
||||||
pushd "%DEPS_DIR%"
|
|
||||||
call git clone %1 %2
|
|
||||||
set RET=!ERRORLEVEL!
|
|
||||||
) else (
|
|
||||||
call cecho.cmd 0 13 "%DEPENDENCY_NAME% already cloned. Pulling latest changes."
|
|
||||||
git reset --hard
|
|
||||||
pushd %2
|
|
||||||
call git pull
|
|
||||||
set RET=0
|
|
||||||
)
|
|
||||||
popd
|
|
||||||
exit /b %RET%
|
|
||||||
|
|
||||||
:: GitCloneAndCheckoutRevision - Clones a Git repository and checks out a specific revision or tag
|
:: GitCloneAndCheckoutRevision - Clones a Git repository and checks out a specific revision or tag
|
||||||
:: Params: %1 gitUrl, %2 destDir, %3 revision
|
:: Params: %1 gitUrl, %2 destDir, %3 revision
|
||||||
:: F.ex. call :GitCloneAndCheckoutRevision https://github.com/KhronosGroup/OpenCOLLADA.git "%DEPENDENCY_DIR%" 064a60b65c2c31b94f013820856bc84fb1937cc6
|
:: F.ex. call :GitCloneAndCheckoutRevision https://github.com/KhronosGroup/OpenCOLLADA.git "%DEPENDENCY_DIR%" 064a60b65c2c31b94f013820856bc84fb1937cc6
|
||||||
|
:: Required vars:
|
||||||
|
:: - DEPENDENCY_NAME
|
||||||
:GitCloneAndCheckoutRevision
|
:GitCloneAndCheckoutRevision
|
||||||
if not exist "%~2". (
|
%PWSH_TOOLS% git_clone_and_checkout_revision "%DEPENDENCY_NAME%" "%1" "%2" "%3"
|
||||||
call cecho.cmd 0 13 "Cloning %DEPENDENCY_NAME% into %~2."
|
IF NOT %ERRORLEVEL%==0 GOTO :Error
|
||||||
pushd "%DEPS_DIR%"
|
exit /b 0
|
||||||
call git clone %1 %2
|
|
||||||
set RET=!ERRORLEVEL!
|
|
||||||
if not "!RET!"=="0" exit /b !RET!
|
|
||||||
popd
|
|
||||||
) else (
|
|
||||||
call cecho.cmd 0 13 "%DEPENDENCY_NAME% already cloned."
|
|
||||||
set RET=0
|
|
||||||
)
|
|
||||||
pushd "%2"
|
|
||||||
call git fetch
|
|
||||||
call cecho.cmd 0 13 "Checking out %DEPENDENCY_NAME% revision %3."
|
|
||||||
call git reset --hard
|
|
||||||
call git checkout %3
|
|
||||||
set RET=%ERRORLEVEL%
|
|
||||||
popd
|
|
||||||
exit /b %RET%
|
|
||||||
|
|
||||||
:: RunCMake - Runs CMake for a CMake-based project
|
:: RunCMake - Runs CMake for a CMake-based project
|
||||||
:: Params: %* cmakeOptions
|
:: Params: %* cmakeOptions
|
||||||
@@ -931,14 +886,9 @@ exit /b %ERRORLEVEL%
|
|||||||
:: Required vars:
|
:: Required vars:
|
||||||
:: - DEPENDENCY_NAME
|
:: - DEPENDENCY_NAME
|
||||||
:InstallCMakeProject
|
:InstallCMakeProject
|
||||||
pushd %1
|
%PWSH_TOOLS% install_cmake_project "%DEPENDENCY_NAME%" "%1" "%2"
|
||||||
call cecho.cmd 0 13 "Installing %2 %DEPENDENCY_NAME%. Please be patient, this will take a while."
|
IF NOT %ERRORLEVEL%==0 GOTO :Error
|
||||||
set COMMAND=cmake --install . --config %2
|
exit /b 0
|
||||||
echo %COMMAND%
|
|
||||||
%COMMAND%
|
|
||||||
set RET=%ERRORLEVEL%
|
|
||||||
popd
|
|
||||||
exit /b %RET%
|
|
||||||
|
|
||||||
:: Checks whether a dependency is already installed for the specified config
|
:: Checks whether a dependency is already installed for the specified config
|
||||||
:: Doesn't work for dependencies, only for those that need separate Debug/Release installs.
|
:: Doesn't work for dependencies, only for those that need separate Debug/Release installs.
|
||||||
|
|||||||
+98
-2
@@ -18,7 +18,7 @@ function mark {
|
|||||||
if (Test-Path -Path $marker_filepath) {
|
if (Test-Path -Path $marker_filepath) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
echo "Marking installation in '$installation_dir' with '$ENV:MARKER_FILE'."
|
cecho.cmd 0 13 "Marking installation in '$installation_dir' with '$ENV:MARKER_FILE'."
|
||||||
New-Item -Path $marker_filepath -ItemType File | Out-Null
|
New-Item -Path $marker_filepath -ItemType File | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ function mark_based_on_artifacts {
|
|||||||
if (Test-Path -Path $marker_filepath) {
|
if (Test-Path -Path $marker_filepath) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
echo "Found artifact '$artifact' for dependency '$dependency_name' $env:BUILD_CFG."
|
cecho.cmd 0 13 "Found artifact '$artifact' for dependency '$dependency_name' $env:BUILD_CFG."
|
||||||
& mark $installation_dir
|
& mark $installation_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,6 +125,102 @@ function setup_build_cfg {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function extract_file {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$dependency_name,
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$filename,
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$destination_dir,
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$dir_after_extraction
|
||||||
|
)
|
||||||
|
if (Test-Path -Path "$dir_after_extraction") {
|
||||||
|
cecho.cmd 0 13 "$dependency_name already extracted into '$dir_after_extraction'. Skipping."
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
cecho.cmd 0 13 "Extracting $dependency_name into '$destination_dir' from '$filename'."
|
||||||
|
7za x "$filename" -o"$destination_dir"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function download_file {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$dependency_name,
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$url,
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$destination_dir,
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$filename
|
||||||
|
)
|
||||||
|
mkdir "$destination_dir" -Force | Out-Null
|
||||||
|
pushd "$destination_dir"
|
||||||
|
if (Test-Path -Path "$filename") {
|
||||||
|
cecho.cmd 0 13 "$dependency_name already downloaded. Skipping."
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
cecho.cmd 0 13 "Downloading $dependency_name into '$destination_dir'"
|
||||||
|
Invoke-WebRequest $url -OutFile $filename
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Required env variables:
|
||||||
|
# - DEPS_DIR
|
||||||
|
function git_clone_and_checkout_revision {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$dependency_name,
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$git_url,
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$dest_dir,
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[string]$revision
|
||||||
|
)
|
||||||
|
if (Test-Path -Path "$dest_dir") {
|
||||||
|
cecho.cmd 0 13 "Cloning $dependency_name is already cloned."
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
cecho.cmd 0 13 "Cloning $dependency_name into '$dest_dir'."
|
||||||
|
pushd "$env:DEPS_DIR"
|
||||||
|
git clone $git_url $dest_dir
|
||||||
|
popd
|
||||||
|
|
||||||
|
pushd "$dest_dir"
|
||||||
|
git fetch
|
||||||
|
cecho.cmd 0 13 "Checking out $dependency_name revision $revision."
|
||||||
|
git reset --hard
|
||||||
|
git checkout $revision
|
||||||
|
popd
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_cmake_project {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$dependency_name,
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$build_dir,
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
[string]$configuration
|
||||||
|
)
|
||||||
|
pushd "$build_dir"
|
||||||
|
cecho.cmd 0 13 "Installing $dependency_name ($configuration). Please be patient, this may take a while."
|
||||||
|
$command = "cmake --install . --config $configuration"
|
||||||
|
cecho.cmd 0 13 "$command"
|
||||||
|
Invoke-Expression $command
|
||||||
|
popd
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function main {
|
function main {
|
||||||
& setup_build_cfg
|
& setup_build_cfg
|
||||||
# Dispatch command.
|
# Dispatch command.
|
||||||
|
|||||||
Reference in New Issue
Block a user