• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2017 Steven Watanabe
2#
3# Distributed under the Boost Software License, Version 1.0.
4#    (See accompanying file LICENSE_1_0.txt or copy at
5#          http://www.boost.org/LICENSE_1_0.txt)
6
7import os ;
8import print ;
9import regex ;
10import feature ;
11
12.PYTHON = [ os.environ PYTHON_CMD ] ;
13path-constant .AR : ar.py ;
14path-constant .RANLIB : ranlib.py ;
15path-constant .LIBTOOL : libtool.py ;
16path-constant .STRIP : strip.py ;
17path-constant .LD : ld.py ;
18
19rule c-escape ( str )
20{
21    return [ regex.replace $(str) \\\\ \\\\ ] ;
22}
23
24rule cfg-header ( target : : properties * )
25{
26    local PYTHON = [ c-escape $(.PYTHON) ] ;
27    local AR = [ c-escape $(.AR) ] ;
28    local RANLIB = [ c-escape $(.RANLIB) ] ;
29    local LIBTOOL = [ c-escape $(.LIBTOOL) ] ;
30    local STRIP = [ c-escape $(.STRIP) ] ;
31    local LD = [ c-escape $(.LD) ] ;
32    print.output $(target) ;
33    print.text "#define PYTHON_CMD "\"$(PYTHON)\" : true ;
34    print.text "#define AR_CMD "\"$(AR)\" : true ;
35    print.text "#define RANLIB_CMD "\"$(RANLIB)\" : true ;
36    print.text "#define LIBTOOL_CMD "\"$(LIBTOOL)\" : true ;
37    print.text "#define STRIP_CMD "\"$(STRIP)\" : true ;
38    print.text "#define LD_CMD "\"$(LD)\" : true ;
39}
40
41# We can only build one variant at a time and we need to have a fixed path
42project : requirements <location>bin ;
43
44make config.h : : @cfg-header ;
45
46project : requirements <implicit-dependency>config.h ;
47
48rule write-target-os ( target : : properties * )
49{
50    local target-os = [ feature.defaults <target-os> ] ;
51    print.output $(target) ;
52    print.text $(target-os:G=) : true ;
53}
54
55make target-os.txt : : @write-target-os ;
56
57exe ar : [ obj ar.obj : mock-program.cpp : <define>PY_SCRIPT=AR_CMD ] ;
58exe ranlib : [ obj ranlib.obj : mock-program.cpp : <define>PY_SCRIPT=RANLIB_CMD ] ;
59exe libtool : [ obj libtool.obj : mock-program.cpp : <define>PY_SCRIPT=LIBTOOL_CMD ] ;
60exe strip : [ obj strip.obj : mock-program.cpp : <define>PY_SCRIPT=STRIP_CMD ] ;
61exe ld : [ obj ld.obj : mock-program.cpp : <define>PY_SCRIPT=LD_CMD ] ;
62