Extract WINE resources at compile-time
authorCasper Hornstrup <chorns@users.sourceforge.net>
Sat, 14 May 2005 17:57:31 +0000 (17:57 +0000)
committerCasper Hornstrup <chorns@users.sourceforge.net>
Sat, 14 May 2005 17:57:31 +0000 (17:57 +0000)
svn path=/branches/xmlbuildsystem/; revision=15280

53 files changed:
reactos/Makefile
reactos/ReactOS.xml
reactos/lib/comctl32/idb_hist_large.bmp [deleted file]
reactos/lib/comctl32/idb_hist_small.bmp [deleted file]
reactos/lib/comctl32/idb_std_large.bmp [deleted file]
reactos/lib/comctl32/idb_std_small.bmp [deleted file]
reactos/lib/comctl32/idb_view_large.bmp [deleted file]
reactos/lib/comctl32/idb_view_small.bmp [deleted file]
reactos/lib/comctl32/idc_copy.cur [deleted file]
reactos/lib/comctl32/idc_divider.cur [deleted file]
reactos/lib/comctl32/idc_divideropen.cur [deleted file]
reactos/lib/comctl32/idc_movebutton.cur [deleted file]
reactos/lib/comctl32/idi_dragarrow.ico [deleted file]
reactos/lib/comctl32/idi_tt_error_sm.ico [deleted file]
reactos/lib/comctl32/idi_tt_info_sm.ico [deleted file]
reactos/lib/comctl32/idi_tt_warn_sm.ico [deleted file]
reactos/lib/comctl32/idt_check.bmp [deleted file]
reactos/lib/comdlg32/800.bmp [deleted file]
reactos/lib/comdlg32/cdrom.ico [deleted file]
reactos/lib/comdlg32/floppy.ico [deleted file]
reactos/lib/comdlg32/folder.ico [deleted file]
reactos/lib/comdlg32/folder2.ico [deleted file]
reactos/lib/comdlg32/fontpics.bmp [deleted file]
reactos/lib/comdlg32/hdisk.ico [deleted file]
reactos/lib/comdlg32/network.ico [deleted file]
reactos/lib/comdlg32/pd32_collate.ico [deleted file]
reactos/lib/comdlg32/pd32_landscape.ico [deleted file]
reactos/lib/comdlg32/pd32_nocollate.ico [deleted file]
reactos/lib/comdlg32/pd32_portrait.ico [deleted file]
reactos/lib/ole32/drag_copy.cur [deleted file]
reactos/lib/ole32/drag_link.cur [deleted file]
reactos/lib/ole32/drag_move.cur [deleted file]
reactos/lib/ole32/nodrop.cur [deleted file]
reactos/lib/shell32/desktop.ico [deleted file]
reactos/lib/shell32/document.ico [deleted file]
reactos/lib/shell32/drive.ico [deleted file]
reactos/lib/shell32/floppy.ico [deleted file]
reactos/lib/shell32/folder.ico [deleted file]
reactos/lib/shell32/folder_open.ico [deleted file]
reactos/lib/shell32/mycomputer.ico [deleted file]
reactos/lib/shell32/netdrive.ico [deleted file]
reactos/lib/shell32/netdrive2.ico [deleted file]
reactos/lib/shell32/printer.ico [deleted file]
reactos/lib/shell32/ramdisk.ico [deleted file]
reactos/tools/bin2res/bin2res.c
reactos/tools/bin2res/bin2res.mak
reactos/tools/rbuild/backend/mingw/mingw.cpp
reactos/tools/rbuild/backend/mingw/mingw.h
reactos/tools/rbuild/backend/mingw/modulehandler.cpp
reactos/tools/rbuild/backend/mingw/modulehandler.h
reactos/tools/rbuild/rbuild.h
reactos/tools/rbuild/rbuild.mak
reactos/tools/rbuild/wineresource.cpp [new file with mode: 0644]

index a6bf8cc..e905b4f 100644 (file)
@@ -229,6 +229,7 @@ include tools/tools.mak
 -include makefile.auto
 
 PREAUTO := \
+       $(BIN2RES_TARGET) \
        $(BUILDNO_H) \
        $(BUGCODES_H) \
        $(BUGCODES_RC) \
index 19136ea..ce1a779 100644 (file)
                <define name="DBG" value="1" />\r
                <property name="DBG_OR_KDBG" value="true" />\r
        </if>\r
