diff --git a/examples-v2/boost-build.jam b/examples-v2/boost-build.jam new file mode 100644 index 000000000..75ecc4338 --- /dev/null +++ b/examples-v2/boost-build.jam @@ -0,0 +1,2 @@ + +boost-build ../new ; \ No newline at end of file diff --git a/examples-v2/make/Jamfile b/examples-v2/make/Jamfile new file mode 100644 index 000000000..55378c8a9 --- /dev/null +++ b/examples-v2/make/Jamfile @@ -0,0 +1,22 @@ + +# Declare a project id. +project make + # Specify requirements for this project. They will be propagated to child project. + # Use 'bjam -n' to see that MACRO is defined when compiling lib/b.obj + : requirements MACRO + ; + +# Load a project located at "extlib", and associated with project-id "/extlib". +use-project /extlib : extlib ; + +# Construct a target 'a' from a list of sources using the specified rule. +make a + : a.o # Use a target declared in this Jamfile + lib/b.o # Use a target from other Jamfile + @/extlib/c.o # Refer to a library by project-id + + : gcc.link ; + + +# Construct another target. +make a.o : a.cpp : gcc.compile ; diff --git a/examples-v2/make/a.cpp b/examples-v2/make/a.cpp new file mode 100644 index 000000000..7d5f90dff --- /dev/null +++ b/examples-v2/make/a.cpp @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} \ No newline at end of file diff --git a/examples-v2/make/extlib/Jamfile b/examples-v2/make/extlib/Jamfile new file mode 100644 index 000000000..fb21b1ccf --- /dev/null +++ b/examples-v2/make/extlib/Jamfile @@ -0,0 +1,4 @@ + +project extlib ; + +make c.o : c.cpp : gcc.compile ; \ No newline at end of file diff --git a/examples-v2/make/extlib/c.cpp b/examples-v2/make/extlib/c.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/examples-v2/make/extlib/gcc.jam b/examples-v2/make/extlib/gcc.jam new file mode 100644 index 000000000..3818bac2f --- /dev/null +++ b/examples-v2/make/extlib/gcc.jam @@ -0,0 +1,44 @@ + +import property ; + +rule compile ( target : sources * : property-set * ) +{ + local options ; + for local p in $(property-set) + { + if $(p) = on + { + options += -O2 ; + } + else if $(p) = on + { + options += -g ; + } + else if $(p:G) = + { + options += -D$(p:G=) ; + } + } + OPTIONS on $(target) = $(options) ; +} + +actions compile +{ + g++ $(OPTIONS) -c -o $(<) $(>) +} + +rule link ( target : sources * : property-set * ) +{ + local options ; + if on in $(property-set) + { + options += -g ; + } + OPTIONS on $(target) = $(options) ; +} + +actions link +{ + g++ $(OPTIONS) -o $(<) $(>) +} + diff --git a/examples-v2/make/extlib/project-root.jam b/examples-v2/make/extlib/project-root.jam new file mode 100644 index 000000000..e69de29bb diff --git a/examples-v2/make/gcc.jam b/examples-v2/make/gcc.jam new file mode 100644 index 000000000..3818bac2f --- /dev/null +++ b/examples-v2/make/gcc.jam @@ -0,0 +1,44 @@ + +import property ; + +rule compile ( target : sources * : property-set * ) +{ + local options ; + for local p in $(property-set) + { + if $(p) = on + { + options += -O2 ; + } + else if $(p) = on + { + options += -g ; + } + else if $(p:G) = + { + options += -D$(p:G=) ; + } + } + OPTIONS on $(target) = $(options) ; +} + +actions compile +{ + g++ $(OPTIONS) -c -o $(<) $(>) +} + +rule link ( target : sources * : property-set * ) +{ + local options ; + if on in $(property-set) + { + options += -g ; + } + OPTIONS on $(target) = $(options) ; +} + +actions link +{ + g++ $(OPTIONS) -o $(<) $(>) +} + diff --git a/examples-v2/make/lib/Jamfile b/examples-v2/make/lib/Jamfile new file mode 100644 index 000000000..1f29af62d --- /dev/null +++ b/examples-v2/make/lib/Jamfile @@ -0,0 +1,2 @@ + +make b.o : b.cpp : gcc.compile ; \ No newline at end of file diff --git a/examples-v2/make/lib/b.cpp b/examples-v2/make/lib/b.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/examples-v2/make/project-root.jam b/examples-v2/make/project-root.jam new file mode 100644 index 000000000..6c67b316f --- /dev/null +++ b/examples-v2/make/project-root.jam @@ -0,0 +1,9 @@ + +import modules ; + +# Temporary workaround. +local location = [ project-root get-location ] ; +local new_path = [ modules.peek : BOOST_BUILD_PATH ] $(location) ; +modules.poke : BOOST_BUILD_PATH : $(new_path) ; + +import gcc ; diff --git a/examples-v2/make/readme.txt b/examples-v2/make/readme.txt new file mode 100644 index 000000000..499dbba96 --- /dev/null +++ b/examples-v2/make/readme.txt @@ -0,0 +1,17 @@ + +Example of a simple project, which builds an executable using g++. +All the transformations are specified explicitly. +It illustrates the use of project identifiers to refer to other targets +and also project requirements. + + +Interesting commands would be + + bjam + bjam release + bjam release clean + bjam release debug-symbols=on + +Also, you can use jam's "-n" option to check if "debug"/"release" have any +effect on commands executed. (Note that "-n" should go before any non-option +elements on command line). diff --git a/v2/example/boost-build.jam b/v2/example/boost-build.jam new file mode 100644 index 000000000..75ecc4338 --- /dev/null +++ b/v2/example/boost-build.jam @@ -0,0 +1,2 @@ + +boost-build ../new ; \ No newline at end of file diff --git a/v2/example/make/Jamfile b/v2/example/make/Jamfile new file mode 100644 index 000000000..55378c8a9 --- /dev/null +++ b/v2/example/make/Jamfile @@ -0,0 +1,22 @@ + +# Declare a project id. +project make + # Specify requirements for this project. They will be propagated to child project. + # Use 'bjam -n' to see that MACRO is defined when compiling lib/b.obj + : requirements MACRO + ; + +# Load a project located at "extlib", and associated with project-id "/extlib". +use-project /extlib : extlib ; + +# Construct a target 'a' from a list of sources using the specified rule. +make a + : a.o # Use a target declared in this Jamfile + lib/b.o # Use a target from other Jamfile + @/extlib/c.o # Refer to a library by project-id + + : gcc.link ; + + +# Construct another target. +make a.o : a.cpp : gcc.compile ; diff --git a/v2/example/make/a.cpp b/v2/example/make/a.cpp new file mode 100644 index 000000000..7d5f90dff --- /dev/null +++ b/v2/example/make/a.cpp @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} \ No newline at end of file diff --git a/v2/example/make/extlib/Jamfile b/v2/example/make/extlib/Jamfile new file mode 100644 index 000000000..fb21b1ccf --- /dev/null +++ b/v2/example/make/extlib/Jamfile @@ -0,0 +1,4 @@ + +project extlib ; + +make c.o : c.cpp : gcc.compile ; \ No newline at end of file diff --git a/v2/example/make/extlib/c.cpp b/v2/example/make/extlib/c.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/v2/example/make/extlib/gcc.jam b/v2/example/make/extlib/gcc.jam new file mode 100644 index 000000000..3818bac2f --- /dev/null +++ b/v2/example/make/extlib/gcc.jam @@ -0,0 +1,44 @@ + +import property ; + +rule compile ( target : sources * : property-set * ) +{ + local options ; + for local p in $(property-set) + { + if $(p) = on + { + options += -O2 ; + } + else if $(p) = on + { + options += -g ; + } + else if $(p:G) = + { + options += -D$(p:G=) ; + } + } + OPTIONS on $(target) = $(options) ; +} + +actions compile +{ + g++ $(OPTIONS) -c -o $(<) $(>) +} + +rule link ( target : sources * : property-set * ) +{ + local options ; + if on in $(property-set) + { + options += -g ; + } + OPTIONS on $(target) = $(options) ; +} + +actions link +{ + g++ $(OPTIONS) -o $(<) $(>) +} + diff --git a/v2/example/make/extlib/project-root.jam b/v2/example/make/extlib/project-root.jam new file mode 100644 index 000000000..e69de29bb diff --git a/v2/example/make/gcc.jam b/v2/example/make/gcc.jam new file mode 100644 index 000000000..3818bac2f --- /dev/null +++ b/v2/example/make/gcc.jam @@ -0,0 +1,44 @@ + +import property ; + +rule compile ( target : sources * : property-set * ) +{ + local options ; + for local p in $(property-set) + { + if $(p) = on + { + options += -O2 ; + } + else if $(p) = on + { + options += -g ; + } + else if $(p:G) = + { + options += -D$(p:G=) ; + } + } + OPTIONS on $(target) = $(options) ; +} + +actions compile +{ + g++ $(OPTIONS) -c -o $(<) $(>) +} + +rule link ( target : sources * : property-set * ) +{ + local options ; + if on in $(property-set) + { + options += -g ; + } + OPTIONS on $(target) = $(options) ; +} + +actions link +{ + g++ $(OPTIONS) -o $(<) $(>) +} + diff --git a/v2/example/make/lib/Jamfile b/v2/example/make/lib/Jamfile new file mode 100644 index 000000000..1f29af62d --- /dev/null +++ b/v2/example/make/lib/Jamfile @@ -0,0 +1,2 @@ + +make b.o : b.cpp : gcc.compile ; \ No newline at end of file diff --git a/v2/example/make/lib/b.cpp b/v2/example/make/lib/b.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/v2/example/make/project-root.jam b/v2/example/make/project-root.jam new file mode 100644 index 000000000..6c67b316f --- /dev/null +++ b/v2/example/make/project-root.jam @@ -0,0 +1,9 @@ + +import modules ; + +# Temporary workaround. +local location = [ project-root get-location ] ; +local new_path = [ modules.peek : BOOST_BUILD_PATH ] $(location) ; +modules.poke : BOOST_BUILD_PATH : $(new_path) ; + +import gcc ; diff --git a/v2/example/make/readme.txt b/v2/example/make/readme.txt new file mode 100644 index 000000000..499dbba96 --- /dev/null +++ b/v2/example/make/readme.txt @@ -0,0 +1,17 @@ + +Example of a simple project, which builds an executable using g++. +All the transformations are specified explicitly. +It illustrates the use of project identifiers to refer to other targets +and also project requirements. + + +Interesting commands would be + + bjam + bjam release + bjam release clean + bjam release debug-symbols=on + +Also, you can use jam's "-n" option to check if "debug"/"release" have any +effect on commands executed. (Note that "-n" should go before any non-option +elements on command line).