Skip to content

Commit

Permalink
skipping gtk on arm and windows
Browse files Browse the repository at this point in the history
  • Loading branch information
venkat0907 committed Aug 7, 2023
1 parent 9d73507 commit 53de31c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 25 deletions.
9 changes: 4 additions & 5 deletions base/fix-vcpkg-json.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ param([String]$fileName='vcpkg.json', [switch]$removeOpenCV, [switch]$removeCUD

$v = Get-Content $fileName -raw | ConvertFrom-Json

if($removeCUDA.IsPresent)
if ($removeCUDA.IsPresent)
{
$opencv = $v.dependencies | Where-Object { $_.name -eq 'opencv4'}
$opencv.features= $opencv.features | Where-Object { $_ -ne 'cuda' }
$opencv.features= $opencv.features | Where-Object { $_ -ne 'cudnn' }
$opencv.features= $opencv.features | Where-Object { $_ -ne 'gtk' }
$v.dependencies |
Where-Object { $_.name -eq 'opencv4' } |
ForEach-Object { $_.features = $_.features -ne 'cuda' -ne 'cudnn' }
}

if($removeOpenCV.IsPresent)
Expand Down
52 changes: 32 additions & 20 deletions base/fix-vcpkg-json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,47 @@ echo "$v"

# Process command line arguments
if $removeCUDA; then
echo "Removing CUDA..."
opencv=$(echo "$v" | jq '.dependencies[] | select(type == "string" or .name == "opencv4")')
opencv=$(echo "$opencv" | jq '.features |= map(select(. != "cuda" and . != "cudnn"))')
v=$(echo "$v" | jq '.dependencies[] |= select(type == "string" or .name != "opencv4")')
v=$(echo "$v" | jq '.dependencies[] |= select(type != "null")')
v=$(echo "$v" | jq ".dependencies += [$opencv]")
echo "Removing CUDA..."
# Loop through each "opencv4" instance
for index in $(echo "$v" | jq -r '.dependencies | keys | .[]'); do
name=$(echo "$v" | jq -r ".dependencies[$index].name")
if [ "$name" == "opencv4" ]; then
# Remove "cuda" and "cudnn" features for this "opencv4" instance
v=$(echo "$v" | jq ".dependencies[$index].features |= map(select(. != \"cuda\" and . != \"cudnn\"))")
fi
done
fi

if $removeOpenCV; then
echo "Removing OpenCV..."
v=$(echo "$v" | jq '.dependencies[] |= select(type == "string" or .name != "opencv4")')
v=$(echo "$v" | jq '.dependencies[] |= select(type != "null")')
count=$(echo "$v" | jq '.dependencies | length')
for ((index=count-1; index >= 0; index--)); do
name=$(echo "$v" | jq -r ".dependencies[$index].name")
if [ "$name" == "opencv4" ]; then
# Remove the entire "opencv4" instance
v=$(echo "$v" | jq "del(.dependencies[$index])")
fi
done
fi

if $onlyOpenCV; then
echo "Keeping only OpenCV..."
opencv=$(echo "$v" | jq '.dependencies[] | select(.name == "opencv4")')
opencv=$(echo "$opencv" | jq '.features |= map(select(. != "cuda" and . != "cudnn"))')
v=$(echo "$v" | jq '.dependencies = []')
v=$(echo "$v" | jq ".dependencies += [$opencv]")

echo "Keeping only OpenCV..."
# Loop through each dependency and remove other dependencies except "opencv4"
count=$(echo "$v" | jq '.dependencies | length')
for ((index = count - 1; index >= 0; index--)); do
name=$(echo "$v" | jq -r ".dependencies[$index].name")
if [ "$name" != "opencv4" ]; then
# Remove the entire dependency
v=$(echo "$v" | jq "del(.dependencies[$index])")
fi
done
fi

#Save the modified object back to the JSON file
echo "Modified JSON file contents:"
echo "$v" | jq .
echo "$v" | jq . > "$fileName"
# Save the modified object back to the JSON file
echo "Modified JSON file contents:"
echo "$v" | jq .
echo "$v" | jq . > "$fileName"

# Print all command line arguments
echo "Command line arguments:"
echo "$@"

echo "$@"
9 changes: 9 additions & 0 deletions base/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
"webp",
"gtk"
]
},
{
"name": "opencv4",
"default-features": false,
"features": [
"gtk"
],
"platform": "(linux \u0026 x64)",
"$reason": "skip linux:arm64 and windows"
},
"libjpeg-turbo",
"openh264",
Expand Down

0 comments on commit 53de31c

Please sign in to comment.