+       <if property="DBG" value="0">\r
+               <compilerflag>-O2</compilerflag>\r
+               <compilerflag>-Wno-strict-aliasing</compilerflag>\r
+               <compilerflag>-ftracer</compilerflag>\r
+               <compilerflag>-momit-leaf-frame-pointer</compilerflag>\r
+               <compilerflag>-mpreferred-stack-boundary=2</compilerflag>\r
+       </if>\r
        <if property="KDBG" value="1">\r
                <define name="KDBG" value="1" />\r
                <property name="DBG_OR_KDBG" value="true" />\r
diff --git a/reactos/lib/comctl32/idb_hist_large.bmp b/reactos/lib/comctl32/idb_hist_large.bmp
deleted file mode 100644 (file)
index 20596fa..0000000
Binary files a/reactos/lib/comctl32/idb_hist_large.bmp and /dev/null differ
diff --git a/reactos/lib/comctl32/idb_hist_small.bmp b/reactos/lib/comctl32/idb_hist_small.bmp
deleted file mode 100644 (file)
index 3cc2ab4..0000000
Binary files a/reactos/lib/comctl32/idb_hist_small.bmp and /dev/null differ
diff --git a/reactos/lib/comctl32/idb_std_large.bmp b/reactos/lib/comctl32/idb_std_large.bmp
deleted file mode 100644 (file)
index 4f0e09e..0000000
Binary files a/reactos/lib/comctl32/idb_std_large.bmp and /dev/null differ
diff --git a/reactos/lib/comctl32/idb_std_small.bmp b/reactos/lib/comctl32/idb_std_small.bmp
deleted file mode 100644 (file)
index 8318e44..0000000
Binary files a/reactos/lib/comctl32/idb_std_small.bmp and /dev/null differ
diff --git a/reactos/lib/comctl32/idb_view_large.bmp b/reactos/lib/comctl32/idb_view_large.bmp
deleted file mode 100644 (file)
index 6331b5e..0000000
Binary files a/reactos/lib/comctl32/idb_view_large.bmp and /dev/null differ
diff --git a/reactos/lib/comctl32/idb_view_small.bmp b/reactos/lib/comctl32/idb_view_small.bmp
deleted file mode 100644 (file)
index d1632f2..0000000
Binary files a/reactos/lib/comctl32/idb_view_small.bmp and /dev/null differ
diff --git a/reactos/lib/comctl32/idc_copy.cur b/reactos/lib/comctl32/idc_copy.cur
deleted file mode 100644 (file)
index e4b7021..0000000
Binary files a/reactos/lib/comctl32/idc_copy.cur and /dev/null differ
diff --git a/reactos/lib/comctl32/idc_divider.cur b/reactos/lib/comctl32/idc_divider.cur
deleted file mode 100644 (file)
index 9d679c9..0000000
Binary files a/reactos/lib/comctl32/idc_divider.cur and /dev/null differ
diff --git a/reactos/lib/comctl32/idc_divideropen.cur b/reactos/lib/comctl32/idc_divideropen.cur
deleted file mode 100644 (file)
index 9adc945..0000000
Binary files a/reactos/lib/comctl32/idc_divideropen.cur and /dev/null differ
diff --git a/reactos/lib/comctl32/idc_movebutton.cur b/reactos/lib/comctl32/idc_movebutton.cur
deleted file mode 100644 (file)
index 8ce16d2..0000000
Binary files a/reactos/lib/comctl32/idc_movebutton.cur and /dev/null differ
diff --git a/reactos/lib/comctl32/idi_dragarrow.ico b/reactos/lib/comctl32/idi_dragarrow.ico
deleted file mode 100644 (file)
index bba46b2..0000000
Binary files a/reactos/lib/comctl32/idi_dragarrow.ico and /dev/null differ
diff --git a/reactos/lib/comctl32/idi_tt_error_sm.ico b/reactos/lib/comctl32/idi_tt_error_sm.ico
deleted file mode 100644 (file)
index 523c7fc..0000000
Binary files a/reactos/lib/comctl32/idi_tt_error_sm.ico and /dev/null differ
diff --git a/reactos/lib/comctl32/idi_tt_info_sm.ico b/reactos/lib/comctl32/idi_tt_info_sm.ico
deleted file mode 100644 (file)
index 80bcf36..0000000
Binary files a/reactos/lib/comctl32/idi_tt_info_sm.ico and /dev/null differ
diff --git a/reactos/lib/comctl32/idi_tt_warn_sm.ico b/reactos/lib/comctl32/idi_tt_warn_sm.ico
deleted file mode 100644 (file)
index 4fab813..0000000
Binary files a/reactos/lib/comctl32/idi_tt_warn_sm.ico and /dev/null differ
diff --git a/reactos/lib/comctl32/idt_check.bmp b/reactos/lib/comctl32/idt_check.bmp
deleted file mode 100644 (file)
index 7344a64..0000000
Binary files a/reactos/lib/comctl32/idt_check.bmp and /dev/null differ
diff --git a/reactos/lib/comdlg32/800.bmp b/reactos/lib/comdlg32/800.bmp
deleted file mode 100644 (file)
index 3b7dae2..0000000
Binary files a/reactos/lib/comdlg32/800.bmp and /dev/null differ
diff --git a/reactos/lib/comdlg32/cdrom.ico b/reactos/lib/comdlg32/cdrom.ico
deleted file mode 100644 (file)
index 5673c9c..0000000
Binary files a/reactos/lib/comdlg32/cdrom.ico and /dev/null differ
diff --git a/reactos/lib/comdlg32/floppy.ico b/reactos/lib/comdlg32/floppy.ico
deleted file mode 100644 (file)
index 726f876..0000000
Binary files a/reactos/lib/comdlg32/floppy.ico and /dev/null differ
diff --git a/reactos/lib/comdlg32/folder.ico b/reactos/lib/comdlg32/folder.ico
deleted file mode 100644 (file)
index eeba9f5..0000000
Binary files a/reactos/lib/comdlg32/folder.ico and /dev/null differ
diff --git a/reactos/lib/comdlg32/folder2.ico b/reactos/lib/comdlg32/folder2.ico
deleted file mode 100644 (file)
index 6f1e662..0000000
Binary files a/reactos/lib/comdlg32/folder2.ico and /dev/null differ
diff --git a/reactos/lib/comdlg32/fontpics.bmp b/reactos/lib/comdlg32/fontpics.bmp
deleted file mode 100644 (file)
index 6c3c1b6..0000000
Binary files a/reactos/lib/comdlg32/fontpics.bmp and /dev/null differ
diff --git a/reactos/lib/comdlg32/hdisk.ico b/reactos/lib/comdlg32/hdisk.ico
deleted file mode 100644 (file)
index 688dbe5..0000000
Binary files a/reactos/lib/comdlg32/hdisk.ico and /dev/null differ
diff --git a/reactos/lib/comdlg32/network.ico b/reactos/lib/comdlg32/network.ico
deleted file mode 100644 (file)
index 1683b7c..0000000
Binary files a/reactos/lib/comdlg32/network.ico and /dev/null differ
diff --git a/reactos/lib/comdlg32/pd32_collate.ico b/reactos/lib/comdlg32/pd32_collate.ico
deleted file mode 100644 (file)
index cccfc1c..0000000
Binary files a/reactos/lib/comdlg32/pd32_collate.ico and /dev/null differ
diff --git a/reactos/lib/comdlg32/pd32_landscape.ico b/reactos/lib/comdlg32/pd32_landscape.ico
deleted file mode 100644 (file)
index f06cfa5..0000000
Binary files a/reactos/lib/comdlg32/pd32_landscape.ico and /dev/null differ
diff --git a/reactos/lib/comdlg32/pd32_nocollate.ico b/reactos/lib/comdlg32/pd32_nocollate.ico
deleted file mode 100644 (file)
index bf84a23..0000000
Binary files a/reactos/lib/comdlg32/pd32_nocollate.ico and /dev/null differ
diff --git a/reactos/lib/comdlg32/pd32_portrait.ico b/reactos/lib/comdlg32/pd32_portrait.ico
deleted file mode 100644 (file)
index 4001f9c..0000000
Binary files a/reactos/lib/comdlg32/pd32_portrait.ico and /dev/null differ
diff --git a/reactos/lib/ole32/drag_copy.cur b/reactos/lib/ole32/drag_copy.cur
deleted file mode 100644 (file)
index 8d27556..0000000
Binary files a/reactos/lib/ole32/drag_copy.cur and /dev/null differ
diff --git a/reactos/lib/ole32/drag_link.cur b/reactos/lib/ole32/drag_link.cur
deleted file mode 100644 (file)
index 1a1fb06..0000000
Binary files a/reactos/lib/ole32/drag_link.cur and /dev/null differ
diff --git a/reactos/lib/ole32/drag_move.cur b/reactos/lib/ole32/drag_move.cur
deleted file mode 100644 (file)
index c293d18..0000000
Binary files a/reactos/lib/ole32/drag_move.cur and /dev/null differ
diff --git a/reactos/lib/ole32/nodrop.cur b/reactos/lib/ole32/nodrop.cur
deleted file mode 100644 (file)
index a299255..0000000
Binary files a/reactos/lib/ole32/nodrop.cur and /dev/null differ
diff --git a/reactos/lib/shell32/desktop.ico b/reactos/lib/shell32/desktop.ico
deleted file mode 100644 (file)
index 13974d0..0000000
Binary files a/reactos/lib/shell32/desktop.ico and /dev/null differ
diff --git a/reactos/lib/shell32/document.ico b/reactos/lib/shell32/document.ico
deleted file mode 100644 (file)
index 2173cbc..0000000
Binary files a/reactos/lib/shell32/document.ico and /dev/null differ
diff --git a/reactos/lib/shell32/drive.ico b/reactos/lib/shell32/drive.ico
deleted file mode 100644 (file)
index 48faa32..0000000
Binary files a/reactos/lib/shell32/drive.ico and /dev/null differ
diff --git a/reactos/lib/shell32/floppy.ico b/reactos/lib/shell32/floppy.ico
deleted file mode 100644 (file)
index 56340cb..0000000
Binary files a/reactos/lib/shell32/floppy.ico and /dev/null differ
diff --git a/reactos/lib/shell32/folder.ico b/reactos/lib/shell32/folder.ico
deleted file mode 100644 (file)
index 11ac83d..0000000
Binary files a/reactos/lib/shell32/folder.ico and /dev/null differ
diff --git a/reactos/lib/shell32/folder_open.ico b/reactos/lib/shell32/folder_open.ico
deleted file mode 100644 (file)
index 59fea02..0000000
Binary files a/reactos/lib/shell32/folder_open.ico and /dev/null differ
diff --git a/reactos/lib/shell32/mycomputer.ico b/reactos/lib/shell32/mycomputer.ico
deleted file mode 100644 (file)
index 2fa7be3..0000000
Binary files a/reactos/lib/shell32/mycomputer.ico and /dev/null differ
diff --git a/reactos/lib/shell32/netdrive.ico b/reactos/lib/shell32/netdrive.ico
deleted file mode 100644 (file)
index c802040..0000000
Binary files a/reactos/lib/shell32/netdrive.ico and /dev/null differ
diff --git a/reactos/lib/shell32/netdrive2.ico b/reactos/lib/shell32/netdrive2.ico
deleted file mode 100644 (file)
index ffbe3fc..0000000
Binary files a/reactos/lib/shell32/netdrive2.ico and /dev/null differ
diff --git a/reactos/lib/shell32/printer.ico b/reactos/lib/shell32/printer.ico
deleted file mode 100644 (file)
index 5d2e999..0000000
Binary files a/reactos/lib/shell32/printer.ico and /dev/null differ
diff --git a/reactos/lib/shell32/ramdisk.ico b/reactos/lib/shell32/ramdisk.ico
deleted file mode 100644 (file)
index d03a657..0000000
Binary files a/reactos/lib/shell32/ramdisk.ico and /dev/null differ
index 2353a80..25dcc05 100644 (file)
 # include <unistd.h>
 #endif
 
