2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-15 13:02:11 +00:00

Example of templates.

[SVN r15173]
This commit is contained in:
Rene Rivera
2002-09-06 03:38:30 +00:00
parent 9d430f5f06
commit 95df2ca6e0
10 changed files with 224 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
# Copyright (C) 2002, Rene Rivera. 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.
# Example of how to define a template.
# This is for Boost.Build-V1
subproject tools/build/examples/template_use ;
# Declare the template as a target. The sources, requirements, and
# default builds sections are copied to the targets that depend (use)
# this template.
#
template t-common
:
# SOURCES
:
# REQUIREMENTS
<include>$(SUBDIR)/include
<define>SOME_DEFINE
:
# DEFAULT BUILDS
;

View File

@@ -0,0 +1,12 @@
/*
Copyright (C) 2002, Rene Rivera. 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.
*/
#ifndef simple_h
#define simple_h
extern int lib_call(int x);
#endif

View File

@@ -0,0 +1,44 @@
# Copyright (C) 2002, Rene Rivera. 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.
# Example of how to use a template target declared in another project.
# This is for Boost.Build-V1
subproject tools/build/examples/template_use/sub ;
# Declare a library target. This 'inherits' the attributes of
# the template which in this case adds the needed include
# directory. Because templates are "special" targets they
# appear in the source dependencies section and must be
# a relative reference to the template target in it's declared
# location.
#
lib simple
:
# SOURCES
<template>../t-common
simple_lib.cpp
:
# REQUIREMENTS
:
# DEFAULT BUILDS
debug <threading>single/multi
;
# Declare an executable target that also uses the template,
# and the above library target.
#
exe simple
:
# SOURCES
<template>../t-common
simple.cpp
<lib>simple
:
# REQUIREMENTS
<threading>multi
:
# DEFAULT BUILDS
;

View File

@@ -0,0 +1,19 @@
/*
Copyright (C) 2002, Rene Rivera. 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.
*/
#include <cstdio>
#include "simple.h"
int main(int /* argc */, char ** /* argv */)
{
for (int i = 0; i < 16; ++i)
{
std::printf("%d * 2 = %d\n",i,lib_call(i));
}
return 0;
}

View File

@@ -0,0 +1,13 @@
/*
Copyright (C) 2002, Rene Rivera. 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.
*/
#include "simple.h"
int lib_call(int x)
{
return x*2;
}

View File

@@ -0,0 +1,24 @@
# Copyright (C) 2002, Rene Rivera. 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.
# Example of how to define a template.
# This is for Boost.Build-V1
subproject tools/build/examples/template_use ;
# Declare the template as a target. The sources, requirements, and
# default builds sections are copied to the targets that depend (use)
# this template.
#
template t-common
:
# SOURCES
:
# REQUIREMENTS
<include>$(SUBDIR)/include
<define>SOME_DEFINE
:
# DEFAULT BUILDS
;

View File

@@ -0,0 +1,12 @@
/*
Copyright (C) 2002, Rene Rivera. 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.
*/
#ifndef simple_h
#define simple_h
extern int lib_call(int x);
#endif

View File

@@ -0,0 +1,44 @@
# Copyright (C) 2002, Rene Rivera. 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.
# Example of how to use a template target declared in another project.
# This is for Boost.Build-V1
subproject tools/build/examples/template_use/sub ;
# Declare a library target. This 'inherits' the attributes of
# the template which in this case adds the needed include
# directory. Because templates are "special" targets they
# appear in the source dependencies section and must be
# a relative reference to the template target in it's declared
# location.
#
lib simple
:
# SOURCES
<template>../t-common
simple_lib.cpp
:
# REQUIREMENTS
:
# DEFAULT BUILDS
debug <threading>single/multi
;
# Declare an executable target that also uses the template,
# and the above library target.
#
exe simple
:
# SOURCES
<template>../t-common
simple.cpp
<lib>simple
:
# REQUIREMENTS
<threading>multi
:
# DEFAULT BUILDS
;

View File

@@ -0,0 +1,19 @@
/*
Copyright (C) 2002, Rene Rivera. 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.
*/
#include <cstdio>
#include "simple.h"
int main(int /* argc */, char ** /* argv */)
{
for (int i = 0; i < 16; ++i)
{
std::printf("%d * 2 = %d\n",i,lib_call(i));
}
return 0;
}

View File

@@ -0,0 +1,13 @@
/*
Copyright (C) 2002, Rene Rivera. 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.
*/
#include "simple.h"
int lib_call(int x)
{
return x*2;
}