proj2make: some minor improvements.
- Enable use of `find_directory()` when searching for "etc/makefile". - Fixed a missing return statement on `_l::str()`; - Fix "STATIC" typo on gAppTypes. - Removed some superfluous spaces on the output makefile, added a couple of missing ones. - Avoid adding library paths as include dirs. - Replace BeOS header paths with Haiku's. - Some minor code style changes, here and there. Change-Id: I03f221c39e894fb6ab6ffebd95ffe5e749678540 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7786 Tested-by: Commit checker robot <[email protected]> Reviewed-by: Jérôme Duval <[email protected]> Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Jérôme Duval
parent
26db1794f9
commit
13581b3d2a
Vendored
+33
-25
@@ -45,7 +45,7 @@ string gPLnkString;
|
|||||||
const char* gAppTypes[] = {
|
const char* gAppTypes[] = {
|
||||||
"APP",
|
"APP",
|
||||||
"SHARED",
|
"SHARED",
|
||||||
"STAITC",
|
"STATIC",
|
||||||
"DRIVER"
|
"DRIVER"
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,10 +54,8 @@ string gAppName;
|
|||||||
|
|
||||||
struct hdr
|
struct hdr
|
||||||
{
|
{
|
||||||
uint32 Id() { return
|
uint32 Id() { return static_cast<uint32>(B_BENDIAN_TO_HOST_INT32(fId)); }
|
||||||
static_cast<uint32>(B_BENDIAN_TO_HOST_INT32(fId)); }
|
uint32 Size() { return static_cast<uint32>(B_BENDIAN_TO_HOST_INT32(fSize)); }
|
||||||
uint32 Size() { return
|
|
||||||
static_cast<uint32>(B_BENDIAN_TO_HOST_INT32(fSize)); }
|
|
||||||
const char* Data() { return (char*)(this + 1); }
|
const char* Data() { return (char*)(this + 1); }
|
||||||
private:
|
private:
|
||||||
uint32 fId;
|
uint32 fId;
|
||||||
@@ -118,10 +116,8 @@ CheckFiles(const char* projPath, const char* makePath)
|
|||||||
throw Error("Can not create makefile");
|
throw Error("Can not create makefile");
|
||||||
|
|
||||||
BPath templateFileName;
|
BPath templateFileName;
|
||||||
// not supporter yet in my haiku rev
|
find_directory(B_SYSTEM_DEVELOP_DIRECTORY, &templateFileName);
|
||||||
// find_directory(B_SYSTEM_DEVELOP_DIR, &templateFileName);
|
templateFileName.Append("etc/Makefile");
|
||||||
// templateFileName.Append("etc/makefile");
|
|
||||||
templateFileName.SetTo("/boot/develop/etc/makefile");
|
|
||||||
|
|
||||||
gTemplateFile.open(templateFileName.Path(), fstream::in);
|
gTemplateFile.open(templateFileName.Path(), fstream::in);
|
||||||
if (!gTemplateFile.is_open())
|
if (!gTemplateFile.is_open())
|
||||||
@@ -153,15 +149,17 @@ ParseGenB(hdr* data)
|
|||||||
|
|
||||||
class _l {
|
class _l {
|
||||||
static string _s;
|
static string _s;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
_l() { _s += " " ; }
|
_l() { _s += " "; }
|
||||||
~_l() { _s.resize(_s.size() - 1); }
|
~_l() { _s.resize(_s.size() - 1); }
|
||||||
|
|
||||||
char* str() { _s.c_str(); }
|
const char* str() { return _s.c_str(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
string _l::_s;
|
string _l::_s;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Parse(hdr* current, hdr* parent)
|
Parse(hdr* current, hdr* parent)
|
||||||
{
|
{
|
||||||
@@ -169,13 +167,13 @@ Parse(hdr* current, hdr* parent)
|
|||||||
|
|
||||||
uint32 u = current->Id();
|
uint32 u = current->Id();
|
||||||
char* c = (char*)&u;
|
char* c = (char*)&u;
|
||||||
printf("%#06x:%s%c%c%c%c:%d\n",
|
printf("%#06x:%s%c%c%c%c:%d\n", (uint8*)current - gProjData, l.str(), c[3], c[2], c[1], c[0],
|
||||||
(uint8*)current - gProjData, l.str(),
|
current->Size());
|
||||||
c[3], c[2], c[1], c[0], current->Size());
|
|
||||||
|
|
||||||
bool useGrandParent = false;
|
bool useGrandParent = false;
|
||||||
size_t off = 0;
|
size_t off = 0;
|
||||||
switch(current->Id()) {
|
BString data;
|
||||||
|
switch (current->Id()) {
|
||||||
case 'Fil1':
|
case 'Fil1':
|
||||||
case 'Link':
|
case 'Link':
|
||||||
case 'PLnk':
|
case 'PLnk':
|
||||||
@@ -190,8 +188,19 @@ Parse(hdr* current, hdr* parent)
|
|||||||
useGrandParent = true;
|
useGrandParent = true;
|
||||||
break;
|
break;
|
||||||
case 'SPth':
|
case 'SPth':
|
||||||
|
data = ¤t->Data()[5];
|
||||||
|
// Avoid adding these library paths as include dirs.
|
||||||
|
if ((data.FindFirst("/boot/develop/lib") > -1)
|
||||||
|
|| (data.FindFirst("/boot/beos/system/lib") > -1)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Replace BeOS paths with Haiku's.
|
||||||
|
data.ReplaceFirst("/boot/develop/headers/be", "/boot/system/develop/os");
|
||||||
|
data.ReplaceFirst("/boot/develop/headers/cpp", "/boot/system/develop/c++");
|
||||||
|
data.ReplaceFirst("/boot/develop/headers/posix", "/boot/system/develop/headers/posix");
|
||||||
|
|
||||||
gSPthString += " \\\n\t";
|
gSPthString += " \\\n\t";
|
||||||
gSPthString += ¤t->Data()[5];
|
gSPthString += data.String();
|
||||||
return;
|
return;
|
||||||
case 'PPth':
|
case 'PPth':
|
||||||
gPPthString += " \\\n\t";
|
gPPthString += " \\\n\t";
|
||||||
@@ -240,11 +249,11 @@ ReadProj()
|
|||||||
void
|
void
|
||||||
Proj2Make()
|
Proj2Make()
|
||||||
{
|
{
|
||||||
gFil1String = " ";
|
gFil1String = "";
|
||||||
gLinkString = " ";
|
gLinkString = "";
|
||||||
gPLnkString = " ";
|
gPLnkString = "";
|
||||||
gSPthString = " ";
|
gSPthString = "";
|
||||||
gPPthString = " ";
|
gPPthString = "";
|
||||||
|
|
||||||
ReadProj();
|
ReadProj();
|
||||||
string str;
|
string str;
|
||||||
@@ -260,9 +269,9 @@ Proj2Make()
|
|||||||
else if (str.find("LOCAL_INCLUDE_PATHS") == 0)
|
else if (str.find("LOCAL_INCLUDE_PATHS") == 0)
|
||||||
str = str + gPPthString;
|
str = str + gPPthString;
|
||||||
else if (str.find("TYPE") == 0)
|
else if (str.find("TYPE") == 0)
|
||||||
str = str + gAppTypes[gAppType];
|
str = str + " " + gAppTypes[gAppType];
|
||||||
else if (str.find("NAME") == 0)
|
else if (str.find("NAME") == 0)
|
||||||
str = str + gAppName;
|
str = str + " " + gAppName;
|
||||||
else if (str.find("RSRCS") == 0)
|
else if (str.find("RSRCS") == 0)
|
||||||
str = str + gPLnkString;
|
str = str + gPLnkString;
|
||||||
|
|
||||||
@@ -299,7 +308,7 @@ main(int argc, char** argv)
|
|||||||
|
|
||||||
Proj2Make();
|
Proj2Make();
|
||||||
|
|
||||||
} catch(exception& exc) {
|
} catch (exception& exc) {
|
||||||
cerr << argv[0] << " : " << exc.what() << endl;
|
cerr << argv[0] << " : " << exc.what() << endl;
|
||||||
cerr << kUsageMessage;
|
cerr << kUsageMessage;
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -307,4 +316,3 @@ main(int argc, char** argv)
|
|||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user