diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..80b2bb4 --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/.vscode/msvc-cmake.ps1 b/.vscode/msvc-cmake.ps1 new file mode 100644 index 0000000..e61be10 --- /dev/null +++ b/.vscode/msvc-cmake.ps1 @@ -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 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..fe9b566 --- /dev/null +++ b/.vscode/settings.json @@ -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 + } +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..1a4665f --- /dev/null +++ b/.vscode/tasks.json @@ -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": [] + } + ] +}