+#if defined(WIN32)
+#define DIR_SEPARATOR "\\"
+#else
+#define DIR_SEPARATOR "/"
+#endif
+
 extern int mkstemps(char *template, int suffix_len);
 
+int process_resources(const char* input_file_name, const char* specific_file_name, 
+                     const char* relative_path,
+                     int inserting, int force_processing, int verbose);
+
 static const char* help =
         "Usage: bin2res [OPTIONS] <rsrc.rc>\n"
        "  -a archive binaries into the <rsrc.rc> file\n"
        "  -x extract binaries from the <rsrc.rc> file\n"
        "  -i <filename> archive the named file into the <rsrc.rc> file\n"
        "  -o <filename> extract the named file from the <rsrc.rc> file\n"
+       "  -b <path> assume resources are relative to this base path\n"
        "  -f force processing of older resources\n"
        "  -v causes the command to be verbous during processing\n" 
        "  -h print this help screen and exit\n"
@@ -127,9 +138,62 @@ const char* parse_marker(const char *line, time_t* last_updated)
     return res_file_name;
 }
 
+const char* parse_include(const char *line)
+{
+    static char include_filename[PATH_MAX], *rpos, *wpos;
+
+    if (!(rpos = strstr(line, "#"))) return 0;
+    for (rpos += 1; *rpos && isspace(*rpos); rpos++) /**/;
+    if (!(rpos = strstr(line, "include"))) return 0;
+    for (rpos += 7; *rpos && isspace(*rpos); rpos++) /**/;
+    for (; *rpos && (*rpos == '"' || *rpos == '<'); rpos++) /**/;
+    for (wpos = include_filename; *rpos && !(*rpos == '"' || *rpos == '<'); ) *wpos++ = *rpos++;
+    if (!(rpos = strstr(include_filename, ".rc"))) return 0;
+    *wpos = 0;
+
+    return include_filename;
+}
+
+char* get_filename_with_full_path(char* output, const char* filename, const char* relative_path)
+{
+       if (relative_path != NULL && relative_path[0] != 0)
+       {
+               strcpy(output, relative_path);
+               strcat(output, DIR_SEPARATOR);
+               strcat(output, filename);
+       }
+       else
+               strcpy(output, filename);
+       return output;
+}
+
+void process_includes(const char* input_file_name, const char* specific_file_name, 
+                    const char* relative_path,
+                    int inserting, int force_processing, int verbose)
+{
+    char filename[PATH_MAX];
+    char buffer[2048];
+    const char *include_file_name;
+    FILE *fin;
+    int c;
+
+    if (!(fin = fopen(input_file_name, "r"))) return;
+    for (c = EOF; fgets(buffer, sizeof(buffer), fin); c = EOF)
+    {
+       if (!(include_file_name = parse_include(buffer))) continue;
+       if ( verbose ) printf ( "Processing included file %s\n", include_file_name);
+       process_resources(get_filename_with_full_path(filename, include_file_name, relative_path),
+                         specific_file_name, relative_path,
+                         inserting, force_processing, verbose);
+    }
+    fclose(fin);
+}
+
 int process_resources(const char* input_file_name, const char* specific_file_name, 
+                     const char* relative_path,
                      int inserting, int force_processing, int verbose)
 {
+    char filename[PATH_MAX];
     char buffer[2048], tmp_file_name[PATH_MAX];
     const char *res_file_name;
     time_t rc_last_update, res_last_update;
@@ -169,7 +233,8 @@ int process_resources(const char* input_file_name, const char* specific_file_nam
            if (inserting) fputc(c, ftmp);
        if (c == EOF) break;
 
-       if (!(fres = fopen(res_file_name, inserting ? "rb" : "wb"))) break;
+       if (!(fres = fopen(get_filename_with_full_path(filename, res_file_name, relative_path),
+           inserting ? "rb" : "wb"))) break;
        if (inserting)
        {
            if (!insert_hexdump(ftmp, fres)) break;
@@ -201,6 +266,11 @@ int process_resources(const char* input_file_name, const char* specific_file_nam
         }
        else unlink(tmp_file_name);
     }
+    else
+    {
+       process_includes(input_file_name, specific_file_name, relative_path,
+                        inserting, force_processing, verbose);
+    }
 
     return c == EOF;
 }
@@ -211,8 +281,9 @@ int main(int argc, char **argv)
     int force_overwrite = 0, verbose = 0;
     const char* input_file_name = 0;
     const char* specific_file_name = 0;
+    const char* relative_path = 0;
 
-    while((optc = getopt(argc, argv, "axi:o:fhv")) != EOF)
+    while((optc = getopt(argc, argv, "axi:o:b:fhv")) != EOF)
     {
        switch(optc)
        {
@@ -229,6 +300,10 @@ int main(int argc, char **argv)
            if (convert_dir && convert_dir != optc) usage();
            convert_dir = optc;
        break;
+       case 'b':
+           if (relative_path) usage();
+           relative_path = optarg;
+       break;
        case 'f':
            force_overwrite = 1;
        break;
@@ -249,7 +324,7 @@ int main(int argc, char **argv)
 
     if (!convert_dir) usage();
 
-    if (!process_resources(input_file_name, specific_file_name, 
+    if (!process_resources(input_file_name, specific_file_name, relative_path,
                           convert_dir == 'a', force_overwrite, verbose))
     {
        perror("Processing failed");
index 1799ba7..3d9dad2 100644 (file)
@@ -42,6 +42,9 @@ $(BIN2RES_INT_)mkstemps.o: $(BIN2RES_BASE_)mkstemps.c | $(BIN2RES_INT)
        $(ECHO_CC)
        ${host_gcc} $(BIN2RES_HOST_CFLAGS) -c $< -o $@
 
+.PHONY: bin2res
+bin2res: $(BIN2RES_TARGET)
+
 .PHONY: bin2res_clean
 bin2res_clean: $(BIN2RES_TARGET)
        -@$(rm) $(BIN2RES_TARGET) $(BIN2RES_OBJECTS) 2>$(NUL)
index 5d2eb5d..4b5fbb6 100644 (file)
@@ -121,8 +121,8 @@ Directory::CreateDirectory ( string path )
 
 string
 Directory::ReplaceVariable ( string name,
-                                string value,
-                                string path )
+                             string value,
+                             string path )
 {
        size_t i = path.find ( name );
        if ( i != string::npos )
@@ -131,9 +131,9 @@ Directory::ReplaceVariable ( string name,
                return path;
 }
 
-string
+/* static */ string
 Directory::GetEnvironmentVariablePathOrDefault ( const string& name,
-                                                    const string& defaultValue )
+                                                 const string& defaultValue )
 {
        const string& environmentVariableValue = Environment::GetVariable ( name );
        if ( environmentVariableValue.length () > 0 )
@@ -142,21 +142,21 @@ Directory::GetEnvironmentVariablePathOrDefault ( const string& name,
                return defaultValue;
 }
 
-string
+/* static */ string
 Directory::GetIntermediatePath ()
 {
        return GetEnvironmentVariablePathOrDefault ( "ROS_INTERMEDIATE",
                                                     "obj-i386" );
 }
 
-string
+/* static */ string
 Directory::GetOutputPath ()
 {
        return GetEnvironmentVariablePathOrDefault ( "ROS_OUTPUT",
                                                     "output-i386" );
 }
 
-string
+/* static */ string
 Directory::GetInstallPath ()
 {
        return GetEnvironmentVariablePathOrDefault ( "ROS_INSTALL",
@@ -165,7 +165,7 @@ Directory::GetInstallPath ()
 
 void
 Directory::ResolveVariablesInPath ( char* buf,
-                                       string path )
+                                    string path )
 {
        string s = ReplaceVariable ( "$(INTERMEDIATE)", GetIntermediatePath (), path );
        s = ReplaceVariable ( "$(OUTPUT)", GetOutputPath (), s );
@@ -175,7 +175,7 @@ Directory::ResolveVariablesInPath ( char* buf,
 
 void
 Directory::GenerateTree ( const string& parent,
-                             bool verbose )
+                          bool verbose )
 {
        string path;
 
@@ -355,6 +355,7 @@ MingwBackend::Process ()
        GenerateInstallTarget ();
        GenerateDirectoryTargets ();
        GenerateDirectories ();
+       UnpackWineResources ();
        CheckAutomaticDependencies ();
        CloseMakefile ();
 }
@@ -637,6 +638,22 @@ MingwBackend::GenerateXmlBuildFilesMacro() const
        fprintf ( fMakefile, "\n" );
 }
 
+string
+MingwBackend::GetBin2ResExecutable ()
+{
+       return NormalizeFilename ( Directory::GetOutputPath () + SSEP + "tools/bin2res/bin2res" + EXEPOSTFIX );
+}
+
+void
+MingwBackend::UnpackWineResources ()
+{
+       printf ( "Unpacking WINE resources..." );
+       WineResource wineResource ( ProjectNode,
+                                   GetBin2ResExecutable () );
+       wineResource.UnpackResources ( verbose );
+       printf ( "done\n" );
+}
+
 void
 MingwBackend::CheckAutomaticDependencies ()
 {
index f19cf82..437023d 100644 (file)
@@ -37,17 +37,17 @@ public:
        std::string EscapeSpaces ( std::string path );
        void CreateRule ( FILE* f,
                          const std::string& parent );
+       static std::string GetIntermediatePath ();
+       static std::string GetOutputPath ();
+       static std::string GetInstallPath ();
 private:
        bool mkdir_p ( const char* path );
        std::string ReplaceVariable ( std::string name,
                                      std::string value,
                                      std::string path );
        std::string GetEnvironmentVariable ( const std::string& name );
-       std::string GetEnvironmentVariablePathOrDefault ( const std::string& name,
-                                                         const std::string& defaultValue );
-       std::string GetIntermediatePath ();
-       std::string GetOutputPath ();
-       std::string GetInstallPath ();
+       static std::string GetEnvironmentVariablePathOrDefault ( const std::string& name,
+                                                                const std::string& defaultValue );
        void ResolveVariablesInPath ( char* buf,
                                      std::string path );
        bool CreateDirectory ( std::string path );
@@ -90,6 +90,8 @@ private:
        std::string GetBuildToolDependencies () const;
        void GenerateInitTarget () const;
        void GenerateXmlBuildFilesMacro() const;
+       std::string GetBin2ResExecutable ();
+       void UnpackWineResources ();
        void CheckAutomaticDependencies ();
        bool IncludeDirectoryTarget ( const std::string& directory ) const;
        bool TryToDetectThisCompiler ( const std::string& compiler );
index 8ac571a..04da147 100644 (file)
@@ -1848,7 +1848,7 @@ MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
                                  deps[i].c_str () );
 
                fprintf ( fMakefile, " | %s\n",
-                         GetDirectory ( GetTargetFilename ( module, NULL ) ).c_str () );
+                         GetDirectory ( GetImportLibraryFilename ( module, NULL ) ).c_str () );
 
                fprintf ( fMakefile, "\t$(ECHO_DLLTOOL)\n" );
 
@@ -2236,33 +2236,9 @@ MingwWin32DLLModuleHandler::MingwWin32DLLModuleHandler (
 void
 MingwWin32DLLModuleHandler::Process ()
 {
-       GenerateExtractWineDLLResourcesTarget ();
        GenerateWin32DLLModuleTarget ();
 }
 
-void
-MingwWin32DLLModuleHandler::GenerateExtractWineDLLResourcesTarget ()
-{
-       fprintf ( fMakefile, ".PHONY: %s_extractresources\n\n",
-                 module.name.c_str () );
-       fprintf ( fMakefile, "%s_extractresources: $(BIN2RES_TARGET)\n",
-                 module.name.c_str () );
-       const vector<File*>& files = module.non_if_data.files;
-       for ( size_t i = 0; i < files.size (); i++ )
-       {
-               File& file = *files[i];
-               string extension = GetExtension ( file.name );
-               if ( extension == ".rc" || extension == ".RC" )
-               {
-                       string resource = NormalizeFilename ( file.name );
-                       fprintf ( fMakefile, "\t$(ECHO_BIN2RES)\n" );
-                       fprintf ( fMakefile, "\t@:echo ${bin2res} -f -x %s\n",
-                                 resource.c_str () );
-               }
-       }
-       fprintf ( fMakefile, "\n");
-}
-
 void
 MingwWin32DLLModuleHandler::GenerateWin32DLLModuleTarget ()
 {
index b9f40b0..dd7ae5b 100644 (file)
@@ -291,7 +291,6 @@ public:
        virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
 private:
-       void GenerateExtractWineDLLResourcesTarget ();
        void GenerateWin32DLLModuleTarget ();
 };
 
index b65ea6b..e571689 100644 (file)
@@ -55,6 +55,7 @@ class If;
 class CompilerFlag;
 class LinkerFlag;
 class Property;
+class WineResource;
 class AutomaticDependency;
 class Bootstrap;
 class CDFile;
@@ -421,6 +422,26 @@ public:
 };
 
 
+class WineResource
+{
+public:
+       const Project& project;
+       std::string bin2res;
+
+       WineResource ( const Project& project,
+                      std::string bin2res );
+       ~WineResource ();
+       void UnpackResources ( bool verbose );
+private:
+       bool IsSpecFile ( const File& file );
+       bool IsWineModule ( const Module& module );
+       bool IsResourceFile ( const File& file );
+       std::string GetResourceFilename ( const Module& module );
+       void UnpackResourcesInModule ( Module& module,
+                                      bool verbose );
+};
+
+
 class SourceFile
 {
 public:
index 5c976d8..33d052b 100644 (file)
@@ -123,6 +123,7 @@ RBUILD_COMMON_SOURCES = \
                project.cpp \
                ssprintf.cpp \
                stubbedcomponent.cpp \
+               wineresource.cpp \
                XML.cpp \
                )
 
@@ -261,6 +262,10 @@ $(RBUILD_INT_)stubbedcomponent.o: $(RBUILD_BASE_)stubbedcomponent.cpp $(RBUILD_H
        $(ECHO_CC)
        ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
 
+$(RBUILD_INT_)wineresource.o: $(RBUILD_BASE_)wineresource.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
+       $(ECHO_CC)
+       ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
+
 $(RBUILD_INT_)XML.o: $(RBUILD_BASE_)XML.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
        $(ECHO_CC)
        ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
@@ -335,7 +340,6 @@ $(RBUILD_TESTS_INT_)alltests.o: $(RBUILD_TESTS_BASE_)alltests.cpp $(RBUILD_HEADE
 
 
 .PHONY: rbuild_test
-
 rbuild_test: $(RBUILD_TEST_TARGET)
        $(ECHO_TEST)
        $(Q)$(RBUILD_TEST_TARGET)
diff --git a/reactos/tools/rbuild/wineresource.cpp b/reactos/tools/rbuild/wineresource.cpp
new file mode 100644 (file)
index 0000000..f031c57
--- /dev/null
@@ -0,0 +1,100 @@
+#include "pch.h"
+#include <assert.h>
+
+#include "rbuild.h"
+
+using std::string;
+using std::vector;
+
+WineResource::WineResource ( const Project& project,
+                             string bin2res )
+       : project ( project ),
+         bin2res ( bin2res )
+{
+}
+
+WineResource::~WineResource ()
+{
+}
+
+bool
+WineResource::IsSpecFile ( const File& file )
+{
+       string extension = GetExtension ( file.name );
+       if ( extension == ".spec" || extension == ".SPEC" )
+               return true;
+       return false;
+}
+
+bool
+WineResource::IsWineModule ( const Module& module )
+{
+       const vector<File*>& files = module.non_if_data.files;
+       for ( size_t i = 0; i < files.size (); i++ )
+       {
+               if ( IsSpecFile ( *files[i] ) )
+                       return true;
+       }
+       return false;
+}
+
+bool
+WineResource::IsResourceFile ( const File& file )
+{
+       string extension = GetExtension ( file.name );
+       if ( extension == ".rc" || extension == ".RC" )
+               return true;
+       return false;
+}
+
+string
+WineResource::GetResourceFilename ( const Module& module )
+{
+       const vector<File*>& files = module.non_if_data.files;
+       for ( size_t i = 0; i < files.size (); i++ )
+       {
+               if ( IsResourceFile ( *files[i] ) )
+                       return files[i]->name;
+       }
+       return "";
+}
+
+void
+WineResource::UnpackResources ( bool verbose )
+{
+       for ( size_t i = 0; i < project.modules.size (); i++ )
+       {
+               if ( IsWineModule ( *project.modules[i] ) )
+               {
+                       UnpackResourcesInModule ( *project.modules[i],
+                                                 verbose );
+               }
+       }
+}
+
+void
+WineResource::UnpackResourcesInModule ( Module& module,
+                                        bool verbose )
+{
+       string resourceFilename = GetResourceFilename ( module );
+       if ( resourceFilename.length () == 0 )
+               return;
+
+       if ( verbose )
+       {
+               printf ( "Unpacking resources for %s",
+                        module.name.c_str () );
+       }
+
+       string outputDirectory = GetDirectory ( module.GetPath () );
+       string parameters = ssprintf ( "-b %s -f -x %s",
+                                      NormalizeFilename ( outputDirectory ).c_str (),
+                                      NormalizeFilename ( resourceFilename ).c_str () );
+       string command = bin2res + " " + parameters;
+       int exitcode = system ( command.c_str () );
+       if ( exitcode != 0 )
+       {
+               throw InvocationFailedException ( command,
+                                                 exitcode );
+       }
+}