diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 9d93d9c..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,9 +0,0 @@ -# Change Log - -All notable changes to the "vcpkg-integration" extension will be documented in this file. - -Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. - -## [Unreleased] - -- Initial release \ No newline at end of file diff --git a/README.md b/README.md index ef426aa..04a7929 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # vcpkg CMake Tools [Vcpkg VSCode CMake extension](https://marketplace.visualstudio.com/items?itemName=JackBoosY.vcpkg-cmake-tools) provides vcpkg integration in VSCode. + It's still WIP, please help us to improve it in [github](https://github.com/JackBoosY/vcpkg-vscode-extension). ## Requirements @@ -15,7 +16,9 @@ It's still WIP, please help us to improve it in [github](https://github.com/Jack 1. Ctrl + Shift + P 2. Search vcpkg. 3. Select `vcpkg: Enable vcpkg`. + a. Extension will automaticly enable vcpkg if you already set environment variable `VCPKG_ROOT` or already set vcpkg path in settings. + b. If environment variable `VCPKG_ROOT` is not set, please choose vcpkg root folder. 4. Extension will select the triplet (dynamic) according to your system architecture, vcpkg toolchain will be added into cmake settings. @@ -43,6 +46,10 @@ It's still WIP, please help us to improve it in [github](https://github.com/Jack ## Release Notes +### 0.0.4 + +- Support VCPKG_INSTALL_OPTIONS + ### 0.0.3 - Update document. diff --git a/package.json b/package.json index 24e9a6b..22b2277 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "icon": "images/vcpkg-logo.png", "publisher": "JackBoosY", "license": "MIT", - "version": "0.0.3", + "version": "0.0.4", "engines": { "vscode": "^1.76.0" }, @@ -108,12 +108,6 @@ "description": "Installed Directory", "scope": "resource" }, - "vcpkg.general.additionalOptions": { - "type": "string", - "default": "", - "description": "Addtional options", - "scope": "resource" - }, "vcpkg.target.useStaticLib": { "type": "boolean", "default": false, @@ -138,15 +132,15 @@ "description": "Host triplet", "scope": "resource" }, - "vcpkg.target.configuration": { - "type": "string", - "default": "Debug", - "description": "Vcpkg Configuration", - "scope": "resource", - "enum": [ - "Debug", - "Release" - ] + "vcpkg.target.additionalOptions": { + "type": "array", + "items": { + "type": "string", + "title": "Vcpkg install options" + }, + "default": [], + "description": "Additional vcpkg options", + "scope": "resource" } } } diff --git a/src/configuration.ts b/src/configuration.ts index 1d41cde..91500ea 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -14,18 +14,18 @@ export class ConfigurationManager implements vscode.Disposable private _installDependenciesConfig = 'general.installDependencies'; private _autoLinkConfig = 'general.autolink'; private _installDirectoryConfig = 'general.installDirectory'; - private _additionalOptionsConfig = 'general.additionalOptions'; + private _additionalOptionsConfig = 'target.additionalOptions'; private _useStaticLibConfig = 'target.useStaticLib'; private _vcpkgUseDynamicCRTConfig = 'target.useDynamicCRT'; private _targetTripletConfig = 'target.defaultTriplet'; private _hostTripletConfig = 'target.hostTriplet'; - private _vcpkgConfigurationConfig = 'target.configuration'; private _cmakeOptionConfig = 'configureArgs'; private _configConfigSettingConfig = 'configureSettings'; private _vcpkgManifestModeConfig = 'VCPKG_MANIFEST_MODE'; private _vcpkgTargetTripletConfig = 'VCPKG_TARGET_TRIPLET'; + private _vcpkgInstallOptionsConfig = 'VCPKG_INSTALL_OPTIONS'; private _cmakeOptionPrefix = '-D'; private _cmakeOptionEanble = '=ON'; private _cmakeOptionDisable = '=OFF'; @@ -142,6 +142,11 @@ export class ConfigurationManager implements vscode.Disposable return newSettings; } + private isStaticLib(triplet : string) + { + return triplet?.endsWith('-static'); + } + private async addVcpkgToolchain(vcpkgRoot : string) { let cleanConfig = this.getCleanVcpkgToolchian(); @@ -160,16 +165,16 @@ export class ConfigurationManager implements vscode.Disposable if (isStatic) { - if (!currTriplet?.endsWith('-static')) + if (!this.isStaticLib(currTriplet as string)) { currTriplet += '-static'; } } else { - if (currTriplet?.endsWith('-static')) + if (this.isStaticLib(currTriplet as string)) { - currTriplet.substring(0, currTriplet.length - '-static'.length); + (currTriplet as string).substring(0, (currTriplet as string).length - '-static'.length); } } @@ -199,6 +204,9 @@ export class ConfigurationManager implements vscode.Disposable this.updateCurrentTripletSetting(); this.addVcpkgToolchain(vcpkgPath); + + // disable manifest mode by default + this.disableManifest(); } async enableVcpkg() { @@ -352,6 +360,105 @@ export class ConfigurationManager implements vscode.Disposable vscode.window.showInformationMessage('Now use dynamic library / triplet'); } + async onConfigurationChanged(event : vscode.ConfigurationChangeEvent) + { + this.logInfo('detect configuration changed.'); + if (event.affectsConfiguration('vcpkg.' + this._enableVcpkgConfig)) + { + this.logInfo('detect vcpkg enable configuration changed.'); + if (workspace.getConfiguration('vcpkg').get(this._enableVcpkgConfig)) + { + this.enableVcpkg(); + } + else + { + this.disableVcpkg(); + } + } + else if (event.affectsConfiguration('vcpkg.' + this._vcpkgPathConfig)) + { + this.logInfo('detect vcpkg path configuration changed.'); + this.disableVcpkg(); + this.enableVcpkg(); + } + else if (event.affectsConfiguration('vcpkg.' + this._useManifestConfig)) + { + this.logInfo('detect vcpkg manifest configuration changed.'); + if (workspace.getConfiguration('vcpkg').get(this._useManifestConfig)) + { + this.enableManifest(); + } + else + { + this.disableManifest(); + } + } + else if (event.affectsConfiguration('vcpkg.' + this._installDependenciesConfig)) + { + } + else if (event.affectsConfiguration('vcpkg.' + this._autoLinkConfig)) + { + } + else if (event.affectsConfiguration('vcpkg.' + this._installDirectoryConfig)) + { + } + else if (event.affectsConfiguration('vcpkg.' + this._additionalOptionsConfig)) + { + this.logInfo('detect vcpkg install option configuration changed.'); + let extraOptCfgs = workspace.getConfiguration('vcpkg').get>(this._additionalOptionsConfig); + let extraOptions = this._cmakeOptionPrefix + this._vcpkgInstallOptionsConfig + '="'; + if (extraOptCfgs !== undefined) + { + for (let curr in extraOptCfgs) + { + extraOptions += extraOptCfgs[curr] + ';'; + + this.logInfo('add extra vcpkg instal option: ' + extraOptCfgs[curr]); + } + + } + + extraOptions += '"'; + + let cmakeConfigs = this.getAndCleanCMakeOptions(this._additionalOptionsConfig); + cmakeConfigs?.push(extraOptions); + + await workspace.getConfiguration('cmake').update(this._cmakeOptionConfig, cmakeConfigs); + } + else if (event.affectsConfiguration('vcpkg.' + this._useStaticLibConfig)) + { + this.logInfo('detect vcpkg static lib configuration changed.'); + if (workspace.getConfiguration('vcpkg').get(this._useStaticLibConfig)) + { + this.useStaticLib(); + } + else + { + this.useDynamicLib(); + } + } + else if (event.affectsConfiguration('vcpkg.' + this._vcpkgUseDynamicCRTConfig)) + { + if (process.platform === "win32") + { + + } + } + else if (event.affectsConfiguration('vcpkg.' + this._targetTripletConfig)) + { + this.logInfo('detect vcpkg target triplet configuration changed.'); + let currSel = workspace.getConfiguration('vcpkg').get(this._targetTripletConfig); + if (this.isStaticLib(currSel as string)) + { + this.useStaticLib(); + } + else + { + this.useDynamicLib(); + } + } + } + dispose(): void { this.disposables.forEach((item) => item.dispose()); } diff --git a/src/extension.ts b/src/extension.ts index 31f02e1..8e75f35 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -39,6 +39,9 @@ export function activate(context: vscode.ExtensionContext) { // use dynamic lib disposables.push(vscode.commands.registerCommand('vcpkg-integration.use_dynamic_lib', async() => await configMgr.useDynamicLib())); + + // config changed event + disposables.push(vscode.workspace.onDidChangeConfiguration(async(event) => await configMgr.onConfigurationChanged(event))); } // This method is called when your extension is deactivated