From 97b77bb87cc481ab4aee81fb01103ee3c3acb2cd Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 6 Aug 2011 12:40:43 +0000 Subject: [PATCH] umk: support for 'inline' assembly and build method git-svn-id: svn://ultimatepp.org/upp/trunk@3742 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ide/Builders/Build.cpp | 6 ++--- uppsrc/ide/Builders/Build.h | 2 ++ uppsrc/ide/Core/Core.h | 2 +- uppsrc/ide/Core/Workspace.cpp | 8 +++++-- uppsrc/umk/umake.cpp | 45 +++++++++++++++++++++++++++++++---- uppsrc/umk/umake.h | 3 +++ 6 files changed, 55 insertions(+), 11 deletions(-) diff --git a/uppsrc/ide/Builders/Build.cpp b/uppsrc/ide/Builders/Build.cpp index c78663094..ff39b13a5 100644 --- a/uppsrc/ide/Builders/Build.cpp +++ b/uppsrc/ide/Builders/Build.cpp @@ -4,12 +4,12 @@ #define LDUMP(x) // DUMP(x) -String GetDefaultMethod() +String MakeBuild::GetDefaultMethod() { return LoadFile(ConfigFile("default_method")); } -VectorMap GetMethodVars(const String& method) +VectorMap MakeBuild::GetMethodVars(const String& method) { VectorMap map; LoadVarFile(ConfigFile((String)~method + ".bm"), map); @@ -335,7 +335,7 @@ String MakeBuild::OutDir(const Index& cfg, const String& package, const outdir = AppendFileName(outdir, GetVarsName()); if(!use_target) outdir = AppendFileName(outdir, package); - outdir = AppendFileName(outdir, method + "." + Join(x, ".")); + outdir = AppendFileName(outdir, GetFileTitle(method) + "." + Join(x, ".")); outdir = Filter(outdir, CharFilterSlash); return outdir; } diff --git a/uppsrc/ide/Builders/Build.h b/uppsrc/ide/Builders/Build.h index 9a90bfb26..54191a2e3 100644 --- a/uppsrc/ide/Builders/Build.h +++ b/uppsrc/ide/Builders/Build.h @@ -40,6 +40,8 @@ struct MakeBuild { virtual void ReQualifyCodeBase() = 0; virtual void SetErrorEditor() = 0; virtual String GetMain() = 0; + virtual String GetDefaultMethod(); + virtual VectorMap GetMethodVars(const String& method); struct TransferFileInfo { diff --git a/uppsrc/ide/Core/Core.h b/uppsrc/ide/Core/Core.h index 9d35b08b4..a15827de8 100644 --- a/uppsrc/ide/Core/Core.h +++ b/uppsrc/ide/Core/Core.h @@ -176,7 +176,7 @@ String GetVarsName(); String VarFilePath(); Vector GetUppDirs(); String GetUppDir(); -void SetVar(const String& var, const String& value); +void SetVar(const String& var, const String& val, bool save = true); String GetAnyFileName(const char *path); String GetAnyFileTitle(const char *path); diff --git a/uppsrc/ide/Core/Workspace.cpp b/uppsrc/ide/Core/Workspace.cpp index 7765bf164..ce1893fb7 100644 --- a/uppsrc/ide/Core/Workspace.cpp +++ b/uppsrc/ide/Core/Workspace.cpp @@ -66,6 +66,9 @@ String VarFilePath(String name) { } String VarFilePath() { + String p = varsname; + if(IsFullPath(varsname)) + return varsname; return VarFilePath(GetVarsName()); } @@ -181,9 +184,10 @@ String GetVar(const String& var) { return MainNest().Get(var); } -void SetVar(const String& var, const String& val) { +void SetVar(const String& var, const String& val, bool save) { MainNest().Set(var, val); - SaveVars(GetVarsName()); + if(save) + SaveVars(GetVarsName()); } Vector GetUppDirs() { diff --git a/uppsrc/umk/umake.cpp b/uppsrc/umk/umake.cpp index 70f2cac3d..8bb65a261 100644 --- a/uppsrc/umk/umake.cpp +++ b/uppsrc/umk/umake.cpp @@ -2,6 +2,34 @@ bool SilentMode; +String GetUmkFile(const char *fn) +{ + return GetFileOnPath(fn, + GetHomeDirFile(".upp/umk") + ';' + + GetHomeDirFile(".upp/theide") + ';' + + GetHomeDirFile(".upp/ide") + ';' + + GetHomeDirectory()); +} + +String GetBuildMethodPath(String method) +{ + if(GetFileExt(method) != ".bm") + method << ".bm"; + return GetUmkFile(method); +} + +String Ide::GetDefaultMethod() +{ + return "GCC"; +} + +VectorMap Ide::GetMethodVars(const String& method) +{ + VectorMap map; + LoadVarFile(GetBuildMethodPath(method), map); + return map; +} + void Puts(const char *s) { Cout() << s; @@ -28,11 +56,18 @@ CONSOLE_APP_MAIN if(x[i] == 'l') SilentMode = true; } - if(!LoadVars(arg[0])) { - Puts("Invalid assembly\n"); - SetExitCode(2); - return; + if(!FileExists(GetUmkFile(arg[0] + ".var"))) { + SetVar("UPP", arg[0], false); + String outdir = ConfigFile("_out"); + RealizeDirectory(outdir); + SetVar("OUTPUT", outdir, false); } + else + if(!LoadVars(arg[0])) { + Puts("Invalid assembly\n"); + SetExitCode(2); + return; + } if(!FileExists(SourcePath(arg[1], GetFileTitle(arg[1]) + ".upp"))) { Puts("Package does not exist\n"); SetExitCode(2); @@ -53,7 +88,7 @@ CONSOLE_APP_MAIN if(f.GetCount()) ide.mainconfigparam = f[0].param; String m = arg[2]; - if(!FileExists(ConfigFile((String)m + ".bm"))) { + if(GetBuildMethodPath(m).GetCount() == 0) { SilentMode = false; Puts("Invalid build method\n"); SetExitCode(3); diff --git a/uppsrc/umk/umake.h b/uppsrc/umk/umake.h index c15eb73b6..23215326c 100644 --- a/uppsrc/umk/umake.h +++ b/uppsrc/umk/umake.h @@ -138,6 +138,9 @@ struct Ide : public IdeContext, public MakeBuild { virtual void SetErrorEditor(); virtual String GetMain(); + virtual String GetDefaultMethod(); + virtual VectorMap GetMethodVars(const String& method); + void ExportMakefile(const String& ep); void ExportProject(const String& ep, bool all);