-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #282 from adamfowleruk/develop
Added more samples, quick find window file caps shortcuts, and compile commands json creation
- Loading branch information
Showing
87 changed files
with
3,362 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
/* | ||
* Copyright 2019 Adam Fowler <[email protected]> | ||
* Distributed under the terms of the MIT License. | ||
* | ||
* Authors: | ||
* Adam Fowler, [email protected] | ||
* Others previously, undocumented | ||
*/ | ||
#include "ProjectBuilder.h" | ||
|
||
#include <fstream> | ||
#include <string> | ||
|
||
#include <Alert.h> | ||
#include <Autolock.h> | ||
#include <Catalog.h> | ||
|
@@ -9,6 +20,8 @@ | |
#include <Roster.h> | ||
#include <stdlib.h> | ||
|
||
#include "CompileCommand.h" | ||
#include "CompileCommandWriter.h" | ||
#include "DebugTools.h" | ||
#include "ErrorParser.h" | ||
#include "Globals.h" | ||
|
@@ -34,7 +47,8 @@ ProjectBuilder::ProjectBuilder(void) | |
fIsBuilding(false), | ||
fTotalFilesToBuild(0L), | ||
fTotalFilesBuilt(0L), | ||
fManager(gCPUCount) | ||
fManager(gCPUCount), | ||
fCommands() | ||
{ | ||
} | ||
|
||
|
@@ -45,7 +59,8 @@ ProjectBuilder::ProjectBuilder(const BMessenger &target) | |
fIsBuilding(false), | ||
fTotalFilesToBuild(0L), | ||
fTotalFilesBuilt(0L), | ||
fManager(gCPUCount) | ||
fManager(gCPUCount), | ||
fCommands() | ||
{ | ||
} | ||
|
||
|
@@ -149,6 +164,7 @@ ProjectBuilder::BuildProject(Project *proj, int32 postbuild) | |
|
||
fTotalFilesToBuild = proj->CountDirtyFiles(); | ||
fTotalFilesBuilt = 0; | ||
fCommands.clear(); | ||
for (int32 i = 0; i < threadcount; i++) | ||
fManager.SpawnThread(BuildThread,this); | ||
} | ||
|
@@ -175,6 +191,14 @@ ProjectBuilder::IsBuilding(void) | |
void | ||
ProjectBuilder::DoPostBuild(void) | ||
{ | ||
// Write out compile commands JSON file first | ||
std::string jsonFile(fProject->GetBuildInfo()->projectFolder.GetFullPath()); | ||
jsonFile += std::string("/compile_commands.json"); | ||
STRACE(1,("Writing out compile commands\n")); | ||
STRACE(1,(jsonFile.c_str())); | ||
std::ofstream ofs(jsonFile, std::ofstream::out); | ||
CompileCommandWriter::ToJSONFile(ofs,fCommands); | ||
|
||
// It's really silly to try to run a library! ;-) | ||
if (fProject->TargetType() != TARGET_APP) | ||
return; | ||
|
@@ -296,7 +320,6 @@ ProjectBuilder::BuildThread(void *data) | |
Project *proj = parent->fProject; | ||
|
||
thread_id thisThread = find_thread(NULL); | ||
|
||
|
||
BMessage msg; | ||
BString errstr; | ||
|
@@ -373,6 +396,13 @@ ProjectBuilder::BuildThread(void *data) | |
return B_OK; | ||
} | ||
|
||
CompileCommand cc( | ||
std::string(file->GetPath().GetFileName()), | ||
std::string(file->GetCompileCommand(*proj->GetBuildInfo(),NULL).String()), | ||
std::string(proj->GetBuildInfo()->objectFolder.GetFullPath()) | ||
); | ||
((ProjectBuilder*)data)->fCommands.push_back(cc); | ||
|
||
proj->CompileFile(file); | ||
|
||
if (info->errorList.msglist.CountItems() > 0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2019 Adam Fowler <[email protected]> | ||
* Distributed under the terms of the MIT License. | ||
* | ||
* Authors: | ||
* Adam Fowler, [email protected] | ||
*/ | ||
#include <string> | ||
|
||
#include "CompileCommand.h" | ||
|
||
CompileCommand::CompileCommand(std::string ifile, std::string icommand, std::string idirectory) | ||
: | ||
file(ifile), | ||
command(icommand), | ||
directory(idirectory) | ||
{ | ||
} | ||
|
||
CompileCommand::~CompileCommand() | ||
{ | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2019 Adam Fowler <[email protected]> | ||
* Distributed under the terms of the MIT License. | ||
* | ||
* Authors: | ||
* Adam Fowler, [email protected] | ||
*/ | ||
#ifndef COMPILECOMMAND_H | ||
#define COMPILECOMMAND_H | ||
|
||
#include <string> | ||
|
||
class CompileCommand | ||
{ | ||
public: | ||
CompileCommand(std::string ifile, std::string icommand, std::string idirectory); | ||
~CompileCommand(); | ||
|
||
std::string file; | ||
std::string command; | ||
std::string directory; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2019 Adam Fowler <[email protected]> | ||
* Distributed under the terms of the MIT License. | ||
* | ||
* Authors: | ||
* Adam Fowler, [email protected] | ||
*/ | ||
#include <sstream> | ||
#include <vector> | ||
|
||
#include "CompileCommandWriter.h" | ||
#include "CompileCommand.h" | ||
|
||
int | ||
CompileCommandWriter::ToJSONFile(std::ostream& oss,std::vector<CompileCommand>& commands) | ||
{ | ||
bool first = true; | ||
oss << "[" << std::endl; | ||
for (auto& command: commands) | ||
{ | ||
if (!first) | ||
{ | ||
oss << "," << std::endl; | ||
} | ||
oss << " { \"directory:\": \"" << command.directory << "\"," << std::endl; | ||
oss << " \"command\": \"" << command.command << "\"," << std::endl; | ||
oss << " \"file\": \"" << command.file << "\" }"; // leave for comma or endl | ||
first = false; | ||
} | ||
oss << std::endl << "]" << std::endl; // start with endl to finish last json object line | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef COMPILECOMMANDWRITER_H | ||
#define COMPILECOMMANDWRITER_H | ||
|
||
#include <sstream> | ||
#include <vector> | ||
|
||
class CompileCommand; | ||
|
||
/*! | ||
* This class writes the CompileCommands to a veriety of formats | ||
*/ | ||
class CompileCommandWriter | ||
{ | ||
public: | ||
/*! | ||
* Writes a set of commands to a file. Replaces existing file. Outputs in JSON array format. | ||
*/ | ||
static int ToJSONFile(std::ostream& oss,std::vector<CompileCommand>& commands); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.