Skip to content

Commit

Permalink
Add some API.
Browse files Browse the repository at this point in the history
GetQueuedCompletionStatusEx
SetFileCompletionNotificationModes
GetFinalPathNameByHandleW
NtCancelIoFileEx

Signed-off-by: deadash <[email protected]>
  • Loading branch information
edsky committed Apr 3, 2024
1 parent b61d774 commit 48f7ca4
Show file tree
Hide file tree
Showing 6 changed files with 2,008 additions and 7 deletions.
71 changes: 71 additions & 0 deletions Build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
param (
[string]$action
)

function Set-EnvironmentVariables {
if ($env:VS_ENV_SET -eq "true") {
Write-Host "Visual Studio environment variables have already been set."
return
}

Write-Host "Locating Visual Studio installation..."
$vsWherePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$installationPath = & $vsWherePath -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath

if ($installationPath -and (Test-Path "$installationPath\Common7\Tools\vsdevcmd.bat")) {
Write-Host "Setting environment variables using VsDevCmd.bat..."
# Set environment variables using VsDevCmd.bat and export them to JSON format
$json = & "${env:COMSPEC}" /s /c "`"$installationPath\Common7\Tools\vsdevcmd.bat`" -no_logo -arch=x86 && powershell -Command `"Get-ChildItem env: | Select-Object Name,Value | ConvertTo-Json`""

# Check if the command executed successfully
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to execute $installationPath\Common7\Tools\vsdevcmd.bat with error code: $LASTEXITCODE"
} else {
# Convert JSON string back to objects and update the environment variables in the current PowerShell session
$envVars = $json | ConvertFrom-Json
foreach ($envVar in $envVars) {
Set-Item -Path "env:$($envVar.Name)" -Value $envVar.Value
}
# Mark environment variables as set
$env:VS_ENV_SET = "true"
}
} else {
Write-Host "Visual Studio installation or VsDevCmd.bat not found."
}

# Set additional environment variables
$env:PATH = "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin;" + $env:PATH
$env:INCLUDE = "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include;" + $env:INCLUDE
$env:LIB = "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib;" + $env:LIB
$env:CL = "/D_USING_V110_SDK71_"
}

function Build {
Write-Host "Starting build process..."
Set-EnvironmentVariables
Push-Location xpstub
nmake
Pop-Location
}

function Clean {
Write-Host "Starting clean process..."
Set-EnvironmentVariables
Push-Location xpstub
nmake clean
Pop-Location
}

Switch ($action) {
"build" {
Build
}
"clean" {
Clean
}
Default {
Write-Host "Usage: Build.ps1 -action [build|clean]"
Write-Host "build: Compiles the project."
Write-Host "clean: Cleans the build artifacts."
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ To compile the project, you need to execute two commands:

1. Build the native components with the batch script:

```bash
make.bat
```powershell
.\Build.ps1 build
```

2. Then build the Rust components:
Expand Down
Loading

0 comments on commit 48f7ca4

Please sign in to comment.