Skip to content

Commit

Permalink
Merge pull request #282 from adamfowleruk/develop
Browse files Browse the repository at this point in the history
Added more samples, quick find window file caps shortcuts, and compile commands json creation
  • Loading branch information
adamfowleruk authored Dec 16, 2019
2 parents a27058b + d1c9c18 commit 403d5a4
Show file tree
Hide file tree
Showing 87 changed files with 3,362 additions and 16 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,16 @@ libpaladin.so
*.gcno
*.info
Tests/out
Paladin/Templates/Sample\ VerticalSlider/VerticalSlider
Paladin/Templates/Sample\ AwesomeSaver/AwesomeSaver
Paladin/Templates/Sample\ ButtonPress/ButtonPress
Paladin/Templates/Sample\ FallLeaves/FallLeaves
Paladin/Templates/Sample\ FileDialog/FileDialog
Paladin/Templates/Sample\ HaikuFortune/HaikuFortune
Paladin/Templates/Sample\ ListDirectory/ListDirectory
Paladin/Templates/Sample\ ListItems/ListItems
Paladin/Templates/Sample\ LoadResources/LoadResources
Paladin/Templates/Sample\ MenuBar/MenuBar
Paladin/compile_commands.json


36 changes: 33 additions & 3 deletions Paladin/BuildSystem/ProjectBuilder.cpp
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>
Expand All @@ -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"
Expand All @@ -34,7 +47,8 @@ ProjectBuilder::ProjectBuilder(void)
fIsBuilding(false),
fTotalFilesToBuild(0L),
fTotalFilesBuilt(0L),
fManager(gCPUCount)
fManager(gCPUCount),
fCommands()
{
}

Expand All @@ -45,7 +59,8 @@ ProjectBuilder::ProjectBuilder(const BMessenger &target)
fIsBuilding(false),
fTotalFilesToBuild(0L),
fTotalFilesBuilt(0L),
fManager(gCPUCount)
fManager(gCPUCount),
fCommands()
{
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
Expand Down Expand Up @@ -296,7 +320,6 @@ ProjectBuilder::BuildThread(void *data)
Project *proj = parent->fProject;

thread_id thisThread = find_thread(NULL);


BMessage msg;
BString errstr;
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions Paladin/BuildSystem/ProjectBuilder.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#ifndef PROJECT_BUILDER_H
#define PROJECT_BUILDER_H

#include <vector>

#include <Locker.h>
#include <Messenger.h>
#include <String.h>

#include "CompileCommand.h"
#include "ErrorParser.h"

enum
Expand Down Expand Up @@ -84,6 +87,8 @@ class ProjectBuilder : public BLocker
int32 fPostBuildAction;

ThreadManager fManager;

std::vector<CompileCommand> fCommands;
};

#endif
6 changes: 6 additions & 0 deletions Paladin/BuildSystem/SourceFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ SourceFile::Precompile(BuildInfo &info, const char *options)
}


BString
SourceFile::GetCompileCommand(BuildInfo &info,const char *options)
{
return BString("");
}

void
SourceFile::Compile(BuildInfo &info, const char *options)
{
Expand Down
1 change: 1 addition & 0 deletions Paladin/BuildSystem/SourceFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class SourceFile

virtual bool CheckNeedsBuild(BuildInfo &info, bool check_deps = true);
virtual void Precompile(BuildInfo &info, const char *options);
virtual BString GetCompileCommand(BuildInfo &info,const char *options);
virtual void Compile(BuildInfo &info, const char *options);
virtual void PostBuild(BuildInfo &info, const char *options);
virtual void RemoveObjects(BuildInfo &info);
Expand Down
24 changes: 20 additions & 4 deletions Paladin/BuildSystem/SourceTypeC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,8 @@ SourceTypeC::GetName(void) const
}


void
SourceFileC::Compile(BuildInfo &info, const char *options)

BString
SourceFileC::GetCompileCommand(BuildInfo &info,const char *options)
{
BString abspath = GetPath().GetFullPath();
if (abspath[0] != '/')
Expand Down Expand Up @@ -408,7 +407,24 @@ SourceFileC::Compile(BuildInfo &info, const char *options)
compileString << options;

compileString << "'" << abspath
<< "' -o '" << GetObjectPath(info).GetFullPath() << "' 2>&1";
<< "' -o '" << GetObjectPath(info).GetFullPath() << "'";

return compileString;
}

void
SourceFileC::Compile(BuildInfo &info, const char *options)

