Skip to content

Commit 5c32b35

Browse files
committed
test1
1 parent 21ebab0 commit 5c32b35

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

tools/metacall-environment.ps1

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ function Install-VS {
222222
}
223223
}
224224

225+
226+
225227
function Set-C {
226228
$ErrorActionPreference = "Stop"
227229
Write-Output "Installing C dependencies..."
@@ -236,7 +238,7 @@ function Set-C {
236238
Set-Location $ROOT_DIR
237239
$DepsDir = Join-Path $ROOT_DIR 'dependencies'
238240
$vcpkgDir = Join-Path $DepsDir 'vcpkg'
239-
241+
$LLVM_Install_Dir = Join-Path $vcpkgDir 'installed\x64-windows'
240242
# Install vcpkg if missing
241243
if (-not (Test-Path (Join-Path $vcpkgDir 'vcpkg.exe'))) {
242244
Write-Output "Cloning vcpkg into $vcpkgDir..."
@@ -251,49 +253,47 @@ function Set-C {
251253
Write-Output "Installing libffi using vcpkg..."
252254
& (Join-Path $vcpkgDir 'vcpkg.exe') install libffi
253255

254-
# Install LLVM using Chocolatey
255-
Write-Output "Installing LLVM..."
256-
choco install llvm -y
257-
258-
# Clone and build libtcc
259-
$tccRepoUrl = "https://github.com/TinyCC/tinycc.git"
260-
$tccDestination = "$DepsDir\tcc"
261-
if (-not (Test-Path "$tccDestination\.git")) {
262-
Write-Output "Cloning libtcc..."
263-
git clone $tccRepoUrl $tccDestination
264-
} else {
265-
Write-Output "libtcc already cloned."
266-
}
267-
268-
# Build libtcc using Git Bash
269-
$gitBashPath = "C:\Program Files\Git\bin\bash.exe"
270-
if ($gitBashPath) {
271-
Write-Output "Building libtcc..."
272-
Set-Location $tccDestination
273-
& "$gitBashPath" -c "git config --global core.autocrlf input"
274-
$bashCommand = "cd /c/gcc-14.2.0/bin/ && gcc --version"
275-
& "$gitBashPath" -c "$bashCommand" | Tee-Object -Variable output
276-
& "$gitBashPath" -c "sed -i 's/\r$//' configure"
277-
& "$gitBashPath" -c "ls && ./configure && make && make test && make install" | Tee-Object -Variable output
256+
# Download and extract precompiled LLVM binaries
257+
$llvmVersion = "19.1.7"
258+
$installerUrl = "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvmVersion/LLVM-$llvmVersion-win64.exe"
259+
$installerPath = "$env:TEMP\LLVM-$llvmVersion-win64.exe"
260+
261+
# if (-not (Test-Path "C:\Program Files\LLVM\bin\clang.exe")) {
262+
# Write-Output "Downloading LLVM $llvmVersion installer..."
263+
# Invoke-WebRequest -Uri $installerUrl -OutFile $installerPath
264+
265+
# Write-Output "Installing LLVM $llvmVersion..."
266+
# Start-Process -FilePath $installerPath -ArgumentList "/S" -Wait
267+
268+
# Write-Output "Cleaning up installer..."
269+
# Remove-Item $installerPath
270+
# } else {
271+
# Write-Output "LLVM $llvmVersion is already installed in C:\Program Files\LLVM."
272+
# }
273+
274+
# Add LLVM to system PATH
275+
$llvmBinPath = "C:\Program Files\LLVM\bin"
276+
$currentPath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
277+
if ($currentPath -notlike "*$llvmBinPath*") {
278+
Write-Output "Adding LLVM to system PATH..."
279+
$newPath = "$currentPath;$llvmBinPath"
280+
[System.Environment]::SetEnvironmentVariable("Path", $newPath, [System.EnvironmentVariableTarget]::Machine)
278281
} else {
279-
Write-Output "Git Bash not found. Please install Git for Windows."
282+
Write-Output "LLVM bin directory is already in the system PATH."
280283
}
281284

282-
# Write environment options for CMake configuration
283-
$Env_Opts = "$ROOT_DIR\build\CMakeConfig.txt"
284-
$LLVM_Dir = "$env:ProgramFiles\LLVM"
285-
$vcpkgLibDir = "$DepsDir\vcpkg\installed\x64-windows\lib"
286-
$vcpkgIncludeDir = "$DepsDir\vcpkg\installed\x64-windows\include"
287-
$tccLib = "$tccDestination\lib\tcc.lib"
288-
$tccInclude = "$tccDestination\include"
285+
# Set paths for CMake configuration
286+
$vcpkgLibDir = Join-Path $vcpkgDir 'installed\x64-windows\lib'
287+
$vcpkgIncludeDir = Join-Path $vcpkgDir 'installed\x64-windows\include'
288+
$Env_Opts = Join-Path $ROOT_DIR 'build\CMakeConfig.txt'
289289

290290
$cmakeOptions = @(
291-
"-DLIBFFI_LIBRARY=$vcpkgLibDir\libffi.lib"
292-
"-DLIBFFI_INCLUDE_DIR=$vcpkgIncludeDir"
293-
"-DLibClang_INCLUDE_DIR=$LLVM_Dir\include\clang"
294-
"-DLIBCLANG_LIBRARY=$LLVM_Dir\lib\libclang.lib"
295-
"-DTCC_LIBRARY=$tccLib"
296-
"-DTCC_INCLUDE_DIR=$tccInclude"
291+
"set(OPTION_BUILD_LOADERS_C ON CACHE BOOL `"Build C loaders`")"
292+
"set(LIBFFI_LIBRARY `"$vcpkgLibDir\ffi.lib`" CACHE STRING `"Path to libffi library`")"
293+
"set(LIBFFI_INCLUDE_DIR `"$vcpkgIncludeDir`" CACHE STRING `"Path to libffi include directory`")"
294+
"set(LibClang_INCLUDE_DIR `"$llvmBinPath\..\include`" CACHE STRING `"Path to libclang include directory`")"
295+
"set(LIBCLANG_LIBRARY `"$llvmBinPath\..\lib\libclang.lib`" CACHE STRING `"Path to libclang library`")"
296+
"set(CMAKE_TOOLCHAIN_FILE `"$vcpkgDir\scripts\buildsystems\vcpkg.cmake`" CACHE STRING `"Path to vcpkg toolchain file`")"
297297
)
298298

299299
$cmakeOptions | Out-File -Append -FilePath $Env_Opts

0 commit comments

Comments
 (0)