Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into miroman/checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
miroman9364 committed Oct 11, 2023
2 parents 680c47c + 4835145 commit d9a3dac
Show file tree
Hide file tree
Showing 20 changed files with 202 additions and 1,650 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ bin/
# Node.js generated files for tree-sitter
build/
node_modules/
tree-sitter-dscexpression/bindings/
tree-sitter-dscexpression/src/
tree-sitter-dscexpression/parser.*
tree-sitter-dscexpression/binding.gyp
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"./ntstatuserror/Cargo.toml",
"./ntuserinfo/Cargo.toml",
"./osinfo/Cargo.toml",
"./pal/Cargo.toml",
"./registry/Cargo.toml",
"./tools/test_group_resource/Cargo.toml",
"./tools/dsctest/Cargo.toml",
"./tree-sitter-dscexpression/Cargo.toml",
"./y2j/Cargo.toml"
],
"rust-analyzer.showUnlinkedFileNotification": true,
Expand Down
33 changes: 20 additions & 13 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ New-Item -ItemType Directory $target > $null

# make sure dependencies are built first so clippy runs correctly
$windows_projects = @("pal", "ntreg", "ntstatuserror", "ntuserinfo", "registry")
$projects = @("dsc_lib", "dsc", "osinfo", "process", "tools/test_group_resource", "y2j", "powershellgroup", "tools/dsctest")
$pedantic_unclean_projects = @("tree-sitter-dscexpression", "ntreg")
$projects = @("tree-sitter-dscexpression", "dsc_lib", "dsc", "osinfo", "process", "tools/test_group_resource", "y2j", "powershellgroup", "tools/dsctest")
$pedantic_unclean_projects = @("ntreg")
$clippy_unclean_projects = @("tree-sitter-dscexpression")
$skip_test_projects_on_windows = @("tree-sitter-dscexpression")

if ($IsWindows) {
$projects += $windows_projects
Expand All @@ -106,10 +108,17 @@ foreach ($project in $projects) {
try {
Push-Location "$PSScriptRoot/$project" -ErrorAction Stop

if ($project -eq 'tree-sitter-dscexpression') {
./build.ps1
}

if (Test-Path "./Cargo.toml")
{
if ($Clippy) {
if ($pedantic_unclean_projects -contains $project) {
if ($clippy_unclean_projects -contains $project) {
Write-Verbose -Verbose "Skipping clippy for $project"
}
elseif ($pedantic_unclean_projects -contains $project) {
Write-Verbose -Verbose "Running clippy for $project"
cargo clippy @flags -- -Dwarnings
}
Expand Down Expand Up @@ -198,23 +207,21 @@ if ($Test) {
Install-Module Pester -WarningAction Ignore
}

"For debug - env:PATH is:"
$env:PATH

foreach ($project in $projects) {
## Build format_json
if ($IsWindows -and $skip_test_projects_on_windows -contains $project) {
Write-Verbose -Verbose "Skipping test for $project on Windows"
continue
}

Write-Host -ForegroundColor Cyan "Testing $project ..."
try {
Push-Location "$PSScriptRoot/$project"
if (Test-Path "./Cargo.toml")
{
if (Test-Path "./Cargo.toml")
{
cargo test
cargo test

if ($LASTEXITCODE -ne 0) {
$failed = $true
}
if ($LASTEXITCODE -ne 0) {
$failed = $true
}
}
} finally {
Expand Down
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"tree-sitter-cli": "^0.20.8"
}
}
19 changes: 0 additions & 19 deletions tree-sitter-dscexpression/binding.gyp

This file was deleted.

28 changes: 0 additions & 28 deletions tree-sitter-dscexpression/bindings/node/binding.cc

This file was deleted.

19 changes: 0 additions & 19 deletions tree-sitter-dscexpression/bindings/node/index.js

This file was deleted.

40 changes: 0 additions & 40 deletions tree-sitter-dscexpression/bindings/rust/build.rs

This file was deleted.

52 changes: 0 additions & 52 deletions tree-sitter-dscexpression/bindings/rust/lib.rs

This file was deleted.

36 changes: 28 additions & 8 deletions tree-sitter-dscexpression/build.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
#requires -version 7.4

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# check if tools are installed

$PSNativeCommandUseErrorActionPreference = $true
$ErrorActionPreference = 'Stop'
function Invoke-NativeCommand($cmd) {
Invoke-Expression $cmd
if ($LASTEXITCODE -ne 0) {
throw "Command $cmd failed with exit code $LASTEXITCODE"
}
}

if ($null -eq (Get-Command npm -ErrorAction Ignore)) {
Write-Host 'Installing Node'

if ($IsWindows) {
winget install OpenJS.NodeJS.LTS
}
elseif ($IsMacOS) {
brew install node
}
else {
sudo apt-get install nodejs
sudo apt-get install npm
}
}

npm list tree-sitter-cli
if ($LASTEXITCODE -ne 0) {
npm install tree-sitter-cli
}

npx tree-sitter generate
node-gyp configure
node-gyp build
npx tree-sitter test
Invoke-NativeCommand 'npx tree-sitter generate'
Invoke-NativeCommand 'npx tree-sitter test'
Loading

0 comments on commit d9a3dac

Please sign in to comment.