1import type ;
2import generators ;
3import feature ;
4
5type.register RC : rc ;
6
7rule init ( )
8{
9}
10
11rule resource-compile ( target : sources * : properties * )
12{
13#    local OS = [ feature.get-values <os> : $(properties) ] ;
14    resource-compile-mingw $(target) : $(sources[1]) ;
15#    switch $(OS)
16#    {
17#        case "NT" :
18#            resource-compile-nt $(target) : $(sources[1]) ;
19#        case "CYGWIN" :
20#            resource-compile-cygwin $(target) : $(sources[1]) ;
21#        case "FREEBSD" :
22#            create-empty-object $(target) : $(sources[1]) ;
23#        case "*" :
24#            errors.error "Cannot process RC files for OS=$(OS)" ;
25#    }
26}
27
28
29actions quietly resource-compile-nt
30{
31    rc /i "$(>:D)" /fo "$(<)" "$(>)"
32}
33
34actions quietly resource-compile-mingw
35{
36    windres -D__WINDRES__ -o "$(<)" -i "$(>)"
37}
38
39actions quietly resource-compile-cygwin
40{
41    windres -D__WINDRES__ --include-dir "$(>:D)" -o "$(<)" -i "$(>)"
42}
43
44actions quietly create-empty-object
45{
46    as /dev/null -o "$(<)"
47}
48
49# Since it's a common practice to write
50# exe hello : hello.cpp hello.rc
51# we change the name of object created from RC file, to
52# avoid conflict with hello.cpp.
53generators.register-standard rc-mingw.resource-compile : RC : OBJ(%_res) ;
54