early-access version 3088

This commit is contained in:
pineappleEA
2022-11-05 15:35:56 +01:00
parent 4e4fc25ce3
commit b601909c6d
35519 changed files with 5996896 additions and 860 deletions

View File

@@ -0,0 +1,3 @@
= The Dangerous and Thrilling Documentation Chronicles
This journey begins on a bleary Monday morning.

View File

@@ -0,0 +1,38 @@
= b2(1)
Rene Rivera
v0.0.0
:doctype: manpage
:manmanual: B2
:mansource: B2
:man-linkstyle: pass:[blue R < >]
== NAME
b2 - Boost Build
== SYNOPSIS
*b2* ['OPTION']... 'TARGET'...
== OPTIONS
*-n*::
Print out what would get built.
== EXIT STATUS
*0*::
Success.
*1*::
Failure.
== RESOURCES
*Project web site:* http://boost.org
== COPYING
Copyright \(C) 2017 {author}. +
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.txt or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)

View File

@@ -0,0 +1,11 @@
#|
Copyright 2017 Rene Rivera
Distributed under the Boost Software License, Version 1.0. (See
accompanying file LICENSE.txt or copy at
https://www.bfgroup.xyz/b2/LICENSE.txt)
|#
html example_html : example.adoc ;
manpage example_1 : example_manpage.adoc ;
pdf example_pdf : example.adoc ;
docbook example_docbook : example.adoc ;

View File

@@ -0,0 +1,6 @@
# Copyright 2002, 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
boost-build ../src/kernel ;

View File

@@ -0,0 +1,8 @@
import feature ;
feature.feature tblgen : : dependency free ;
project built_tool ;
build-project core ;

View File

@@ -0,0 +1,39 @@
import toolset ;
import os ;
project : requirements <tblgen>../tblgen//tblgen ;
# Create a.c using a custom action defined below.
make a.c : a.td : @tblgen ;
# Use a.c in executable.
exe core : core.cpp a.c ;
# The action has to invoke the tool built in other
# parts of the project. The <tblgen> feature is used
# to specify the location of the tool, and the flags
# statement below make the full path to the tool
# available inside the action.
toolset.flags tblgen COMMAND <tblgen> ;
# We generally want a.c to be rebuilt when the tool changes.
rule tblgen ( targets * : sources * : properties * )
{
DEPENDS $(targets) : [ on $(targets) return $(COMMAND) ] ;
}
# The action that invokes the tool
actions tblgen bind COMMAND
{
$(COMMAND:E=tblgen) > $(<)
}
if [ os.name ] = VMS
{
actions tblgen bind COMMAND
{
PIPE MCR $(COMMAND:WE=tblgen) > $(<:W)
}
}

View File

@@ -0,0 +1,5 @@
int main()
{
return 0;
}

View File

@@ -0,0 +1,5 @@
This example shows how to build an executable and then use it
for generating other targets. The 'tblgen' subdirectory builds
a tool, while the 'core' subdirectory uses that tool. Refer
to core/Jamfile.jam for detailed comments.

View File

@@ -0,0 +1,4 @@
project : requirements -<tblgen>tblgen//tblgen ;
exe tblgen : tblgen.cpp ;

View File

@@ -0,0 +1,9 @@
#include <iostream>
int main()
{
std::cout << "int foo;\n";
return 0;
}

View File

@@ -0,0 +1,14 @@
// Copyright (c) 2014 Rene Rivera
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <iostream>
#include <cstdlib>
int main()
{
std::cout << "Bye!\n";
return EXIT_FAILURE
}

View File

@@ -0,0 +1,14 @@
// Copyright (c) 2014 Rene Rivera
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <iostream>
#include <cstdlib>
int main()
{
std::cout << "Bye!\n";
return EXIT_FAILURE;
}

View File

@@ -0,0 +1,15 @@
# Copyright 2016 Rene Rivera
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
using testing ;
import property-set ;
import path ;
exe success : success.cpp ;
run success : arg1 arg2 : : : success-a ;
run success : arg3 arg4 : : : success-b ;
run post.cpp : : success-a : : post-a ;
run post.cpp : : success-b : : post-b ;

View File

@@ -0,0 +1,14 @@
// Copyright (c) 2014 Rene Rivera
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[])
{
std::cout << argv[1] << "\n";
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,14 @@
// Copyright (c) 2014 Rene Rivera
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <iostream>
#include <cstdlib>
int main(int argc, char *argv[])
{
std::cout << "Hi!\n";
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,7 @@
class_template
class %class_name% {
public:
%class_name%() {}
~%class_name%() {}
};

View File

@@ -0,0 +1,36 @@
// (C) Copyright Vladimir Prus, 2003
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
// Please see 'usage.verbatim' file for usage notes.
#include <iostream>
#include <string>
#include <cstring>
using std::cout;
using std::string;
using std::strlen;
extern const char class_template[];
extern const char usage[];
int main(int ac, char* av[])
{
if (av[1]) {
string class_name = av[1];
string s = class_template;
string::size_type n;
while((n = s.find("%class_name%")) != string::npos) {
s.replace(n, strlen("%class_name%"), class_name);
}
std::cout << "Output is:\n";
std::cout << s << "\n";
return 0;
} else {
std::cout << usage << "\n";
return 1;
}
}

View File

@@ -0,0 +1,44 @@
#!/usr/bin/python
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
import sys
from string import strip
def quote_line(line):
result = ""
for i in line:
if (i == '\\'):
result = result + '\\\\'
elif (i == '\"'):
result = result + '\\\"'
elif (i != '\r' and i != '\n'):
result = result + i;
return '\"' + result + '\\n\"'
def quote_file(file):
result = ""
for i in file.readlines():
result = result + quote_line(i) + "\n"
return result
if len(sys.argv) < 3:
print "Usage: inline_file.py output_c_file file_to_include"
else:
output_c_file = sys.argv[1]
out_file = open(output_c_file, "w");
file_to_include = sys.argv[2]
in_file = open(file_to_include, "r");
variable_name = strip(in_file.readline())
out_file.write("extern const char %s[] = {\n%s};\n\n" % (variable_name, quote_file(in_file)))
in_file.close()
out_file.close()

View File

@@ -0,0 +1,9 @@
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
import verbatim ;
exe codegen : codegen.cpp class.verbatim usage.verbatim
t1.verbatim ;

View File

@@ -0,0 +1,11 @@
Copyright 2003 Vladimir Prus
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
This example show how to add a new target type and a new tool support to
B2. Please refer to extender manual for a complete description of this
example.
Note that this example requires Python. If cygwin Python on Windows is to be
used, please go to "verbatim.jam" and follow instructions there.

View File

@@ -0,0 +1,2 @@
t1
//###include "t2.verbatim"

View File

@@ -0,0 +1,5 @@
usage
Usage: codegen class_name
This program takes a template of C++ code and replaces of all occurrences of
%class_name% with the passed 'class_name' parameter.

View File

@@ -0,0 +1,61 @@
# Copyright 2003, 2004 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
# This file shows some of the primary customization mechanisms in B2 V2
# and should serve as a basic for your own customization.
# Each part has a comment describing its purpose, and you can pick the parts
# which are relevant to your case, remove everything else, and then change names
# and actions to taste.
import os ;
# Declare a new target type. This allows B2 to do something sensible
# when targets with the .verbatim extension are found in sources.
import type ;
type.register VERBATIM : verbatim ;
# Declare a dependency scanner for the new target type. The
# 'inline-file.py' script does not handle includes, so this is
# only for illustraction.
import scanner ;
# First, define a new class, derived from 'common-scanner',
# that class has all the interesting logic, and we only need
# to override the 'pattern' method which return regular
# expression to use when scanning.
class verbatim-scanner : common-scanner
{
rule pattern ( )
{
return "//###include[ ]*\"([^\"]*)\"" ;
}
}
# Register the scanner class. The 'include' is
# the property which specifies the search path
# for includes.
scanner.register verbatim-scanner : include ;
# Assign the scanner class to the target type.
# Now, all .verbatim sources will be scanned.
# To test this, build the project, touch the
# t2.verbatim file and build again.
type.set-scanner VERBATIM : verbatim-scanner ;
import generators ;
generators.register-standard verbatim.inline-file : VERBATIM : CPP ;
# Note: To use Cygwin Python on Windows change the following line
# to "python inline_file.py $(<) $(>)"
# Also, make sure that "python" in in PATH.
actions inline-file
{
"./inline_file.py" $(<) $(>)
}
if [ os.name ] = VMS
{
actions inline-file
{
python inline_file.py $(<:W) $(>:W)
}
}

View File

@@ -0,0 +1,47 @@
# Copyright 2010 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
# This file is only used with Python port of Boost.Build
# This file shows some of the primary customization mechanisms in Boost.Build V2
# and should serve as a basic for your own customization.
# Each part has a comment describing its purpose, and you can pick the parts
# which are relevant to your case, remove everything else, and then change names
# and actions to taste.
# Declare a new target type. This allows Boost.Build to do something sensible
# when targets with the .verbatim extension are found in sources.
import b2.build.type as type
type.register("VERBATIM", ["verbatim"])
# Declare a dependency scanner for the new target type. The
# 'inline-file.py' script does not handle includes, so this is
# only for illustraction.
import b2.build.scanner as scanner;
# First, define a new class, derived from 'common-scanner',
# that class has all the interesting logic, and we only need
# to override the 'pattern' method which return regular
# expression to use when scanning.
class VerbatimScanner(scanner.CommonScanner):
def pattern(self):
return "//###include[ ]*\"([^\"]*)\""
scanner.register(VerbatimScanner, ["include"])
type.set_scanner("VERBATIM", VerbatimScanner)
import b2.build.generators as generators
generators.register_standard("verbatim.inline-file",
["VERBATIM"], ["CPP"])
from b2.manager import get_manager
get_manager().engine().register_action("verbatim.inline-file",
"""
./inline_file.py $(<) $(>)
""")

View File

@@ -0,0 +1,11 @@
# Copyright 2007 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
This example shows the 'generate' rule, that allows you to construct target
using any arbitrary set of transformation and commands.
The rule is similar to 'make' and 'notfile', but unlike those, you can operate
in terms of B2 'virtual targets', which is more flexible.
Please consult the docs for more explanations.

View File

@@ -0,0 +1,10 @@
int main()
{
}
/*
Copyright 2007 Vladimir Prus
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
*/

View File

@@ -0,0 +1,26 @@
import "class" : new ;
import common ;
rule generate-example ( project name : property-set : sources * )
{
local result ;
for local s in $(sources)
{
#local source-name = [ $(s).name ] ;
#local source-action = [ $(s).action ] ;
#local source-properties = [ $(source-action).properties ] ;
# Create a new action, that takes the source target and runs the
# 'common.copy' command on it.
local a = [ new non-scanning-action $(s) : common.copy : $(property-set)
] ;
# Create a target to represent the action result. Uses the target name
# passed here via the 'name' parameter and the same type and project as
# the source.
result += [ new file-target $(name) : [ $(s).type ] : $(project) : $(a)
] ;
}
return $(result) ;
}

View File

@@ -0,0 +1,16 @@
from b2.build.virtual_target import NonScanningAction, FileTarget
def generate_example(project, name, ps, sources):
result = []
for s in sources:
a = NonScanningAction([s], "common.copy", ps)
# Create a target to represent the action result. Uses the target name
# passed here via the 'name' parameter and the same type and project as
# the source.
result.append(FileTarget(name, s.type(), project, a))
return result

View File

@@ -0,0 +1,9 @@
# Copyright 2007 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
import generate ;
import gen ;
generate a2 : a.cpp : <generating-rule>@gen.generate-example ;

View File

@@ -0,0 +1,6 @@
# Copyright 2006 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
This example shows how to declare a new generator class. It is necessary when
generator's logic is more complex that just running a single tool.

View File

@@ -0,0 +1,10 @@
int main()
{
return 0;
}
/*
Copyright 2006 Vladimir Prus
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
*/

View File

@@ -0,0 +1,6 @@
# Copyright 2006 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
import soap ;
exe foo : foo.gci : <server>on ;

View File

@@ -0,0 +1,86 @@
# Copyright 2006 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
# This is example of a fictional code generator tool.
# It accepts a single input of type '.gci' and produces
# either one or two outputs of type .cpp, depending
# on the value of the feature <server-mode>
#
# This example is loosely based on gSOAP code generator.
import type ;
import generators ;
import feature ;
import common ;
import "class" : new ;
import os ;
type.register GCI : gci ;
feature.feature server : off on : incidental ;
class soap-generator : generator
{
import "class" : new ;
rule __init__ ( * : * )
{
generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
}
rule run ( project name ? : property-set : sources * )
{
if ! $(sources[2])
{
# Accept only single source.
local t = [ $(sources[1]).type ] ;
if $(t) = GCI
{
# The type is correct.
# If no output name is specified, guess it from sources.
if ! $(name)
{
name = [ generator.determine-output-name $(sources) ] ;
}
# Produce one output, using just copy.
local a = [ new action $(sources[1])
: common.copy : $(property-set) ] ;
local t = [ new file-target $(name) : CPP : $(project)
: $(a) ] ;
# If in server mode, create another output -- an
# empty file. If this were a real SOAP generator, we
# might have created a single action, and two targets
# both using that action.
local t2 ;
if [ $(property-set).get <server> ] = "on"
{
local a = [ new action : soap.touch : $(property-set) ] ;
t2 = [ new file-target $(name)_server : CPP : $(project)
: $(a) ] ;
}
return [ virtual-target.register $(t) ]
[ virtual-target.register $(t2) ] ;
}
}
}
}
generators.register [ new soap-generator soap.soap : GCI : CPP ] ;
TOUCH = [ common.file-touch-command ] ;
actions touch
{
$(TOUCH) $(<)
}
if [ os.name ] = VMS
{
actions touch
{
$(TOUCH) $(<:W)
}
}

View File

@@ -0,0 +1,26 @@
# Copyright 2003, 2006 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
# Declare a main target.
exe main : main.cpp ;
# Declare an action for updating translations
# After changing main.cpp, invocation of
#
# bjam update-russian
#
# will update translations in russian.po
gettext.update update-russian : russian.po main ;
# Compiled message catalog.
gettext.catalog russian : russian.po ;
# A stage rule which installs message catalog to the
# location gettext expects.
stage messages-russian : russian
: <location>messages/ru_RU.KOI8-R/LC_MESSAGES
<name>main.mo
;

View File

@@ -0,0 +1,6 @@
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
using gettext ;

View File

@@ -0,0 +1,28 @@
// Copyright Vladimir Prus 2003.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt
// or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <locale.h>
#include <libintl.h>
#define i18n(s) gettext(s)
#include <iostream>
using namespace std;
int main()
{
// Specify that translations are stored in directory
// "messages".
bindtextdomain("main", "messages");
textdomain("main");
// Switch to russian locale.
setlocale(LC_MESSAGES, "ru_RU.KOI8-R");
// Output localized message.
std::cout << i18n("hello") << "\n";
return 0;
}

View File

@@ -0,0 +1,24 @@
Copyright 2003 Vladimir Prus
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
This example shows how it is possible to use GNU gettext utilities with
B2.
A simple translation file is compiled and installed as message catalog for
russian. The main application explicitly switches to russian locale and outputs
the translation of "hello".
To test:
bjam
bin/gcc/debug/main
To test even more:
- add more localized strings to "main.cpp"
- run "bjam update-russian"
- edit "russian.po"
- run bjam
- run "main"

View File

@@ -0,0 +1,21 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2003-07-01 15:45+0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: main.cpp:16
msgid "hello"
msgstr "international hello"

View File

@@ -0,0 +1,14 @@
// Copyright (c) 2003 Vladimir Prus
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
// tag::source[]
#include <iostream>
int main()
{
std::cout << "Hello!\n";
}
// end::source[]

View File

@@ -0,0 +1 @@
exe hello : hello.cpp ;

View File

@@ -0,0 +1,46 @@
////
Copyright 2008 Jurko Gospodnetic
Copyright 2017 Rene Rivera
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
////
= Hello
This example shows a very basic Boost Build project set up so it compiles a
single executable from a single source file:
.`hello.cpp`
[source,cpp]
----
include::../../example/hello/hello.cpp[tag=source]
----
Our `jamroot.jam` is minimal and only specifies one `exe` target for the
program:
.`jamroot.jam`
[source,jam]
----
include::jamroot.jam[]
----
Building the example yields:
[source,bash]
----
> cd /example/hello
> b2
...found 8 targets...
...updating 4 targets...
common.mkdir bin/clang-darwin-4.2.1
common.mkdir bin/clang-darwin-4.2.1/debug
clang-darwin.compile.c++ bin/clang-darwin-4.2.1/debug/hello.o
clang-darwin.link bin/clang-darwin-4.2.1/debug/hello
...updated 4 targets...
> bin/clang-darwin-4.2.1/debug/hello
Hello!
----
NOTE: The actual paths in the `bin` sub-directory will depend on your
toolset.

View File

@@ -0,0 +1,12 @@
// Copyright (c) 2003 Vladimir Prus
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <lib1.h>
int main()
{
foo();
}

View File

@@ -0,0 +1,9 @@
# Copyright 2002, 2003, 2005 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
# Declare a executable file, which uses a library. Note that
# includes that for library will be automatically used
# when compiling 'app.cpp'
exe app : app.cpp /library-example/foo//bar ;

View File

@@ -0,0 +1,4 @@
use-project /library-example/foo : util/foo ;
build-project app ;

View File

@@ -0,0 +1,10 @@
// Copyright (c) 2003 Vladimir Prus
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
#ifdef _WIN32
__declspec(dllexport)
#endif
void foo() {}

View File

@@ -0,0 +1,7 @@
// Copyright (c) 2003 Vladimir Prus
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
void foo();

View File

@@ -0,0 +1,9 @@
# Copyright 2005 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
project
: usage-requirements <include>include ;
lib bar : bar.cpp ;

View File

@@ -0,0 +1,2 @@
import sys
open(sys.argv[2], "w").write(open(sys.argv[1]).read())

View File

@@ -0,0 +1,22 @@
import feature ;
import toolset ;
import os ;
path-constant HERE : . ;
make main.cpp : main_cpp.pro : @do-something ;
feature.feature example.python.interpreter : : free ;
toolset.flags do-something PYTHON : <example.python.interpreter> ;
actions do-something
{
"$(PYTHON:E=python)" "$(HERE)/foo.py" "$(>)" "$(<)"
}
if [ os.name ] = VMS
{
actions do-something
{
$(PYTHON:E=python) $(HERE:W)foo.py $(>:W) $(<:W)
}
}

View File

@@ -0,0 +1 @@
int main() {}

View File

@@ -0,0 +1,7 @@
Copyright 2002, 2005 Vladimir Prus
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
Example of using custom command to create one file from another, using the
built-in 'make' rule.

View File

@@ -0,0 +1,54 @@
# showcasing several default install directories
install a1 : a : <location>(bindir) ;
install a2 : a : <location>(libdir)/a2 ;
install (sbindir)/a3 : a ;
# using a custom prefix; the file will be installed into foo/bar/bin/a4
install (bindir)/a4 : a : <install-prefix>foo/bar ;
# this one deduces installed package name to be the basename of the project
# directory, so e.g. on Linux the file will be installed installed into
# /usr/local/share/doc/<name of project's directory>/a5
install (docdir)/a5 : a : <install-prefix>bar/baz ;
# use a custom named directory; its default on Linux is /usr/local/share/xyz/
import stage ;
stage.add-install-dir foodir : xyz : datadir ;
install (foodir)/a6 : a ;
# another custom named directory, this one appends package name like docdir;
# so, e.g. on Linux it defaults to /usr/local/lib/named-install-dirs
stage.add-install-dir privatedir : "" : libdir : package-suffix ;
install (privatedir)/a7 : a ;
# using stage.get-package-name
make a8 : a : @write-dirs : <staging-prefix>p/q/r <install-bindir>/bin ;
rule write-dirs ( target : sources * : properties * )
{
import property-set ;
import print ;
local ps = [ property-set.create $(properties) ] ;
local pn = [ stage.get-package-name $(ps) ] ;
print.output $(target) ;
print.text
[ stage.get-dir docdir : $(ps) : $(pn) ]
[ stage.get-dir docdir : $(ps) : $(pn) : staged ]
[ stage.get-dir docdir : $(ps) : $(pn) : relative ]
[ stage.get-dir docdir : $(ps) : $(pn) : relative staged ]
[ stage.get-dir bindir : $(ps) : $(pn) : relative ]
: overwrite
;
}
# using staging prefix; on Linux installs into q/r/s/share/a9
install (datarootdir)/a9 : a : <staging-prefix>q/r/s ;
build-project x ;
# Copyright 2020 Dmitry Arkhipov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at
# https://www.bfgroup.xyz/b2/LICENSE.txt)

View File

@@ -0,0 +1,5 @@
# this subproject showcases installed package name deduction
project subx ;
build-project y ;
build-project z ;

View File

@@ -0,0 +1,9 @@
# this subproject doesn't have a name, so its default package name is deduced
# from its parent
install (docdir)/y1 : ../../a ;
# Copyright 2020 Dmitry Arkhipov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at
# https://www.bfgroup.xyz/b2/LICENSE.txt)

View File

@@ -0,0 +1,11 @@
# this subproject does have a name, so its name is used as its default package
# name
project subz ;
install (docdir)/z1 : ../../a ;
# Copyright 2020 Dmitry Arkhipov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or copy at
# https://www.bfgroup.xyz/b2/LICENSE.txt)

View File

@@ -0,0 +1,17 @@
/*
Copyright Rene Rivera 2019
Distributed under the Boost Software License, Version 1.0. (See
accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef B2_EXAMPLE_PCH_MULTI_EXTRA_META_HPP
#define B2_EXAMPLE_PCH_MULTI_EXTRA_META_HPP
#include <type_traits>
#include <functional>
#include <typeindex>
#include <tuple>
#endif

View File

@@ -0,0 +1,19 @@
/* Copyright 2006 Vladimir Prus
Distributed under the Boost Software License, Version 1.0. (See
accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
#ifdef BOOST_BUILD_PCH_ENABLED
#ifdef FOO2
int bar();
#endif
class TestClass {
public:
TestClass(int, int) {}
};
#endif

View File

@@ -0,0 +1,16 @@
/*
Copyright Rene Rivera 2019
Distributed under the Boost Software License, Version 1.0. (See
accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef B2_EXAMPLE_PCH_MULTI_STD_HPP
#define B2_EXAMPLE_PCH_MULTI_STD_HPP
#include <iostream>
#include <vector>
#include <algorithm>
#endif

View File

@@ -0,0 +1,30 @@
# Copyright 2006 Ilya Sokolov
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE.txt or copy at
# https://www.bfgroup.xyz/b2/LICENSE.txt)
# pch ##########################################################################
import pch ;
local pchs ;
for local hpp in [ glob-tree *.hpp ]
{
cpp-pch $(hpp:B) : $(hpp) : <include>include ;
explicit $(hpp:B) ;
pchs += $(hpp:B) ;
}
alias headers : $(pchs) ;
# exe ##########################################################################
exe hello_world
: # sources
headers
source/hello_world.cpp
: # requirements
<include>include
: # default build
: # usage requirements
;

View File

@@ -0,0 +1,17 @@
/* Copyright 2006 Ilya Sokolov
Copyright 2006 Vladimir Prus
Distributed under the Boost Software License, Version 1.0. (See
accompanying file LICENSE.txt or copy at
https://www.bfgroup.xyz/b2/LICENSE.txt)
*/
#include <pch.hpp>
#include <std.hpp>
#include <extra/meta.hpp>
int main()
{
TestClass c(1, 2);
return 0;
}

View File

@@ -0,0 +1,19 @@
/* Copyright 2006 Vladimir Prus
Distributed under the Boost Software License, Version 1.0. (See
accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
#ifdef BOOST_BUILD_PCH_ENABLED
#ifdef FOO2
int bar();
#endif
class TestClass {
public:
TestClass(int, int) {}
};
#endif

View File

@@ -0,0 +1,29 @@
# Copyright 2006 Ilya Sokolov
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE.txt or copy at
# https://www.bfgroup.xyz/b2/LICENSE.txt)
# pch ##########################################################################
import pch ;
cpp-pch pch
: # sources
include/pch.hpp
: # requirements
<include>include
;
explicit pch ;
# exe ##########################################################################
exe hello_world
: # sources
pch
source/hello_world.cpp
: # requirements
<include>include
: # default build
: # usage requirements
;

View File

@@ -0,0 +1,15 @@
/* Copyright 2006 Ilya Sokolov
Copyright 2006 Vladimir Prus
Distributed under the Boost Software License, Version 1.0. (See
accompanying file LICENSE.txt or copy at
https://www.bfgroup.xyz/b2/LICENSE.txt)
*/
#include <pch.hpp>
int main()
{
TestClass c(1, 2);
return 0;
}

View File

@@ -0,0 +1,4 @@
Name: debugged
Version: 0.1
Description: A package with separate debug version (debug version)
Cflags: -DVARIANT=\"DEBUG\"

View File

@@ -0,0 +1,104 @@
#|
Copyright 2019 Dmitry Arkhipov
Distributed under the Boost Software License, Version 1.0. (See
accompanying file LICENSE.txt or copy at
https://www.bfgroup.xyz/b2/LICENSE.txt)
|#
using pkg-config : : : <libdir>packages ;
using pkg-config : debug : : <libdir>packages <path>debug-packages ;
import common ;
import pkg-config ;
import property-set ;
import testing ;
import version ;
project : requirements <variant>debug:<pkg-config>debug ;
pkg-config.import debugged ;
pkg-config.import foobar : requirements <version>>=0.3 ;
pkg-config.import mangled : requirements <conditional>@mangle-name ;
versioned =
[ pkg-config.import versioned
: usage-requirements <conditional>@versioned-api
] ;
with-var =
[ pkg-config.import with-var
: usage-requirements <conditional>@var-to-define
] ;
# test if a package is found at all
run test1.cpp foobar ;
# test if conditional requirement is applied
run test2.cpp mangled
: target-name test2-1
: requirements <threading>single
: args SINGLE
;
run test2.cpp mangled
: target-name test2-2
: requirements <threading>multi
: args MULTI
;
# test if pkg-config configuration is properly inferred from property set
run test3.cpp debugged
: target-name test3-1
: requirements <variant>release
: args RELEASE
;
run test3.cpp debugged
: target-name test3-2
: requirements <variant>debug
: args DEBUG
;
# test use of version method of pkg-config targets
run test4.cpp versioned ;
# test use of variable method of pkg-config targets
run test5.cpp with-var ;
rule mangle-name ( props * ) {
import feature ;
local name =
[ common.format-name
<base> <threading>
: mangled
: ""
: [ property-set.create $(props) ]
] ;
return <name>$(name) ;
}
rule versioned-api ( props * ) {
local ps = [ property-set.create $(props) ] ;
local version = [ $(versioned).version $(ps) ] ;
if [ version.version-less $(version) : 2 ]
{
return <define>VERSIONED_API=1 ;
}
else
{
return <define>VERSIONED_API=2 ;
}
}
rule var-to-define ( props * ) {
local ps = [ property-set.create $(props) ] ;
local qwerty = [ $(with-var).variable qwerty : $(ps) ] ;
return <define>QWERTY=\\\"$(qwerty)\\\" ;
}

View File

@@ -0,0 +1,4 @@
Name: debugged
Version: 0.1
Description: A package with separate debug version (release version)
Cflags: -DVARIANT=\"RELEASE\"

View File

@@ -0,0 +1,4 @@
Name: foobar
Version: 0.3
Description: The bar for your foo
Cflags: -DQWERTY=\"uiop\"

View File

@@ -0,0 +1,4 @@
Name: mangled
Version: 0.1
Description: A package with mangled name (multi-threaded version)
Cflags: -DTHREADING=\"MULTI\"

View File

@@ -0,0 +1,4 @@
Name: mangled
Version: 0.1
Description: A package with mangled name (single-threaded version)
Cflags: -DTHREADING=\"SINGLE\"

View File

@@ -0,0 +1,3 @@
Name: versioned
Version: 4.2
Description: A package with versioned API

View File

@@ -0,0 +1,4 @@
qwerty=UIOP
Name: with-var
Version: 0.1
Description: A package that defines a custom variable

View File

@@ -0,0 +1,11 @@
// Copyright 2019 Dmitry Arkhipov
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <string>
int main() {
return QWERTY == std::string("uiop") ? EXIT_SUCCESS : EXIT_FAILURE ;
}

View File

@@ -0,0 +1,12 @@
// Copyright 2019 Dmitry Arkhipov
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <string>
#include <iostream>
int main(int, char const** argv) {
return THREADING == std::string(argv[1]) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@@ -0,0 +1,12 @@
// Copyright 2019 Dmitry Arkhipov
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <string>
#include <iostream>
int main(int, char const** argv) {
return VARIANT == std::string(argv[1]) ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@@ -0,0 +1,11 @@
// Copyright 2019 Dmitry Arkhipov
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
#if VERSIONED_API < 2
# error "API is too old"
#endif
int main() {}

View File

@@ -0,0 +1,12 @@
// Copyright 2019 Dmitry Arkhipov
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE.txt or copy at
// https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <string>
#include <iostream>
int main(int, char const** argv) {
return QWERTY == std::string("UIOP") ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@@ -0,0 +1,8 @@
# Copyright 2006 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
import python_helpers ;
ECHO "test1:" [ python_helpers.test1 ] ;
ECHO "test2:" [ python_helpers.test2 1234 : 5678 ] ;

View File

@@ -0,0 +1,15 @@
# Copyright 2006 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
import modules ;
local here = [ modules.binding $(__name__) ] ;
here = $(here:D) ;
modules.poke : EXTRA_PYTHONPATH : $(here) ;
# Import the Python rules to B2
PYTHON_IMPORT_RULE python_helpers : test1 : python_helpers : test1 ;
PYTHON_IMPORT_RULE python_helpers : test2 : python_helpers : test2 ;
# Make the new rules accessible to everybody who imports us.
EXPORT python_helpers : test1 test2 ;

View File

@@ -0,0 +1,18 @@
# Copyright 2006 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
# Declare a couple of functions called from B2
#
# Each function will receive as many arguments as there ":"-separated
# arguments in bjam call. Each argument is a list of strings.
# As a special exception (aka bug), if no arguments are passed in bjam,
# Python function will be passed a single empty list.
#
# All Python functions must return a list of strings, which may be empty.
def test1(l):
return ["foo", "bar"]
def test2(l, l2):
return [l[0], l2[0]]

View File

@@ -0,0 +1,16 @@
Copyright 2006 Vladimir Prus
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
This example shows how you can use Python modules from B2.
In order to do this, you need to build bjam with Python support, by running:
./build.sh --with-python=/usr
in the jam/src directory (replace /usr with the root of your Python
installation).
The integration between Python and bjam is very basic now, but enough to be
useful.

View File

@@ -0,0 +1,20 @@
Copyright 2005 Vladimir Prus
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
This directory contains B2 examples for the Qt library
(http://www.trolltech.com/products/qt/index.html).
The current examples are:
1. Basic setup -- application with several sources and moccable header.
2. Using of .ui source file.
3. Running .cpp files via the moc tool.
For convenience, there are examples both for 3.* and 4.* version of Qt, they are
mostly identical and differ only in source code.
All examples assumes that you just installed B2 and that QTDIR
environment variables is set (typical values can be /usr/share/qt3 and
/usr/share/qt4). After adding "using qt ..." to your user-config.jam, you would
have to remove "using qt ; " statements from example Jamroot files.

View File

@@ -0,0 +1,73 @@
// Copyright Vladimir Prus 2004.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt
// or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
#include "canvas.h"
#include <qlabel.h>
#include <qcanvas.h>
#include <qlayout.h>
Canvas::Canvas(QWidget* parent)
: QWidget(parent)
{
m_pen = QPen(QColor(255, 128, 128));
m_brushes = new QBrush[2];
m_brushes[0] = QBrush(QColor(255, 0, 0));
m_brushes[1] = QBrush(QColor(0, 255, 0));
m_current_brush = 0;
m_canvas = new QCanvas(this);
m_canvas->resize(4*1600, 600);
redraw();
QVBoxLayout* l = new QVBoxLayout(this);
m_canvas_view = new QCanvasView(m_canvas, this);
l->addWidget(m_canvas_view);
m_canvas_view->resize(rect().size());
m_canvas_view->show();
}
Canvas::~Canvas()
{
delete m_brushes;
}
void Canvas::redraw()
{
QCanvasItemList l = m_canvas->allItems();
for(QCanvasItemList::iterator i = l.begin(),
e = l.end(); i != e; ++i)
{
delete *i;
}
unsigned count = 0;
for (unsigned x = 10; x < 4*1600; x += 20)
for (unsigned y = 10; y < 600; y += 20) {
QCanvasRectangle* r = new QCanvasRectangle(x, y, 10, 10, m_canvas);
r->setPen(m_pen);
r->setBrush(m_brushes[m_current_brush]);
r->show();
++count;
QCanvasText* t = new QCanvasText("D", m_canvas);
t->move(x, y);
t->show();
++count;
}
(new QCanvasText(QString::number(count), m_canvas))->show();
m_canvas->setAllChanged();
}
void Canvas::change_color()
{
m_current_brush = (m_current_brush + 1)%2;
redraw();
m_canvas->update();
}

View File

@@ -0,0 +1,35 @@
// Copyright Vladimir Prus 2004.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt
// or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
#ifndef CANVAS_VP_2004_08_31
#define CANVAS_VP_2004_08_31
#include <qmainwindow.h>
#include <qpen.h>
#include <qbrush.h>
class Canvas : public QWidget
{
Q_OBJECT
public:
Canvas(QWidget* parent);
virtual ~Canvas();
public slots:
void change_color();
private:
void redraw();
class QCanvas* m_canvas;
class QCanvasView* m_canvas_view;
class QPen m_pen;
class QBrush* m_brushes;
int m_current_brush;
};
#endif

View File

@@ -0,0 +1,13 @@
# Copyright Vladimir Prus 2004.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt
# or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
using qt ;
project
# built MT version, unless asked otherwise.
: default-build <threading>multi
;
exe canvas : main.cpp canvas.cpp canvas.h : <library>/qt//qt ;

View File

@@ -0,0 +1,36 @@
// Copyright Vladimir Prus 2004.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt
// or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
#include "canvas.h"
#include <qapplication.h>
#include <qvbox.h>
#include <qpushbutton.h>
class Window : public QMainWindow
{
public:
Window()
{
setCaption("QCanvas test");
QVBox* vb = new QVBox(this);
setCentralWidget(vb);
Canvas* c = new Canvas(vb);
QPushButton* b = new QPushButton("Change color", vb);
connect(b, SIGNAL(clicked()), c, SLOT(change_color()));
}
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
Window *w = new Window();
app.setMainWidget(w);
w->show();
return app.exec();
}

View File

@@ -0,0 +1,11 @@
using qt ;
import cast ;
project
: default-build <threading>multi
;
exe main : main.cpp [ cast _ moccable-cpp : main.cpp ]
/qt//qt
;

View File

@@ -0,0 +1,41 @@
// Copyright Vladimir Prus 2005.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt
// or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <qwidget.h>
#include <qpushbutton.h>
#include <qapplication.h>
#include <iostream>
class My_widget : public QWidget
{
Q_OBJECT
public:
My_widget() : QWidget()
{
QPushButton* b = new QPushButton("Push me", this);
connect(b, SIGNAL(clicked()), this, SLOT(theSlot()));
}
private slots:
void theSlot()
{
std::cout << "Clicked\n";
}
};
int main(int ac, char* av[])
{
QApplication app(ac, av);
My_widget mw;
mw.show();
app.setMainWidget(&mw);
app.exec();
}
#include "main.moc"

View File

@@ -0,0 +1,58 @@
<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
<class>HelloWorldWidget</class>
<comment>
<!--
Copyright Felix E. Klee, 2003
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at http://www.boost.org/LICENSE_1_0.txt)
-->
</comment>
<widget class="QWidget">
<property name="name">
<cstring>HelloWorldWidget</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>124</width>
<height>63</height>
</rect>
</property>
<property name="caption">
<string>Hello World!</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>11</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="QLabel">
<property name="name">
<cstring>TextLabel2</cstring>
</property>
<property name="text">
<string>Hello World!</string>
</property>
<property name="alignment">
<set>AlignCenter</set>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>OkButton</cstring>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
</vbox>
</widget>
<layoutdefaults spacing="6" margin="11"/>
</UI>

View File

@@ -0,0 +1,15 @@
# Copyright Felix E. Klee, 2003
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt
# or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
# Tell that QT should be used. QTDIR will give installation
# prefix.
using qt ;
project
: default-build <threading>multi
;
exe hello : main.cpp hello_world_widget.ui : <library>/qt//qt ;

View File

@@ -0,0 +1,18 @@
// Copyright Felix E. Klee, 2003
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt
// or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
#include "hello_world_widget.h"
#include <qapplication.h>
#include <qpushbutton.h>
int main(int argc, char **argv) {
QApplication a(argc, argv);
HelloWorldWidget w;
QObject::connect(static_cast<QObject*>(w.OkButton), SIGNAL(clicked()), &w, SLOT(close()));
a.setMainWidget(&w);
w.show();
return a.exec();
}

View File

@@ -0,0 +1,158 @@
// Copyright Vladimir Prus 2005.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt
// or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
#include "arrow.h"
#include <QtGui/qapplication.h>
#include <QtGui/qwidget.h>
#include <QtGui/qpainter.h>
#include <QtGui/qpainterpath.h>
#include <stdlib.h>
#include <math.h>
Arrow_widget::Arrow_widget(QWidget* parent) : QWidget(parent), color_(0)
{
QPalette pal = palette();
pal.setBrush(backgroundRole(), QBrush(Qt::white));
setPalette(pal);
}
void Arrow_widget::slotChangeColor()
{
color_ = (color_ + 1) % 3;
update();
}
void
Arrow_widget::draw_arrow(int x1, int y1, int x2, int y2, QPainter& painter)
{
// The length of the from the tip of the arrow to the point
// where line starts.
const int arrowhead_length = 16;
QPainterPath arrow;
arrow.moveTo(x1, y1);
// Determine the angle of the straight line.
double a1 = (x2-x1);
double a2 = (y2-y1);
double b1 = 1;
double b2 = 0;
double straight_length = sqrt(a1*a1 + a2*a2);
double dot_product = a1*b1 + a2*b2;
double cosine = dot_product/
(sqrt(pow(a1, 2) + pow(a2, 2))*sqrt(b1 + b2));
double angle = acos(cosine);
if (y1 < y2)
{
angle = -angle;
}
double straight_angle = angle*180/M_PI;
double limit = 10;
double angle_to_vertical;
if (fabs(straight_angle) < 90)
angle_to_vertical = fabs(straight_angle);
else if (straight_angle > 0)
angle_to_vertical = 180-straight_angle;
else
angle_to_vertical = 180-(-straight_angle);
double angle_delta = 0;
if (angle_to_vertical > limit)
angle_delta = 30 * (angle_to_vertical - limit)/90;
double start_angle = straight_angle > 0
? straight_angle - angle_delta :
straight_angle + angle_delta;
QMatrix m1;
m1.translate(x1, y1);
m1.rotate(-start_angle);
double end_angle = straight_angle > 0
? (straight_angle + 180 + angle_delta) :
(straight_angle + 180 - angle_delta);
QMatrix m2;
m2.reset();
m2.translate(x2, y2);
m2.rotate(-end_angle);
arrow.cubicTo(m1.map(QPointF(straight_length/2, 0)),
m2.map(QPointF(straight_length/2, 0)),
m2.map(QPointF(arrowhead_length, 0)));
painter.save();
painter.setBrush(Qt::NoBrush);
painter.drawPath(arrow);
painter.restore();
painter.save();
painter.translate(x2, y2);
painter.rotate(-90);
painter.rotate(-end_angle);
painter.rotate(180);
QPolygon arrowhead(4);
arrowhead.setPoint(0, 0, 0);
arrowhead.setPoint(1, arrowhead_length/3, -arrowhead_length*5/4);
arrowhead.setPoint(2, 0, -arrowhead_length);
arrowhead.setPoint(3, -arrowhead_length/3, -arrowhead_length*5/4);
painter.drawPolygon(arrowhead);
painter.restore();
}
void Arrow_widget::paintEvent(QPaintEvent*)
{
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
int base_x = 550;
int base_y = 200;
if (color_ == 0)
p.setBrush(Qt::black);
else if (color_ == 1)
p.setBrush(Qt::green);
else if (color_ == 2)
p.setBrush(Qt::yellow);
else
p.setBrush(Qt::black);
for (int x_step = 0; x_step < 6; ++x_step)
{
for (int y_step = 1; y_step <= 3; ++y_step)
{
draw_arrow(base_x, base_y, base_x+x_step*100,
base_y - y_step*50, p);
draw_arrow(base_x, base_y, base_x+x_step*100,
base_y + y_step*50, p);
draw_arrow(base_x, base_y, base_x-x_step*100,
base_y + y_step*50, p);
draw_arrow(base_x, base_y, base_x-x_step*100,
base_y - y_step*50, p);
}
}
draw_arrow(50, 400, 1000, 450, p);
draw_arrow(1000, 400, 50, 450, p);
}

View File

@@ -0,0 +1,30 @@
// Copyright Vladimir Prus 2005.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt
// or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <QtGui/qapplication.h>
#include <QtGui/qwidget.h>
#include <QtGui/qpainter.h>
#include <QtGui/qpainterpath.h>
#include <stdlib.h>
#include <math.h>
class Arrow_widget : public QWidget
{
Q_OBJECT
public:
Arrow_widget(QWidget* parent = 0);
public slots:
void slotChangeColor();
private:
void draw_arrow(int x1, int y1, int x2, int y2, QPainter& painter);
void paintEvent(QPaintEvent*);
private:
int color_;
};

View File

@@ -0,0 +1,14 @@
import qt4 ;
if ! [ qt4.initialized ]
{
ECHO "Warning: Qt4 not initialized in user-config.jam" ;
ECHO "Assuming /space/p2/ghost/build/Qt4 as location." ;
ECHO "This is very likely won't work for you. " ;
using qt4 : /space/p2/ghost/build/Qt4 ;
}
project : requirements <threading>multi ;
exe arrow : main.cpp arrow.cpp arrow.h /qt//QtGui ;

View File

@@ -0,0 +1,27 @@
// Copyright Vladimir Prus 2005.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt
// or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
#include "arrow.h"
#include <QApplication>
#include <QTimer>
int main(int ac, char* av[])
{
QApplication app(ac, av);
Arrow_widget* w = new Arrow_widget;
w->resize(1100, 480);
QTimer timer;
QObject::connect(&timer, SIGNAL(timeout()),
w, SLOT(slotChangeColor()));
timer.start(2000);
w->show();
app.exec();
return 0;
}

View File

@@ -0,0 +1,18 @@
import qt4 ;
if ! [ qt4.initialized ]
{
ECHO "Warning: Qt4 not initialized in user-config.jam" ;
ECHO "Assuming /space/p2/ghost/build/Qt4 as location." ;
ECHO "This is very likely won't work for you. " ;
using qt4 : /space/p2/ghost/build/Qt4 ;
}
import cast ;
exe main : main.cpp
[ cast _ moccable-cpp : main.cpp ]
/qt//QtGui
: <threading>multi
;

View File

@@ -0,0 +1,39 @@
// Copyright Vladimir Prus 2005.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt
// or copy at https://www.bfgroup.xyz/b2/LICENSE.txt)
#include <qwidget.h>
#include <qpushbutton.h>
#include <qapplication.h>
#include <iostream>
class My_widget : public QWidget
{
Q_OBJECT
public:
My_widget() : QWidget()
{
QPushButton* b = new QPushButton("Push me", this);
connect(b, SIGNAL(clicked()), this, SLOT(theSlot()));
}
private slots:
void theSlot()
{
std::cout << "Clicked\n";
}
};
int main(int ac, char* av[])
{
QApplication app(ac, av);
My_widget mw;
mw.show();
app.exec();
}
#include "main.moc"

View File

@@ -0,0 +1,55 @@
<ui version="4.0" >
<author></author>
<comment>
<!--
Copyright Felix E. Klee, 2003
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt
or copy at http://www.boost.org/LICENSE_1_0.txt)
-->
</comment>
<exportmacro></exportmacro>
<class>HelloWorldWidget</class>
<widget class="QWidget" name="HelloWorldWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>124</width>
<height>63</height>
</rect>
</property>
<property name="windowTitle" >
<string>Hello World!</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>11</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="TextLabel2" >
<property name="text" >
<string>Hello World!</string>
</property>
<property name="alignment" >
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="OkButton" >
<property name="text" >
<string>OK</string>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
<connections/>
</ui>

Some files were not shown because too many files have changed in this diff Show More