mirror of https://github.com/buggins/dlangide.git
show project dependencies
This commit is contained in:
parent
ed758dcdd8
commit
cadd2abf84
|
@ -79,6 +79,9 @@ void testMago() {
|
|||
Log.e("OLE 2 failed to initialize");
|
||||
return;
|
||||
}
|
||||
|
||||
IDebugCoreServer2 coreServer = null;
|
||||
|
||||
//hr = CoCreateInstance(&CLSID_MAGO, null, CLSCTX_ALL, &IID_IDebugEngine2, cast(void**)&piUnknown);
|
||||
hr = CoCreateInstance(&IID_MAGO_NATIVE_ENGINE, //CLSID_MAGO,
|
||||
null,
|
||||
|
@ -118,10 +121,10 @@ void testMago() {
|
|||
envblock ~= 0;
|
||||
opts ~= 0;
|
||||
|
||||
|
||||
IDebugPort2 port;
|
||||
hr = debugEngineLaunch.LaunchSuspended (
|
||||
null,
|
||||
null,
|
||||
port,
|
||||
exe.ptr,//LPCOLESTR
|
||||
args.ptr,
|
||||
dir.ptr,
|
||||
|
|
|
@ -591,6 +591,16 @@ class IDEFrame : AppFrame {
|
|||
return false;
|
||||
}
|
||||
|
||||
private bool loadProject(Project project) {
|
||||
if (!project.load()) {
|
||||
_logPanel.logLine("Cannot read project " ~ project.filename);
|
||||
window.showMessageBox(UIString("Cannot open project"d), UIString("Error occured while opening project "d ~ toUTF32(project.filename)));
|
||||
return false;
|
||||
}
|
||||
_logPanel.logLine(toUTF32("Project file " ~ project.filename ~ " is opened ok"));
|
||||
return true;
|
||||
}
|
||||
|
||||
void openFileOrWorkspace(string filename) {
|
||||
if (filename.isWorkspaceFile) {
|
||||
Workspace ws = new Workspace();
|
||||
|
@ -605,13 +615,7 @@ class IDEFrame : AppFrame {
|
|||
} else if (filename.isProjectFile) {
|
||||
_logPanel.clear();
|
||||
_logPanel.logLine("Trying to open project from " ~ filename);
|
||||
Project project = new Project();
|
||||
if (!project.load(filename)) {
|
||||
_logPanel.logLine("Cannot read project file " ~ filename);
|
||||
window.showMessageBox(UIString("Cannot open project"d), UIString("Error occured while opening project"d));
|
||||
return;
|
||||
}
|
||||
_logPanel.logLine("Project file is opened ok");
|
||||
Project project = new Project(currentWorkspace, filename);
|
||||
string defWsFile = project.defWorkspaceFile;
|
||||
if (currentWorkspace) {
|
||||
Project existing = currentWorkspace.findProject(project.filename);
|
||||
|
@ -628,6 +632,7 @@ class IDEFrame : AppFrame {
|
|||
} else if (result.id == IDEActions.AddToCurrentWorkspace) {
|
||||
// add to current
|
||||
currentWorkspace.addProject(project);
|
||||
loadProject(project);
|
||||
currentWorkspace.save();
|
||||
refreshWorkspace();
|
||||
}
|
||||
|
@ -656,6 +661,7 @@ class IDEFrame : AppFrame {
|
|||
ws.name = project.name;
|
||||
ws.description = project.description;
|
||||
ws.addProject(project);
|
||||
loadProject(project);
|
||||
ws.save(defWsFile);
|
||||
setWorkspace(ws);
|
||||
_logPanel.logLine("Done");
|
||||
|
|
|
@ -147,7 +147,7 @@ class WorkspacePanel : DockWindow {
|
|||
TreeItem root = _tree.items.newChild(_workspace.filename, _workspace.name, "project-development");
|
||||
root.intParam = ProjectItemType.Workspace;
|
||||
foreach(project; _workspace.projects) {
|
||||
TreeItem p = root.newChild(project.filename, project.name, "project-d");
|
||||
TreeItem p = root.newChild(project.filename, project.name, project.isDependency ? "project-d-dependency" : "project-d");
|
||||
p.intParam = ProjectItemType.Project;
|
||||
addProjectItems(p, project.items);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import std.file;
|
|||
import std.json;
|
||||
import std.utf;
|
||||
import std.algorithm;
|
||||
import std.process;
|
||||
|
||||
/// return true if filename matches rules for workspace file names
|
||||
bool isProjectFile(string filename) {
|
||||
|
@ -230,16 +231,24 @@ class Project : WorkspaceItem {
|
|||
protected ProjectFolder _items;
|
||||
protected ProjectSourceFile _mainSourceFile;
|
||||
protected SettingsFile _projectFile;
|
||||
protected bool _isDependency;
|
||||
protected string _dependencyVersion;
|
||||
|
||||
protected string[] _sourcePaths;
|
||||
protected string[] _builderSourcePaths;
|
||||
|
||||
|
||||
this(string fname = null) {
|
||||
this(Workspace ws, string fname = null, string dependencyVersion = null) {
|
||||
super(fname);
|
||||
_workspace = ws;
|
||||
_items = new ProjectFolder(fname);
|
||||
_dependencyVersion = dependencyVersion;
|
||||
_isDependency = _dependencyVersion.length > 0;
|
||||
}
|
||||
|
||||
@property bool isDependency() { return _isDependency; }
|
||||
@property string dependencyVersion() { return _dependencyVersion; }
|
||||
|
||||
/// returns project's own source paths
|
||||
@property string[] sourcePaths() { return _sourcePaths; }
|
||||
/// returns project's own source paths
|
||||
|
@ -346,6 +355,10 @@ class Project : WorkspaceItem {
|
|||
|
||||
try {
|
||||
_name = toUTF32(_projectFile.getString("name"));
|
||||
if (_isDependency) {
|
||||
_name ~= "-"d;
|
||||
_name ~= toUTF32(_dependencyVersion.startsWith("~") ? _dependencyVersion[1..$] : _dependencyVersion);
|
||||
}
|
||||
_description = toUTF32(_projectFile.getString("description"));
|
||||
Log.d(" project name: ", _name);
|
||||
Log.d(" project description: ", _description);
|
||||
|
@ -355,7 +368,8 @@ class Project : WorkspaceItem {
|
|||
|
||||
Log.i("Project source paths: ", sourcePaths);
|
||||
Log.i("Builder source paths: ", builderSourcePaths);
|
||||
|
||||
if (!_isDependency)
|
||||
loadSelections();
|
||||
} catch (JSONException e) {
|
||||
Log.e("Cannot parse json", e);
|
||||
return false;
|
||||
|
@ -365,5 +379,82 @@ class Project : WorkspaceItem {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Project[] _dependencies;
|
||||
@property Project[] dependencies() { return _dependencies; }
|
||||
protected bool addDependency(Project dep) {
|
||||
if (_workspace)
|
||||
_workspace.addDependencyProject(dep);
|
||||
_dependencies ~= dep;
|
||||
return true;
|
||||
}
|
||||
bool loadSelections() {
|
||||
_dependencies.length = 0;
|
||||
DubPackageFinder finder = new DubPackageFinder();
|
||||
scope(exit) destroy(finder);
|
||||
SettingsFile selectionsFile = new SettingsFile(buildNormalizedPath(_dir, "dub.selections.json"));
|
||||
if (!selectionsFile.load())
|
||||
return false;
|
||||
Setting versions = selectionsFile.objectByPath("versions");
|
||||
if (!versions)
|
||||
return false;
|
||||
string[string] versionMap = versions.strMap;
|
||||
foreach(packageName, packageVersion; versionMap) {
|
||||
string fn = finder.findPackage(packageName, packageVersion);
|
||||
Log.d("dependency ", packageName, " ", packageVersion, " : ", fn ? fn : "NOT FOUND");
|
||||
if (fn) {
|
||||
Project p = new Project(_workspace, fn, packageVersion);
|
||||
if (p.load()) {
|
||||
addDependency(p);
|
||||
} else {
|
||||
Log.e("cannot load dependency package ", packageName, " ", packageVersion, " from file ", fn);
|
||||
destroy(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class DubPackageFinder {
|
||||
string systemDubPath;
|
||||
string userDubPath;
|
||||
string tempPath;
|
||||
this() {
|
||||
version(Windows){
|
||||
systemDubPath = buildNormalizedPath(environment.get("ProgramData"), "dub", "packages");
|
||||
userDubPath = buildNormalizedPath(environment.get("APPDATA"), "dub", "packages");
|
||||
tempPath = buildNormalizedPath(environment.get("TEMP"), "dub", "packages");
|
||||
} else version(Posix){
|
||||
systemDubPath = "/var/lib/dub/packages";
|
||||
userDubPath = buildNormalizedPath(environment.get("HOME"), ".dub", "packages");
|
||||
if(!userDubPath.isAbsolute)
|
||||
userDubPath = buildNormalizedPath(getcwd(), userDubPath);
|
||||
tempPath = "/tmp/packages";
|
||||
}
|
||||
}
|
||||
|
||||
protected string findPackage(string packageDir, string packageName, string packageVersion) {
|
||||
string fullName = packageVersion.startsWith("~") ? packageName ~ "-" ~ packageVersion[1..$] : packageName ~ "-" ~ packageVersion;
|
||||
string pathName = absolutePath(buildNormalizedPath(packageDir, fullName));
|
||||
if (pathName.exists && pathName.isDir) {
|
||||
string fn = buildNormalizedPath(pathName, "dub.json");
|
||||
if (fn.exists && fn.isFile)
|
||||
return fn;
|
||||
fn = buildNormalizedPath(pathName, "package.json");
|
||||
if (fn.exists && fn.isFile)
|
||||
return fn;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
string findPackage(string packageName, string packageVersion) {
|
||||
string res = null;
|
||||
res = findPackage(userDubPath, packageName, packageVersion);
|
||||
if (res)
|
||||
return res;
|
||||
res = findPackage(systemDubPath, packageName, packageVersion);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,17 @@ class Workspace : WorkspaceItem {
|
|||
fillStartupProject();
|
||||
}
|
||||
|
||||
bool addDependencyProject(Project p) {
|
||||
for (int i = 0; i < _projects.length; i++) {
|
||||
if (_projects[i].filename.equal(p.filename)) {
|
||||
_projects[i] = p;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
addProject(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
string absoluteToRelativePath(string path) {
|
||||
return toForwardSlashSeparator(relativePath(path, _dir));
|
||||
}
|
||||
|
@ -108,6 +119,8 @@ class Workspace : WorkspaceItem {
|
|||
json["description"] = JSONValue(toUTF8(_description));
|
||||
JSONValue[string] projects;
|
||||
foreach (Project p; _projects) {
|
||||
if (p.isDependency)
|
||||
continue; // don't save dependency
|
||||
string pname = toUTF8(p.name);
|
||||
string ppath = absoluteToRelativePath(p.filename);
|
||||
projects[pname] = JSONValue(ppath);
|
||||
|
@ -147,7 +160,7 @@ class Workspace : WorkspaceItem {
|
|||
Log.d("project: ", key, " path:", path);
|
||||
if (!isAbsolute(path))
|
||||
path = buildNormalizedPath(_dir, path); //, "dub.json"
|
||||
Project project = new Project(path);
|
||||
Project project = new Project(this, path);
|
||||
_projects ~= project;
|
||||
project.load();
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 330 B |
|
@ -17,6 +17,7 @@ res/mdpi/edit-redo.png
|
|||
res/mdpi/edit-undo.png
|
||||
res/mdpi/edit-unindent.png
|
||||
res/mdpi/project-d.png
|
||||
res/mdpi/project-d-dependency.png
|
||||
res/mdpi/project-development.png
|
||||
res/mdpi/project-open.png
|
||||
res/mdpi/run-build.png
|
||||
|
|
Loading…
Reference in New Issue