mirror of https://github.com/buggins/dlangide.git
source and import paths
This commit is contained in:
parent
41c534d2b7
commit
00577332a1
|
@ -14,6 +14,7 @@ import dlangui.widgets.popup;
|
||||||
import dlangui.dialogs.dialog;
|
import dlangui.dialogs.dialog;
|
||||||
import dlangui.dialogs.filedlg;
|
import dlangui.dialogs.filedlg;
|
||||||
import dlangui.core.stdaction;
|
import dlangui.core.stdaction;
|
||||||
|
import dlangui.core.files;
|
||||||
|
|
||||||
import dlangide.ui.commands;
|
import dlangide.ui.commands;
|
||||||
import dlangide.ui.wspanel;
|
import dlangide.ui.wspanel;
|
||||||
|
@ -311,6 +312,14 @@ class IDEFrame : AppFrame {
|
||||||
_logPanel = new OutputPanel("output");
|
_logPanel = new OutputPanel("output");
|
||||||
_logPanel.compilerLogIssueClickHandler = &onCompilerLogIssueClick;
|
_logPanel.compilerLogIssueClickHandler = &onCompilerLogIssueClick;
|
||||||
_logPanel.appendText(null, "DlangIDE is started\nHINT: Try to open some DUB project\n"d);
|
_logPanel.appendText(null, "DlangIDE is started\nHINT: Try to open some DUB project\n"d);
|
||||||
|
string dubPath = findExecutablePath("dub");
|
||||||
|
string dmdPath = findExecutablePath("dmd");
|
||||||
|
string ldcPath = findExecutablePath("ldc2");
|
||||||
|
string gdcPath = findExecutablePath("gdc");
|
||||||
|
_logPanel.appendText(null, dubPath ? ("dub path: "d ~ toUTF32(dubPath) ~ "\n"d) : ("dub is not found! cannot build projects without DUB\n"d));
|
||||||
|
_logPanel.appendText(null, dmdPath ? ("dmd path: "d ~ toUTF32(dmdPath) ~ "\n"d) : ("dmd compiler is not found!\n"d));
|
||||||
|
_logPanel.appendText(null, ldcPath ? ("ldc path: "d ~ toUTF32(ldcPath) ~ "\n"d) : ("ldc compiler is not found!\n"d));
|
||||||
|
_logPanel.appendText(null, gdcPath ? ("gdc path: "d ~ toUTF32(gdcPath) ~ "\n"d) : ("gdc compiler is not found!\n"d));
|
||||||
|
|
||||||
_dockHost.addDockedWindow(_logPanel);
|
_dockHost.addDockedWindow(_logPanel);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ module dlangide.workspace.project;
|
||||||
import dlangide.workspace.workspace;
|
import dlangide.workspace.workspace;
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
import dlangui.core.collections;
|
import dlangui.core.collections;
|
||||||
|
import dlangui.core.settings;
|
||||||
import std.path;
|
import std.path;
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.json;
|
import std.json;
|
||||||
|
@ -204,17 +205,51 @@ class WorkspaceItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// detect DMD source paths
|
||||||
|
string[] dmdSourcePaths() {
|
||||||
|
string[] res;
|
||||||
|
version(Windows) {
|
||||||
|
import dlangui.core.files;
|
||||||
|
string dmdPath = findExecutablePath("dmd");
|
||||||
|
if (dmdPath) {
|
||||||
|
string dmdDir = buildNormalizedPath(dirName(dmdPath), "..", "..", "src");
|
||||||
|
res ~= absolutePath(buildNormalizedPath(dmdDir, "druntime", "import"));
|
||||||
|
res ~= absolutePath(buildNormalizedPath(dmdDir, "phobos"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res ~= "/usr/include/dmd/druntime/import";
|
||||||
|
res ~= "/usr/include/dmd/phobos";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/// DLANGIDE D project
|
/// DLANGIDE D project
|
||||||
class Project : WorkspaceItem {
|
class Project : WorkspaceItem {
|
||||||
protected Workspace _workspace;
|
protected Workspace _workspace;
|
||||||
protected bool _opened;
|
protected bool _opened;
|
||||||
protected ProjectFolder _items;
|
protected ProjectFolder _items;
|
||||||
protected ProjectSourceFile _mainSourceFile;
|
protected ProjectSourceFile _mainSourceFile;
|
||||||
|
protected SettingsFile _projectFile;
|
||||||
|
|
||||||
|
protected string[] _sourcePaths;
|
||||||
|
protected string[] _builderSourcePaths;
|
||||||
|
|
||||||
|
|
||||||
this(string fname = null) {
|
this(string fname = null) {
|
||||||
super(fname);
|
super(fname);
|
||||||
_items = new ProjectFolder(fname);
|
_items = new ProjectFolder(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// returns project's own source paths
|
||||||
|
@property string[] sourcePaths() { return _sourcePaths; }
|
||||||
|
/// returns project's own source paths
|
||||||
|
@property string[] builderSourcePaths() {
|
||||||
|
if (!_builderSourcePaths) {
|
||||||
|
_builderSourcePaths = dmdSourcePaths();
|
||||||
|
}
|
||||||
|
return _builderSourcePaths;
|
||||||
|
}
|
||||||
|
|
||||||
string relativeToAbsolutePath(string path) {
|
string relativeToAbsolutePath(string path) {
|
||||||
if (isAbsolute(path))
|
if (isAbsolute(path))
|
||||||
return path;
|
return path;
|
||||||
|
@ -238,11 +273,23 @@ class Project : WorkspaceItem {
|
||||||
return buildNormalizedPath(_filename.dirName, toUTF8(name) ~ WORKSPACE_EXTENSION);
|
return buildNormalizedPath(_filename.dirName, toUTF8(name) ~ WORKSPACE_EXTENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectFolder findItems() {
|
ProjectFolder findItems(string[] srcPaths) {
|
||||||
ProjectFolder folder = new ProjectFolder(_filename);
|
ProjectFolder folder = new ProjectFolder(_filename);
|
||||||
folder.project = this;
|
folder.project = this;
|
||||||
folder.loadDir(relativeToAbsolutePath("src"));
|
string path = relativeToAbsolutePath("src");
|
||||||
folder.loadDir(relativeToAbsolutePath("source"));
|
if (folder.loadDir(path))
|
||||||
|
_sourcePaths ~= path;
|
||||||
|
path = relativeToAbsolutePath("source");
|
||||||
|
if (folder.loadDir(path))
|
||||||
|
_sourcePaths ~= path;
|
||||||
|
foreach(customPath; srcPaths) {
|
||||||
|
path = relativeToAbsolutePath(customPath);
|
||||||
|
foreach(existing; _sourcePaths)
|
||||||
|
if (path.equal(existing))
|
||||||
|
continue; // already exists
|
||||||
|
if (folder.loadDir(path))
|
||||||
|
_sourcePaths ~= path;
|
||||||
|
}
|
||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,24 +333,29 @@ class Project : WorkspaceItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
override bool load(string fname = null) {
|
override bool load(string fname = null) {
|
||||||
|
if (!_projectFile)
|
||||||
|
_projectFile = new SettingsFile();
|
||||||
_mainSourceFile = null;
|
_mainSourceFile = null;
|
||||||
if (fname.length > 0)
|
if (fname.length > 0)
|
||||||
filename = fname;
|
filename = fname;
|
||||||
if (!exists(filename) || !isFile(filename)) {
|
if (!_projectFile.load(_filename)) {
|
||||||
|
Log.e("failed to load project from file ", _filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Log.d("Reading project from file ", _filename);
|
Log.d("Reading project from file ", _filename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
string jsonSource = readText!string(_filename);
|
_name = toUTF32(_projectFile.getString("name"));
|
||||||
JSONValue json = parseJSON(jsonSource);
|
_description = toUTF32(_projectFile.getString("description"));
|
||||||
_name = toUTF32(json["name"].str);
|
|
||||||
_description = toUTF32(json["description"].str);
|
|
||||||
Log.d(" project name: ", _name);
|
Log.d(" project name: ", _name);
|
||||||
Log.d(" project description: ", _description);
|
Log.d(" project description: ", _description);
|
||||||
|
string[] srcPaths = _projectFile.getStringArray("sourcePaths");
|
||||||
_items = findItems();
|
_items = findItems(srcPaths);
|
||||||
findMainSourceFile();
|
findMainSourceFile();
|
||||||
|
|
||||||
|
Log.i("Project source paths: ", sourcePaths);
|
||||||
|
Log.i("Builder source paths: ", builderSourcePaths);
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
Log.e("Cannot parse json", e);
|
Log.e("Cannot parse json", e);
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue