add a 'unicode' property to modules (not yet supported by mingw, need to add a librar...
[reactos.git] / reactos / tools / rbuild / module.cpp
index b114b7a..004fe92 100644 (file)
 using std::string;
 using std::vector;
 
+string
+Right ( const string& s, size_t n )
+{
+       if ( n > s.size() )
+               return s;
+       return string ( &s[s.size()-n] );
+}
+
 string
 Replace ( const string& s, const string& find, const string& with )
 {
@@ -240,6 +248,23 @@ Module::Module ( const Project& project,
        else
                extension = GetDefaultModuleExtension ();
 
+       att = moduleNode.GetAttribute ( "unicode", false );
+       if ( att != NULL )
+       {
+               const char* p = att->value.c_str();
+               if ( !stricmp ( p, "true" ) || !stricmp ( p, "yes" ) )
+                       isUnicode = true;
+               else if ( !stricmp ( p, "false" ) || !stricmp ( p, "no" ) )
+                       isUnicode = false;
+               else
+               {
+                       throw InvalidAttributeValueException (
+                               moduleNode.location,
+                               "unicode",
+                               att->value );
+               }
+       }
+
        att = moduleNode.GetAttribute ( "entrypoint", false );
        if ( att != NULL )
                entrypoint = att->value;
@@ -310,11 +335,20 @@ Module::Module ( const Project& project,
        else
                useWRC = true;
 
-       att = moduleNode.GetAttribute ( "warnings", false );
+       att = moduleNode.GetAttribute ( "allowwarnings", false );
+       if ( att == NULL )
+       {
+               att = moduleNode.GetAttribute ( "warnings", false );
+               if ( att != NULL )
+               {
+                       printf ( "%s: WARNING: 'warnings' attribute of <module> is deprecated, use 'allowwarnings' instead\n",
+                               moduleNode.location.c_str() );
+               }
+       }
        if ( att != NULL )
-               enableWarnings = att->value == "true";
+               allowWarnings = att->value == "true";
        else
-               enableWarnings = false;
+               allowWarnings = false;
 
        att = moduleNode.GetAttribute ( "aliasof", false );
        if ( type == Alias && att != NULL )
@@ -663,9 +697,15 @@ Module::GetDefaultModuleEntrypoint () const
                        return "_DllMain@12";
                case Win32CUI:
                case Test:
-                       return "_mainCRTStartup";
+                       if ( isUnicode )
+                               return "_wmainCRTStartup";
+                       else
+                               return "_mainCRTStartup";
                case Win32GUI:
-                       return "_WinMainCRTStartup";
+                       if ( isUnicode )
+                               return "_wWinMainCRTStartup";
+                       else
+                               return "_WinMainCRTStartup";
                case KernelModeDriver:
                        return "_DriverEntry@8";
                case BuildTool: