mirror of
https://github.com/boostorg/build.git
synced 2026-02-16 13:22:11 +00:00
An example of generated file is .tlb generated by midl.exe. Patch from Alexey Pakhunov. [SVN r31194]
134 lines
4.2 KiB
Plaintext
134 lines
4.2 KiB
Plaintext
# Copyright (C) Andre Hentz 2003. Permission to copy, use, modify, sell and
|
|
# distribute this software is granted provided this copyright notice appears in
|
|
# all copies. This software is provided "as is" without express or implied
|
|
# warranty, and with no claim as to its suitability for any purpose.
|
|
|
|
import type ;
|
|
import generators ;
|
|
import feature ;
|
|
import errors ;
|
|
import scanner ;
|
|
|
|
type.register RC : rc ;
|
|
|
|
rule init ( )
|
|
{
|
|
}
|
|
|
|
rule resource-compile ( target : sources * : properties * )
|
|
{
|
|
local OS = [ feature.get-values <os> : $(properties) ] ;
|
|
switch $(OS)
|
|
{
|
|
case "NT" :
|
|
resource-compile-nt $(target) : $(sources[1]) ;
|
|
case "CYGWIN" :
|
|
resource-compile-cygwin $(target) : $(sources[1]) ;
|
|
case "FREEBSD" :
|
|
create-empty-object $(target) : $(sources[1]) ;
|
|
case "SOLARIS" :
|
|
create-empty-object $(target) : $(sources[1]) ;
|
|
case "LINUX" :
|
|
create-empty-object $(target) : $(sources[1]) ;
|
|
case "*" :
|
|
errors.error "Cannot process RC files for OS=$(OS)" ;
|
|
}
|
|
}
|
|
|
|
|
|
actions quietly resource-compile-nt
|
|
{
|
|
rc /i "$(>:D)" /i "$(<:D)" /fo "$(<)" "$(>)"
|
|
}
|
|
|
|
actions quietly resource-compile-cygwin
|
|
{
|
|
windres --include-dir "$(>:D)" -o "$(<)" -i "$(>)"
|
|
}
|
|
|
|
actions quietly create-empty-object
|
|
{
|
|
as /dev/null -o "$(<)"
|
|
}
|
|
|
|
# Since it's a common practice to write
|
|
# exe hello : hello.cpp hello.rc
|
|
# we change the name of object created from RC file, to
|
|
# avoid conflict with hello.cpp.
|
|
# The reason we generate OBJ and not RES, is that gcc does not
|
|
# seem to like RES files, but works OK with OBJ.
|
|
# See http://article.gmane.org/gmane.comp.lib.boost.build/5643/
|
|
#
|
|
# Using 'register-c-compiler' adds the build directory to INCLUDES
|
|
generators.register-c-compiler rc.resource-compile : RC : OBJ(%_res) ;
|
|
|
|
# Register scanner for resources
|
|
class res-scanner : scanner
|
|
{
|
|
import regex virtual-target path scanner ;
|
|
|
|
rule __init__ ( includes * )
|
|
{
|
|
scanner.__init__ ;
|
|
|
|
self.includes = $(includes) ;
|
|
}
|
|
|
|
rule pattern ( )
|
|
{
|
|
return "(([^ ]+[ ]+(BITMAP|CURSOR|FONT|ICON|MESSAGETABLE|RT_MANIFEST)[ ]+([^ \"]+|\"[^\"]+\"))|(#include[ ]*(<[^<]+>|\"[^\"]+\")))" ;
|
|
}
|
|
|
|
rule process ( target : matches * : binding )
|
|
{
|
|
local angle = [ regex.transform $(matches) : "#include[ ]*<([^<]+)>" ] ;
|
|
local quoted = [ regex.transform $(matches) : "#include[ ]*\"([^\"]+)\"" ] ;
|
|
local res = [ regex.transform $(matches) : "[^ ]+[ ]+(BITMAP|CURSOR|FONT|ICON|MESSAGETABLE|RT_MANIFEST)[ ]+(([^ \"]+)|\"([^\"]+)\")" : 3 4 ] ;
|
|
|
|
# Icons and other includes may referenced as
|
|
#
|
|
# IDR_MAINFRAME ICON "res\\icon.ico"
|
|
#
|
|
# so we have to replace double backslashes to single ones.
|
|
res = [ regex.replace-list $(res) : "\\\\\\\\" : "/" ] ;
|
|
|
|
# CONSIDER: the new scoping rule seem to defeat "on target" variables.
|
|
local g = [ on $(target) return $(HDRGRIST) ] ;
|
|
local b = [ NORMALIZE_PATH $(binding:D) ] ;
|
|
|
|
# Attach binding of including file to included targets.
|
|
# When target is directly created from virtual target
|
|
# this extra information is unnecessary. But in other
|
|
# cases, it allows to distinguish between two headers of the
|
|
# same name included from different places.
|
|
# We don't need this extra information for angle includes,
|
|
# since they should not depend on including file (we can't
|
|
# get literal "." in include path).
|
|
local g2 = $(g)"#"$(b) ;
|
|
|
|
angle = $(angle:G=$(g)) ;
|
|
quoted = $(quoted:G=$(g2)) ;
|
|
res = $(res:G=$(g2)) ;
|
|
|
|
local all = $(angle) $(quoted) ;
|
|
|
|
INCLUDES $(target) : $(all) ;
|
|
DEPENDS $(target) : $(res) ;
|
|
NOCARE $(all) $(res) ;
|
|
SEARCH on $(angle) = $(self.includes:G=) ;
|
|
SEARCH on $(quoted) = $(b) $(self.includes:G=) ;
|
|
SEARCH on $(res) = $(b) $(self.includes:G=) ;
|
|
|
|
# Just propagate current scanner to includes, in a hope
|
|
# that includes do not change scanners.
|
|
scanner.propagate $(__name__) : $(angle) $(quoted) : $(target) ;
|
|
}
|
|
}
|
|
|
|
scanner.register res-scanner : include ;
|
|
type.set-scanner RC : res-scanner ;
|
|
|
|
|
|
|
|
|