Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# ---- Build trees / output dirs ----
/build*/
/out*/
/bin/
/lib/
/obj/

# ---- CMake ----
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
CTestTestfile.cmake
DartConfiguration.tcl
CMakeScripts/
CMakeUserPresets.json

# CMake package/build metadata
*.cmake.user
install_manifest.txt
compile_commands.json

# Generated Make/Ninja files
Makefile
build.ninja
.ninja_deps
.ninja_log

# ---- Testing / coverage ----
Testing/
coverage/
*.gcda
*.gcno
*.gcov
*.profraw
*.profdata

# ---- IDE / editor ----
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/msvc-cmake.ps1

.idea/
*.code-workspace

# ---- macOS ----
.DS_Store

# ---- Linux ----
*~

# ---- Windows ----
Thumbs.db
Desktop.ini
*.tmp
*.log

# MSVC / Visual Studio build artifacts
*.suo
*.user
*.userosscache
*.sln.docstates
*.VC.db
*.VC.opendb
*.ipch
*.pdb
*.idb
*.ilk
*.obj
*.o
*.a
*.lib
*.dll
*.exe
*.exp

# ---- Android / NDK / Gradle (if used for cross builds) ----
.gradle/
local.properties
.cxx/
.externalNativeBuild/
44 changes: 44 additions & 0 deletions .vscode/msvc-cmake.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# msvc-cmake.ps1
# Locates the latest MSVC installation via vswhere, initialises the x64 build
# environment from vcvarsall.bat, then forwards every argument to cmake unchanged.
#
# Usage (from tasks.json):
# powershell -ExecutionPolicy Bypass -File msvc-cmake.ps1 [cmake args...]

$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (-not (Test-Path $vswhere)) {
# Some VS layouts put vswhere under Program Files instead of (x86)
$vswhere = "${env:ProgramFiles}\Microsoft Visual Studio\Installer\vswhere.exe"
}
if (-not (Test-Path $vswhere)) {
Write-Error "vswhere.exe not found. Please install Visual Studio (any edition)."
exit 1
}

$vsPath = & $vswhere -latest -products * `
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
-property installationPath

if (-not $vsPath) {
Write-Error "No Visual Studio with C++ tools (VC.Tools.x86.x64) found."
exit 1
}

$vcvarsall = Join-Path $vsPath "VC\Auxiliary\Build\vcvarsall.bat"
if (-not (Test-Path $vcvarsall)) {
Write-Error "vcvarsall.bat not found at: $vcvarsall"
exit 1
}

Write-Host "Using MSVC from: $vsPath"

# Run vcvarsall, capture every env var it produces, apply them to this process.
$envOutput = cmd /c "`"$vcvarsall`" x64 >nul 2>&1 && set"
foreach ($line in $envOutput) {
if ($line -match '^([^=]+)=(.*)$') {
[System.Environment]::SetEnvironmentVariable($Matches[1], $Matches[2], 'Process')
}
}

& cmake @args
exit $LASTEXITCODE
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cmake.generator": "Ninja",
"cmake.preferredGenerators": [
"Ninja"
],
"cmake.useVsDeveloperEnvironment": "always",
"cmake.useCMakePresets": "never",
"cmake.buildDirectory": "${workspaceFolder}/build/${buildType}",
"cmake.configureOnOpen": true,
"cmake.configureSettings": {
"LIBUSB_BUILD_SHARED_LIBS": true
}
}
68 changes: 68 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Configure libusb (CMake)",
"type": "shell",
"command": "powershell",
"args": [
"-ExecutionPolicy", "Bypass",
"-File", "${workspaceFolder}/.vscode/msvc-cmake.ps1",
"-S", "${workspaceFolder}",
"-B", "${workspaceFolder}/build",
"-G", "Ninja",
"-DCMAKE_BUILD_TYPE=Debug",
"-DBUILD_SHARED_LIBS=ON",
"-DLIBUSB_BUILD_TESTING=ON",
"-DLIBUSB_ENABLE_DEBUG_LOGGING=ON"
],
"problemMatcher": []
},
{
"label": "Build libusb (CMake)",
"type": "shell",
"command": "powershell",
"args": [
"-ExecutionPolicy", "Bypass",
"-File", "${workspaceFolder}/.vscode/msvc-cmake.ps1",
"--build",
"${workspaceFolder}/build"
],
"dependsOn": "Configure libusb (CMake)",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Configure libusb (CMake Release)",
"type": "shell",
"command": "powershell",
"args": [
"-ExecutionPolicy", "Bypass",
"-File", "${workspaceFolder}/.vscode/msvc-cmake.ps1",
"-S", "${workspaceFolder}",
"-B", "${workspaceFolder}/build-release",
"-G", "Ninja",
"-DCMAKE_BUILD_TYPE=Release",
"-DBUILD_SHARED_LIBS=ON"
],
"problemMatcher": []
},
{
"label": "Build libusb (CMake Release)",
"type": "shell",
"command": "powershell",
"args": [
"-ExecutionPolicy", "Bypass",
"-File", "${workspaceFolder}/.vscode/msvc-cmake.ps1",
"--build",
"${workspaceFolder}/build-release"
],
"dependsOn": "Configure libusb (CMake Release)",
"group": "build",
"problemMatcher": []
}
]
}
Loading