added validation for <directory>'s name attribute
authorRoyce Mitchell III <royce3@ev1.net>
Sun, 13 Mar 2005 06:31:38 +0000 (06:31 +0000)
committerRoyce Mitchell III <royce3@ev1.net>
Sun, 13 Mar 2005 06:31:38 +0000 (06:31 +0000)
create dk/nkm/lib if it doesn't exist

svn path=/branches/xmlbuildsystem/; revision=13994

reactos/Makefile
reactos/tools/rbuild/XML.cpp
reactos/tools/rbuild/module.cpp
reactos/tools/rbuild/project.cpp
reactos/tools/rbuild/rbuild.h

index e0d3f8b..3d318c7 100644 (file)
@@ -99,16 +99,20 @@ else # mingw32-windows
        NUL = NUL
 endif
 
-ifneq ($(ROS_INTERMEDIATE),)
-$(ROS_INTERMEDIATE)tools: $(ROS_INTERMEDIATE)
-       ${nmkdir} $(ROS_INTERMEDIATE)tools
-endif
-
 ifneq ($(ROS_INTERMEDIATE),)
 $(ROS_INTERMEDIATE):
        ${nmkdir} $(ROS_INTERMEDIATE)
+$(ROS_INTERMEDIATE)tools: $(ROS_INTERMEDIATE)
+       ${nmkdir} $@
+$(ROS_INTERMEDIATE)dk: $(ROS_INTERMEDIATE)
+       ${nkmdir} $@
+$(ROS_INTERMEDIATE)dk$(SEP)nkm: $(ROS_INTERMEDIATE)dk
+       ${nkmdir} $@
 endif
 
+$(ROS_INTERMEDIATE)dk$(SEP)nkm$(SEP)lib: $(ROS_INTERMEDIATE)dk$(SEP)nkm
+       ${nmkdir} $@
+
 NTOSKRNL_MC = .$(SEP)ntoskrnl$(SEP)ntoskrnl.mc
 KERNEL32_MC = .$(SEP)lib$(SEP)kernel32$(SEP)kernel32.mc
 BUILDNO_H = .$(SEP)include$(SEP)reactos$(SEP)buildno.h
index e3f42de..07b9c8f 100644 (file)
@@ -179,8 +179,8 @@ Path::RelativeFromWorkingDirectory ( const string& path )
                vout.push_back ( vpath[i++] );\r
 \r
        // now merge vout into a string again\r
-       string out = ".";\r
-       for ( i = 0; i < vout.size(); i++ )\r
+       string out = vout[0];\r
+       for ( i = 1; i < vout.size(); i++ )\r
        {\r
                out += "/" + vout[i];\r
        }\r
index 7a9e4a6..57a070e 100644 (file)
@@ -19,6 +19,25 @@ FixSeparator ( const string& s )
        return s2;\r
 }\r
 \r
+string\r
+GetSubPath (\r
+       const string& location,\r
+       const string& path,\r
+       const string& att_value )\r
+{\r
+       if ( !att_value.size() )\r
+               throw InvalidBuildFileException (\r
+                       location,\r
+                       "<directory> tag has empty 'name' attribute" );\r
+       if ( strpbrk ( att_value.c_str (), "/\\?*:<>|" ) )\r
+               throw InvalidBuildFileException (\r
+                       location,\r
+                       "<directory> tag has invalid characters in 'name' attribute" );\r
+       if ( !path.size() )\r
+               return att_value;\r
+       return FixSeparator(path + CSEP + att_value);\r
+}\r
+\r
 string\r
 GetExtension ( const string& filename )\r
 {\r
@@ -252,7 +271,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
        {\r
                const XMLAttribute* att = e.GetAttribute ( "name", true );\r
                assert(att);\r
-               subpath = FixSeparator ( path + CSEP + att->value );\r
+               subpath = GetSubPath ( e.location, path, att->value );\r
        }\r
        else if ( e.name == "include" )\r
        {\r
@@ -508,10 +527,10 @@ Module::GetDependencyPath () const
 {\r
        if ( HasImportLibrary () )\r
        {\r
-               return ssprintf ( "dk%snkm%slib%slib%s.a",\r
-                                 SSEP,\r
-                                 SSEP,\r
-                                 SSEP,\r
+               return ssprintf ( "dk%cnkm%clib%clib%s.a",\r
+                                 CSEP,\r
+                                 CSEP,\r
+                                 CSEP,\r
                                  name.c_str () );\r
        }\r
        else\r
index e929c0c..e3d51fa 100644 (file)
@@ -182,7 +182,8 @@ Project::ReadXml ()
                if ( head->subElements[i]->name == "project" )\r
                {\r
                        node = head->subElements[i];\r
-                       this->ProcessXML ( "." );\r
+                       string path;\r
+                       this->ProcessXML ( path );\r
                        return;\r
                }\r
        }\r
@@ -254,7 +255,7 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
        {\r
                const XMLAttribute* att = e.GetAttribute ( "name", true );\r
                assert(att);\r
-               subpath = path + CSEP + att->value;\r
+               subpath = GetSubPath ( e.location, path, att->value );\r
        }\r
        else if ( e.name == "include" )\r
        {\r
index 926909f..7c718d2 100644 (file)
@@ -6,15 +6,17 @@
 #ifdef WIN32\r
 #include <direct.h>\r
 #include <io.h>\r
-#endif\r
+#endif/*WIN32*/\r
 #include <sys/stat.h>\r
 #include <time.h>\r
 #ifdef _MSC_VER\r
 #include <sys/utime.h>\r
-#else\r
+#else/*_MSC_VER*/\r
 #include <utime.h>\r
+#ifdef WIN32\r
 #include <process.h>\r
-#endif\r
+#endif/*WIN32*/\r
+#endif/*_MSC_VER*/\r
 \r
 #include "ssprintf.h"\r
 #include "exception.h"\r
@@ -524,10 +526,15 @@ public:
        void ProcessXML();\r
 };\r
 \r
-\r
 extern std::string\r
 FixSeparator ( const std::string& s );\r
 \r
+extern std::string\r
+GetSubPath (\r
+       const std::string& location,\r
+       const std::string& path,\r
+       const std::string& att_value );\r
+\r
 extern std::string\r
 GetExtension ( const std::string& filename );\r
 \r