summaryrefslogtreecommitdiffstats
path: root/src/boost/tools/build/test/toolset-mock/src/Jamroot.jam
blob: 172e26db7d699429ef92192d06429481062e7471 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright 2017 Steven Watanabe
#
# Distributed under the Boost Software License, Version 1.0.
#    (See accompanying file LICENSE.txt or copy at
#          https://www.bfgroup.xyz/b2/LICENSE.txt)

import os ;
import print ;
import regex ;
import feature ;

.PYTHON = [ os.environ PYTHON_CMD ] ;
path-constant .AR : ar.py ;
path-constant .LIBTOOL : libtool.py ;
path-constant .STRIP : strip.py ;
path-constant .LD : ld.py ;

rule c-escape ( str )
{
    return [ regex.replace $(str) \\\\ \\\\ ] ;
}

rule cfg-header ( target : : properties * )
{
    local PYTHON = [ c-escape $(.PYTHON) ] ;
    local AR = [ c-escape $(.AR) ] ;
    local LIBTOOL = [ c-escape $(.LIBTOOL) ] ;
    local STRIP = [ c-escape $(.STRIP) ] ;
    local LD = [ c-escape $(.LD) ] ;
    print.output $(target) ;
    print.text "#define PYTHON_CMD "\"$(PYTHON)\" : true ;
    print.text "#define AR_CMD "\"$(AR)\" : true ;
    print.text "#define LIBTOOL_CMD "\"$(LIBTOOL)\" : true ;
    print.text "#define STRIP_CMD "\"$(STRIP)\" : true ;
    print.text "#define LD_CMD "\"$(LD)\" : true ;
}

# We can only build one variant at a time and we need to have a fixed path
project : requirements <location>bin ;

make config.h : : @cfg-header ;

project : requirements <implicit-dependency>config.h ;

rule write-target-os ( target : : properties * )
{
    local target-os = [ feature.defaults <target-os> ] ;
    print.output $(target) ;
    print.text $(target-os:G=) : true ;
}

make target-os.txt : : @write-target-os ;

exe ar : [ obj ar.obj : mock-program.cpp : <define>PY_SCRIPT=AR_CMD ] ;
exe libtool : [ obj libtool.obj : mock-program.cpp : <define>PY_SCRIPT=LIBTOOL_CMD ] ;
exe strip : [ obj strip.obj : mock-program.cpp : <define>PY_SCRIPT=STRIP_CMD ] ;
exe ld : [ obj ld.obj : mock-program.cpp : <define>PY_SCRIPT=LD_CMD ] ;