{
BString abspath = GetPath().GetFullPath();
if (abspath[0] != '/')
{
abspath.Prepend("/");
abspath.Prepend(info.projectFolder.GetFullPath());
}

BString compileString(GetCompileCommand(info,options));
compileString << " 2>&1";

BString errmsg;
RunPipedCommand(compileString.String(), errmsg, true);
Expand Down
1 change: 1 addition & 0 deletions Paladin/BuildSystem/SourceTypeC.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class SourceFileC : public SourceFile
bool UsesBuild(void) const;
void UpdateDependencies(BuildInfo &info);
bool CheckNeedsBuild(BuildInfo &info, bool check_deps = true);
virtual BString GetCompileCommand(BuildInfo &info,const char *options);
void Compile(BuildInfo &info, const char *options);

DPath GetObjectPath(BuildInfo &info);
Expand Down
23 changes: 23 additions & 0 deletions Paladin/CompileCommand.cpp
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()
{
}

24 changes: 24 additions & 0 deletions Paladin/CompileCommand.h
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
32 changes: 32 additions & 0 deletions Paladin/CompileCommandWriter.cpp
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;
}
21 changes: 21 additions & 0 deletions Paladin/CompileCommandWriter.h
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
16 changes: 10 additions & 6 deletions Paladin/Paladin.pld
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ DEPENDENCY=AppDebug.h|Project.h|BuildSystem/BuildInfo.h|ThirdParty/DPath.h|Build
SOURCEFILE=DebugTools.cpp
DEPENDENCY=DebugTools.h
SOURCEFILE=ErrorWindow.cpp
DEPENDENCY=ErrorWindow.h|BuildSystem/ErrorParser.h|ThirdParty/DListView.h|DebugTools.h|MsgDefs.h|Project.h|BuildSystem/BuildInfo.h|ThirdParty/DPath.h|BuildSystem/ErrorParser.h|ProjectPath.h|ProjectPath.h|BuildSystem/ProjectBuilder.h|ProjectWindow.h|ProjectStatus.h|ProjectSettingsWindow.h|ThirdParty/AutoTextControl.h
DEPENDENCY=ErrorWindow.h|BuildSystem/ErrorParser.h|ThirdParty/DListView.h|DebugTools.h|MsgDefs.h|Project.h|BuildSystem/BuildInfo.h|ThirdParty/DPath.h|BuildSystem/ErrorParser.h|ProjectPath.h|ProjectPath.h|BuildSystem/ProjectBuilder.h|CompileCommand.h|ProjectWindow.h|ProjectStatus.h|ProjectSettingsWindow.h|ThirdParty/AutoTextControl.h
SOURCEFILE=FileActions.cpp
DEPENDENCY=FileActions.h|ThirdParty/DPath.h|Globals.h|CodeLib.h|ThirdParty/LockableList.h|Project.h|BuildSystem/BuildInfo.h|BuildSystem/ErrorParser.h|ProjectPath.h|BuildSystem/ErrorParser.h|ProjectPath.h|DebugTools.h
SOURCEFILE=FileUtils.cpp
Expand All @@ -43,7 +43,7 @@ DEPENDENCY=LibWindow.h|ThirdParty/DWindow.h|Globals.h|CodeLib.h|ThirdParty/DPath
SOURCEFILE=Makemake.cpp
DEPENDENCY=Makemake.h|ThirdParty/DPath.h|Project.h|BuildSystem/BuildInfo.h|BuildSystem/ErrorParser.h|ProjectPath.h|BuildSystem/ErrorParser.h|ProjectPath.h|Makefile.h|BuildSystem/SourceFile.h
SOURCEFILE=Paladin.cpp
DEPENDENCY=Paladin.h|AboutWindow.h|DebugTools.h|ThirdParty/DPath.h|BuildSystem/ErrorParser.h|FileUtils.h|Globals.h|CodeLib.h|ThirdParty/LockableList.h|Project.h|BuildSystem/BuildInfo.h|BuildSystem/ErrorParser.h|ProjectPath.h|ProjectPath.h|ThirdParty/LaunchHelper.h|Makemake.h|MsgDefs.h|BuildSystem/ProjectBuilder.h|ProjectWindow.h|ProjectStatus.h|ProjectSettingsWindow.h|ThirdParty/AutoTextControl.h|SourceControl/SCMManager.h|SourceControl/SourceControl.h|Project.h|ThirdParty/Settings.h|BuildSystem/SourceFile.h|StartWindow.h|TemplateWindow.h|TemplateManager.h|PaladinFileFilter.h
DEPENDENCY=Paladin.h|AboutWindow.h|DebugTools.h|ThirdParty/DPath.h|BuildSystem/ErrorParser.h|FileUtils.h|Globals.h|CodeLib.h|ThirdParty/LockableList.h|Project.h|BuildSystem/BuildInfo.h|BuildSystem/ErrorParser.h|ProjectPath.h|ProjectPath.h|ThirdParty/LaunchHelper.h|Makemake.h|MsgDefs.h|BuildSystem/ProjectBuilder.h|CompileCommand.h|ProjectWindow.h|ProjectStatus.h|ProjectSettingsWindow.h|ThirdParty/AutoTextControl.h|SourceControl/SCMManager.h|SourceControl/SourceControl.h|Project.h|ThirdParty/Settings.h|BuildSystem/SourceFile.h|StartWindow.h|TemplateWindow.h|TemplateManager.h|PaladinFileFilter.h
SOURCEFILE=Paladin.rdef
SOURCEFILE=PaladinFileFilter.cpp
DEPENDENCY=PaladinFileFilter.h|Project.h|BuildSystem/BuildInfo.h|ThirdParty/DPath.h|BuildSystem/ErrorParser.h|ProjectPath.h|BuildSystem/ErrorParser.h|ProjectPath.h
Expand All @@ -60,7 +60,7 @@ DEPENDENCY=ProjectSettingsWindow.h|ThirdParty/AutoTextControl.h|ThirdParty/DList
SOURCEFILE=ProjectStatus.cpp
DEPENDENCY=ProjectStatus.h
SOURCEFILE=ProjectWindow.cpp
DEPENDENCY=ProjectWindow.h|BuildSystem/ProjectBuilder.h|BuildSystem/ErrorParser.h|ProjectStatus.h|ProjectSettingsWindow.h|ThirdParty/AutoTextControl.h|AddNewFileWindow.h|ThirdParty/DWindow.h|AltTabFilter.h|MsgDefs.h|AppDebug.h|AsciiWindow.h|CodeLibWindow.h|CodeLib.h|ThirdParty/DPath.h|DebugTools.h|BuildSystem/ErrorParser.h|ErrorWindow.h|FileActions.h|BuildSystem/FileFactory.h|BuildSystem/SourceType.h|FindOpenFileWindow.h|FindWindow.h|ThirdParty/GetTextWindow.h|ThirdParty/DWindow.h|Globals.h|ThirdParty/LockableList.h|Project.h|BuildSystem/BuildInfo.h|ProjectPath.h|ProjectPath.h|GroupRenameWindow.h|ThirdParty/LaunchHelper.h|LibWindow.h|LicenseManager.h|Makemake.h|Paladin.h|PrefsWindow.h|ProjectList.h|QuickFindWindow.h|RunArgsWindow.h|SourceControl/SCMManager.h|SourceControl/SourceControl.h|Project.h|SourceControl/SCMOutputWindow.h|ThirdParty/Settings.h|BuildSystem/SourceFile.h|VRegWindow.h
DEPENDENCY=ProjectWindow.h|BuildSystem/ProjectBuilder.h|CompileCommand.h|BuildSystem/ErrorParser.h|ProjectStatus.h|ProjectSettingsWindow.h|ThirdParty/AutoTextControl.h|AddNewFileWindow.h|ThirdParty/DWindow.h|AltTabFilter.h|MsgDefs.h|AppDebug.h|AsciiWindow.h|CodeLibWindow.h|CodeLib.h|ThirdParty/DPath.h|DebugTools.h|BuildSystem/ErrorParser.h|ErrorWindow.h|FileActions.h|BuildSystem/FileFactory.h|BuildSystem/SourceType.h|FindOpenFileWindow.h|FindWindow.h|ThirdParty/GetTextWindow.h|ThirdParty/DWindow.h|Globals.h|ThirdParty/LockableList.h|Project.h|BuildSystem/BuildInfo.h|ProjectPath.h|ProjectPath.h|GroupRenameWindow.h|ThirdParty/LaunchHelper.h|LibWindow.h|LicenseManager.h|Makemake.h|Paladin.h|PrefsWindow.h|ProjectList.h|QuickFindWindow.h|RunArgsWindow.h|SourceControl/SCMManager.h|SourceControl/SourceControl.h|Project.h|SourceControl/SCMOutputWindow.h|ThirdParty/Settings.h|BuildSystem/SourceFile.h|VRegWindow.h
SOURCEFILE=QuickFindWindow.cpp
DEPENDENCY=QuickFindWindow.h|ThirdParty/AutoTextControl.h|DebugTools.h|ThirdParty/EscapeCancelFilter.h|Globals.h|CodeLib.h|ThirdParty/DPath.h|ThirdParty/LockableList.h|Project.h|BuildSystem/BuildInfo.h|BuildSystem/ErrorParser.h|ProjectPath.h|BuildSystem/ErrorParser.h|ProjectPath.h|MsgDefs.h
SOURCEFILE=RunArgsWindow.cpp
Expand All @@ -75,15 +75,19 @@ SOURCEFILE=TerminalWindow.cpp
DEPENDENCY=TerminalWindow.h|ThirdParty/DWindow.h|DebugTools.h
SOURCEFILE=ThirdParty/TextFile.h
GROUP=Build System
EXPANDGROUP=no
EXPANDGROUP=yes
SOURCEFILE=BuildSystem/BuildInfo.cpp
DEPENDENCY=BuildSystem/BuildInfo.h|ThirdParty/DPath.h|BuildSystem/ErrorParser.h|ProjectPath.h
SOURCEFILE=CompileCommand.cpp
DEPENDENCY=CompileCommand.h
SOURCEFILE=CompileCommandWriter.cpp
DEPENDENCY=CompileCommandWriter.h|CompileCommand.h
SOURCEFILE=BuildSystem/ErrorParser.cpp
DEPENDENCY=BuildSystem/ErrorParser.h
SOURCEFILE=BuildSystem/FileFactory.cpp
DEPENDENCY=BuildSystem/FileFactory.h|BuildSystem/SourceType.h|ThirdParty/DPath.h|BuildSystem/SourceTypeC.h|BuildSystem/ErrorParser.h|BuildSystem/SourceFile.h|BuildSystem/SourceTypeLex.h|BuildSystem/SourceTypeLib.h|BuildSystem/SourceTypeResource.h|BuildSystem/SourceTypeRez.h|BuildSystem/SourceTypeShell.h|BuildSystem/SourceTypeText.h|BuildSystem/SourceTypeYacc.h
SOURCEFILE=BuildSystem/ProjectBuilder.cpp
DEPENDENCY=BuildSystem/ProjectBuilder.h|BuildSystem/ErrorParser.h|DebugTools.h|Globals.h|CodeLib.h|ThirdParty/DPath.h|ThirdParty/LockableList.h|Project.h|BuildSystem/BuildInfo.h|ProjectPath.h|BuildSystem/ErrorParser.h|ProjectPath.h|ThirdParty/LaunchHelper.h|Project.h|BuildSystem/SourceFile.h|BuildSystem/StatCache.h|TerminalWindow.h|ThirdParty/DWindow.h
DEPENDENCY=BuildSystem/ProjectBuilder.h|CompileCommand.h|BuildSystem/ErrorParser.h|CompileCommandWriter.h|DebugTools.h|Globals.h|CodeLib.h|ThirdParty/DPath.h|ThirdParty/LockableList.h|Project.h|BuildSystem/BuildInfo.h|ProjectPath.h|BuildSystem/ErrorParser.h|ProjectPath.h|ThirdParty/LaunchHelper.h|Project.h|BuildSystem/SourceFile.h|BuildSystem/StatCache.h|TerminalWindow.h|ThirdParty/DWindow.h
SOURCEFILE=BuildSystem/SourceFile.cpp
DEPENDENCY=BuildSystem/SourceFile.h|ThirdParty/DPath.h|BuildSystem/ErrorParser.h|BuildSystem/BuildInfo.h|ProjectPath.h|Globals.h|CodeLib.h|ThirdParty/LockableList.h|Project.h|BuildSystem/BuildInfo.h|BuildSystem/ErrorParser.h|ProjectPath.h|BuildSystem/StatCache.h
SOURCEFILE=BuildSystem/SourceType.cpp
Expand Down Expand Up @@ -179,7 +183,7 @@ LIBRARY=B_FIND_PATH_LIB_DIRECTORY/libtracker.so
LIBRARY=B_FIND_PATH_LIB_DIRECTORY/libtranslation.so
RUNARGS=
CCDEBUG=yes
CCPROFILE=yes
CCPROFILE=no
CCOPSIZE=no
CCOPLEVEL=0
CCTARGETTYPE=0
Expand Down
Loading

0 comments on commit 403d5a4

Please sign in to comment.