added <xrc-file> tag to wxpresets
[wxWidgets.git] / build / bakefiles / wxpresets / presets / wx_xrc.bkl
1 <?xml version="1.0" ?>
2 <!-- $Id$ -->
3
4 <!--
5
6 Bakefile XRC support; included by wx.bkl, do not include directly.
7
8 Usage:
9
10 <exe id="myapp" template="wxgui,simple">
11     ...
12     <sources>...</sources>
13     ...
14     <xrc-file>myapp.xrc</xrc-file>
15     <xrc-file>file2.xrc</xrc-file>
16 </exe>
17
18 Then in application code, you have to call initialization for every XRC
19 file:
20
21     InitXMLResource_myapp();
22     InitXMLResource_file2();
23
24 -->
25
26 <makefile>
27
28     <!-- XRC section -->
29     <option name="WXRC" category="path">
30         <description>Path to find the wxrc executable.</description>
31         <default-value>wxrc</default-value>
32     </option>
33
34
35     <define-tag name="xrc-file" rules="exe,dll,lib">
36         <set var="_xrc_file">$(value)</set>
37         <set var="_xrc_cpp">$(value.replace('.xrc', '_xrc.cpp'))</set>
38         <set var="_xrc_base">$(value[value.rfind('/')+1:value.rfind('.')])</set>
39         <set var="_wxrc_options">-c -n InitXMLResource_$(_xrc_base)</set>
40
41         <sources>$(_xrc_cpp)</sources>
42         <if cond="FORMAT not in ['msvc6prj','msvs2003prj','msvs2005prj']">
43             <clean-files>$(_xrc_cpp)</clean-files>
44             <add-target target="$(_xrc_cpp)" type="action"/>
45             <modify-target target="$(_xrc_cpp)">
46                 <set var="_xrc">$(_xrc_file)</set>
47                 <depends-on-file>$(SRCDIR)/$(_xrc)</depends-on-file>
48                 <command>
49                     $(WXRC) $(_wxrc_options) -o $(_xrc_cpp) $(_xrc)
50                 </command>
51             </modify-target>
52         </if>
53         <if cond="FORMAT in ['msvc6prj','msvs2003prj','msvs2005prj']">
54             <sources>$(_xrc_file)</sources>
55             <!--
56                 A hack to add XRC compilation step to MSVC projects.
57
58                 NB: it's important to use backslashes and not slashes here.
59              -->
60              <set var="_custom_build_files" append="1">$(_xrc_file.replace('/','\\'))</set>
61             <set var="_custom_build_$(_xrc_file.replace('/','_').replace('.','_'))">
62 Compiling XRC resources: $(_xrc_file)...
63 InputPath=$(_xrc_file)
64
65 "$(_xrc_cpp.replace('/','\\'))" : "$(DOLLAR)(INTDIR)"
66 $(TAB)$(WXRC) $(_wxrc_options) -o $(_xrc_cpp) $(_xrc_file)
67             </set>
68         </if>
69
70     </define-tag>
71
72 </makefile>