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:
24
examples/template_use/Jamfile
Normal file
24
examples/template_use/Jamfile
Normal 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
|
||||
;
|
||||
12
examples/template_use/include/simple.h
Normal file
12
examples/template_use/include/simple.h
Normal 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
|
||||
44
examples/template_use/sub/Jamfile
Normal file
44
examples/template_use/sub/Jamfile
Normal 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
|
||||
;
|
||||
19
examples/template_use/sub/simple.cpp
Normal file
19
examples/template_use/sub/simple.cpp
Normal 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;
|
||||
}
|
||||
13
examples/template_use/sub/simple_lib.cpp
Normal file
13
examples/template_use/sub/simple_lib.cpp
Normal 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;
|
||||
}
|
||||
24
v1/example/template_use/Jamfile
Normal file
24
v1/example/template_use/Jamfile
Normal 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
|
||||
;
|
||||
12
v1/example/template_use/include/simple.h
Normal file
12
v1/example/template_use/include/simple.h
Normal 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
|
||||
44
v1/example/template_use/sub/Jamfile
Normal file
44
v1/example/template_use/sub/Jamfile
Normal 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
|
||||
;
|
||||
19
v1/example/template_use/sub/simple.cpp
Normal file
19
v1/example/template_use/sub/simple.cpp
Normal 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;
|
||||
}
|
||||
13
v1/example/template_use/sub/simple_lib.cpp
Normal file
13
v1/example/template_use/sub/simple_lib.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user