Skip to content

Commit

Permalink
Add files via upload (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
BachToTheFuture authored and scottmc committed Jan 16, 2018
1 parent 0c9c9f3 commit f60155d
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 10 deletions.
1 change: 1 addition & 0 deletions Paladin/Globals.cpp
Expand Up @@ -28,6 +28,7 @@ DPath gLastProjectPath;
DPath gSVNRepoPath;

bool gBuildMode = false;
bool gMakeMode = false;
bool gDontManageHeaders = true;
bool gSingleThreadedBuild = false;
bool gShowFolderOnOpen = false;
Expand Down
1 change: 1 addition & 0 deletions Paladin/Globals.h
Expand Up @@ -51,6 +51,7 @@ extern DPath gProjectPath;
extern DPath gLastProjectPath;
extern DPath gSVNRepoPath;
extern bool gBuildMode;
extern bool gMakeMode;
extern bool gDontManageHeaders;
extern bool gSingleThreadedBuild;
extern bool gShowFolderOnOpen;
Expand Down
77 changes: 67 additions & 10 deletions Paladin/Paladin.cpp
Expand Up @@ -20,6 +20,7 @@
#include "FileUtils.h"
#include "Globals.h"
#include "LaunchHelper.h"
#include "Makemake.h"
#include "MsgDefs.h"
#include "ObjectList.h"
#include "PLocale.h"
Expand Down Expand Up @@ -86,17 +87,19 @@ void
PrintUsage(void)
{
#ifdef USE_TRACE_TOOLS
printf("Usage: Paladin [-b] [-r] [-s] [-d] [-v] [file1 [file2 ...]]\n"
printf("Usage: Paladin [-b] [-m] [-r] [-s] [-d] [-v] [file1 [file2 ...]]\n"
"-b, Build the specified project. Only one file can be specified with this switch.\n"
"-r, Completely rebuild the project\n"
"-s, Use only one thread for building\n"
"-d, Print debugging output\n"
"-v, Make debugging mode verbose\n");
"-m, Generate a makefile for the specified project.\n"
"-r, Completely rebuild the project.\n"
"-s, Use only one thread for building.\n"
"-d, Print debugging output.\n"
"-v, Make debugging mode verbose.\n");
#else
printf("Usage: Paladin [-b] [-r] [-s] [file1 [file2 ...]]\n"
printf("Usage: Paladin [-b] [-m] [-r] [-s] [file1 [file2 ...]]\n"
"-b, Build the specified project. Only one file can be specified with this switch.\n"
"-r, Completely rebuild the project\n"
"-s, Use only one thread for building\n");
"-m, Generate a makefile for the specified project.\n"
"-r, Completely rebuild the project.\n"
"-s, Use only one thread for building.\n");
#endif
}

Expand Down Expand Up @@ -165,6 +168,11 @@ App::ArgvReceived(int32 argc,char **argv)
gBuildMode = true;
break;
}
case 'm':
{
gMakeMode = true;
break;
}
case 'r':
{
gBuildMode = true;
Expand Down Expand Up @@ -259,13 +267,13 @@ App::ArgvReceived(int32 argc,char **argv)
refcount++;
optind++;

if (refcount == 1 && gBuildMode)
if (refcount == 1 && (gBuildMode || gMakeMode))
break;
}

if (refcount > 0)
RefsReceived(&refmsg);
else if (gBuildMode)
else if (gBuildMode || gMakeMode)
Quit();
}

Expand All @@ -283,6 +291,9 @@ App::RefsReceived(BMessage *msg)
if (gBuildMode && isPaladin)
BuildProject(ref);
else
if (gMakeMode && isPaladin)
GenerateMakefile(ref);
else
if (isPaladin || isBeIDE)
LoadProject(ref);
else
Expand Down Expand Up @@ -799,6 +810,52 @@ App::BuildProject(const entry_ref &ref)
fBuilder->BuildProject(proj, POSTBUILD_NOTHING);
}

void
App::GenerateMakefile(const entry_ref &ref)
{
BPath path(&ref);
Project *proj = new Project;

if (proj->Load(path.Path()) != B_OK)
{
BMessage msg(M_BUILD_FAILURE);
PostMessage(&msg);

delete proj;
return;
}

if (proj->IsReadOnly())
{
BString err(path.Path());
err << TR(" is on a read-only disk. Please copy the project to another disk ")
<< TR("or remount the disk with write support to be able to build it.\n");
BMessage msg(M_BUILD_FAILURE);
msg.AddString("errstr",err);
PostMessage(&msg);

delete proj;
return;
}

gProjectList->Lock();
gProjectList->AddItem(proj);
gProjectList->Unlock();

gCurrentProject = proj;
DPath out(proj->GetPath().GetFolder());
out.Append("Makefile");
if (MakeMake(proj, out) == B_OK); {
BEntry entry(out.GetFullPath());
entry_ref new_ref;
if (entry.InitCheck() == B_OK) {
entry.GetRef(&new_ref);
BMessage refMessage(B_REFS_RECEIVED);
refMessage.AddRef("refs",&new_ref);
be_app->PostMessage(&refMessage);
}
}
}

void
App::LoadProject(const entry_ref &givenRef)
Expand Down
1 change: 1 addition & 0 deletions Paladin/Paladin.h
Expand Up @@ -29,6 +29,7 @@ class App : public BApplication

private:
void BuildProject(const entry_ref &ref);
void GenerateMakefile(const entry_ref &ref);
void LoadProject(const entry_ref &ref);
void UpdateRecentItems(const entry_ref &ref);
void PostToProjectWindow(BMessage *msg, entry_ref *file);
Expand Down

0 comments on commit f60155d

Please sign in to comment.