aboutsummaryrefslogtreecommitdiffstats
path: root/qt-cpp
diff options
context:
space:
mode:
authorOrkun Tokdemir <orkun.tokdemir@qt.io>2024-11-20 16:39:02 +0100
committerOrkun Tokdemir <orkun.tokdemir@qt.io>2024-11-25 13:14:44 +0000
commit5928f1e4df631d0edce29e684de7c68b4ab1d4a7 (patch)
tree3fa1287ee30943a08602274e7aed87ff29ea781d /qt-cpp
parent121abdb88f6b79f8e8d247212f76d06cadcf3c91 (diff)
qt-cpp: qt-qml: Add build directory
* Pass the build directory to qmlls with `-b` * Detect the build directory change from the CMake extension Change-Id: I8279b444036e174762f9d469fd8b4abdaba66e83 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Diffstat (limited to 'qt-cpp')
-rw-r--r--qt-cpp/src/extension.ts1
-rw-r--r--qt-cpp/src/project.ts27
2 files changed, 26 insertions, 2 deletions
diff --git a/qt-cpp/src/extension.ts b/qt-cpp/src/extension.ts
index 809435c..a3bad17 100644
--- a/qt-cpp/src/extension.ts
+++ b/qt-cpp/src/extension.ts
@@ -119,6 +119,7 @@ export async function initCoreValues() {
const selectedQtPaths = kit ? getQtPathsExe(kit) : undefined;
message.config.set('selectedQtPaths', selectedQtPaths);
message.config.set('workspaceType', QtWorkspaceType.CMakeExt);
+ message.config.set('buildDir', project.buildDir ?? '');
logger.info('Updating coreAPI with message:', message as unknown as string);
coreAPI.update(message);
}
diff --git a/qt-cpp/src/project.ts b/qt-cpp/src/project.ts
index ad8fbf9..a7037a2 100644
--- a/qt-cpp/src/project.ts
+++ b/qt-cpp/src/project.ts
@@ -26,20 +26,26 @@ export async function createCppProject(
if (api) {
cmakeProject = await api.getProject(folder.uri);
}
- return Promise.resolve(new CppProject(folder, context, cmakeProject));
+ const buildDir = await cmakeProject?.getBuildDirectory();
+ return Promise.resolve(
+ new CppProject(folder, context, cmakeProject, buildDir)
+ );
}
// Project class represents a workspace folder in the extension.
export class CppProject implements Project {
private readonly _stateManager: WorkspaceStateManager;
private readonly _cmakeProject: cmakeApi.Project | undefined;
+ private _buildDir: string | undefined;
constructor(
private readonly _folder: vscode.WorkspaceFolder,
readonly _context: vscode.ExtensionContext,
- cmakeProject: cmakeApi.Project | undefined
+ cmakeProject: cmakeApi.Project | undefined,
+ buildDir: string | undefined
) {
this._cmakeProject = cmakeProject;
this._stateManager = new WorkspaceStateManager(_context, _folder);
+ this._buildDir = buildDir;
if (this._cmakeProject) {
this._cmakeProject.onSelectedConfigurationChanged(
@@ -56,6 +62,20 @@ export class CppProject implements Project {
}
}
);
+ this._cmakeProject.onCodeModelChanged(async () => {
+ const prevbuildDir = this._buildDir;
+ const currentBuildDir = await this._cmakeProject?.getBuildDirectory();
+ if (prevbuildDir !== currentBuildDir) {
+ logger.info(
+ 'Build directory changed:',
+ currentBuildDir ?? 'undefined'
+ );
+ this._buildDir = currentBuildDir;
+ const message = new QtWorkspaceConfigMessage(this.folder);
+ message.config.set('buildDir', currentBuildDir);
+ coreAPI?.update(message);
+ }
+ });
}
}
@@ -65,6 +85,9 @@ export class CppProject implements Project {
get folder() {
return this._folder;
}
+ get buildDir() {
+ return this._buildDir;
+ }
dispose() {
logger.info('Disposing project:', this._folder.uri.fsPath);