Skip to content

Commit

Permalink
Format vcpkg manifest files
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 3, 2024
1 parent 638612e commit 3150811
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
run: |
sudo apt install -y \
shellcheck
. <(curl https://aka.ms/vcpkg-init.sh -L)
- name: Run pre-commit hooks
uses: pre-commit/[email protected]
Expand Down
14 changes: 12 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# See https://pre-commit.com/hooks.html for more hooks
exclude: |
(?x)^(
vcpkg/ |
3rdparty/ |
.clang-format$
)
Expand All @@ -13,7 +12,11 @@ repos:
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude: ^i18n
exclude: |
(?x)^(
i18n/|
vcpkg/
)
- id: check-yaml
- id: check-added-large-files
args: ['--maxkb=8000']
Expand All @@ -35,6 +38,13 @@ repos:
types: [file, shell]
exclude: .docker/android_dev/tools/android-accept-licenses.sh

- id: vcpkg-format
name: vcpkg-format
description: Formatting vcpkg manifests
entry: ./scripts/vcpkg-format.py
language: script
files: '.*vcpkg\.json'

# Shellcheck
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.5
Expand Down
26 changes: 26 additions & 0 deletions scripts/vcpkg-format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3

import subprocess
import sys
import urllib.request
import tempfile
import os
import fcntl


def main():
if sys.platform == "win32":
cmd = ("vcpkg", "format-manifest", *sys.argv[1:])
else:
vcpkg_exe = os.path.join(os.path.expanduser("~"), ".vcpkg", "vcpkg")
if not os.path.isfile(vcpkg_exe):
print(
f"{vcpkg_exe} not found: bootstrap it by running \n\n . <(curl https://aka.ms/vcpkg-init.sh -L)\n\nSee https://github.com/microsoft/vcpkg-tool/blob/main/README.md#installuseremove"
)
return 1
cmd = (vcpkg_exe, "format-manifest", *sys.argv[1:])
return subprocess.call(cmd)


if __name__ == "__main__":
exit(main())
15 changes: 7 additions & 8 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,21 @@
"nu-book-zxing-cpp",
{
"name": "qca",
"default-features": false,
"features":
[
"ossl"
]
"host": true,
"default-features": false
},
{
"name": "qca",
"default-features": false,
"host": true
"features": [
"ossl"
]
},
"qgis",
{
"name": "qgis",
"default-features": false,
"host": true
"host": true,
"default-features": false
},
{
"name": "qtbase",
Expand Down

0 comments on commit 3150811

Please sign in to comment.