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

Merge from trunk

[SVN r33628]
This commit is contained in:
Vladimir Prus
2006-04-10 09:44:30 +00:00
parent 69be3c04ae
commit 1f0d1d0584
14 changed files with 348 additions and 40 deletions

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,158 @@
// Copyright Vladimir Prus 2005.
// 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)
#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_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.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,27 @@
// Copyright Vladimir Prus 2005.
// 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)
#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

@@ -1,12 +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 ]
/qt4//QtGui ;
/qt//QtGui
: <threading>multi
;
#cast _ moccable-cpp : main.cpp ;

View File

@@ -3,7 +3,16 @@
# (See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
project
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 hello : main.cpp hello_world_widget.ui : <library>/qt4//QtGui ;
exe hello : main.cpp hello_world_widget.ui : <library>/qt//QtGui ;

View File

@@ -13,3 +13,4 @@ cd boost-build/build/v2
./roll.sh > ../roll-log
cd ..
scp boost-build.zip boost-build.tar.bz2 vladimir_prus@shell.sf.net:/home/groups/b/bo/boost/htdocs/boost-build2 > scp-log
echo "Upload successfull"

View File

@@ -584,7 +584,7 @@ class main-target : abstract-target
# Returns the best viable alternative for this property-set
# See the documentation for selection rules.
local rule select-alternatives ( property-set )
local rule select-alternatives ( property-set debug ? )
{
# When selecting alternatives we have to consider defaults,
# for example:
@@ -607,7 +607,7 @@ class main-target : abstract-target
while $(worklist) && ! $(bad)
{
local v = $(worklist[1]) ;
local properties = [ $(v).match $(property-set) ] ;
local properties = [ $(v).match $(property-set) $(debug) ] ;
if $(properties) != no-match
{
@@ -752,11 +752,8 @@ class main-target : abstract-target
local best-alternatives = [ select-alternatives $(property-set) ] ;
if ! $(best-alternatives)
{
errors.error
"failed to build" [ full-name ]
"with properties" [ $(property-set).raw ]
"because no best-matching alternative could be found"
;
ECHO "error: No best alternative for" [ full-name ] ;
select-alternatives $(property-set) debug ;
return [ property-set.empty ] ;
}
else
@@ -931,7 +928,8 @@ rule common-properties2 ( build-request requirements )
# Apply non-conditional requirements.
# There's a slight bug here: it's possible that conditional
# requirement change a value set by non-conditional requirements. This
# should be error, but we don't detect it yet.
# should be error, but we don't detect it yet.
local raw = [ $(build-request).raw ] ;
raw = [ property.refine $(raw) :
[ feature.expand [ $(requirements).non-conditional ] ] ] ;
@@ -1071,7 +1069,7 @@ class basic-target : abstract-target
# Returns the alternative condition for this alternative, if
# the condition is satisfied by 'property-set'.
rule match ( property-set )
rule match ( property-set debug ? )
{
# The condition is composed of all base non-conditional properties.
# It's not clear if we should expand 'self.requirements' or not.
@@ -1084,12 +1082,25 @@ class basic-target : abstract-target
local bcondition = [ $(self.requirements).base ] ;
local ccondition = [ $(self.requirements).conditional ] ;
local condition = [ set.difference $(bcondition) : $(ccondition) ] ;
if $(debug)
{
ECHO " next alternative: required properties:" $(condition:E=(empty)) ;
}
if $(condition) in [ $(property-set).raw ]
{
return $(condition) ;
if $(debug)
{
ECHO " matched" ;
}
return $(condition) ;
}
else
{
if $(debug)
{
ECHO " not matched" ;
}
return no-match ;
}
}

View File

@@ -249,7 +249,7 @@ rule get-invocation-command (
if $(.debug-configuration)
{
ECHO "warning: toolset $(toolset) initialization: " ;
ECHO "warning: can't find user-provided command '$(user-provided-command:J= )'" ;
ECHO "warning: can't find user-provided command " '$(user-provided-command)' ;
ECHO "warning: initialized from" [ errors.nearest-user-location ] ;
}
# It's possible, in theory, that user-provided command is OK, but we're

View File

@@ -41,9 +41,10 @@ rule install ( name : requirements * : binaries * : libraries * : headers * )
{
local install-source-root = [ property.select <install-source-root>
: $(requirements) ] ;
install-source-root ?= "." ;
# If <install-source-root> is not specified, all headers are installed
# to prefix/include, no matter what their relative path is. Sometimes
# that's what needed.
requirements = [ property.change $(requirements) : <install-source-root> ] ;
@@ -70,7 +71,11 @@ rule install ( name : requirements * : binaries * : libraries * : headers * )
stage.install $(name)-bin : $(binaries) : $(requirements) <location>$(bin-locate) ;
stage.install $(name)-lib : $(libraries) : $(requirements) <location>$(lib-locate) ;
stage.install $(name)-lib :
$(binaries) $(libraries)
: $(requirements) <location>$(lib-locate)
<install-dependencies>on <install-type>LIB
;
stage.install $(name)-headers : $(headers) : $(requirements)
<location>$(include-locate) <install-source-root>$(install-source-root) ;
alias $(name) : $(name)-bin $(name)-lib $(name)-headers ;

View File

@@ -51,19 +51,19 @@ rule init ( prefix ? )
.initialized = true ;
.prefix = $(prefix) ;
generators.register-standard qt3.moc : H : CPP(moc_%) : <allow>qt ;
generators.register-standard qt3.moc : H : CPP(moc_%) : <allow>qt3 ;
# Note: the OBJ target type here is fake, take a look
# at qt4.jam/uic-h-generator for explanations that
# apply in this case as well.
generators.register [ new moc-h-generator
qt3.moc.cpp : MOCCABLE_CPP : OBJ : <allow>qt ] ;
generators.register [ new moc-h-generator-qt3
qt3.moc.cpp : MOCCABLE_CPP : OBJ : <allow>qt3 ] ;
# The UI type is defined in types/qt.jam,
# and UIC_H is only used in qt.jam, but not in qt4.jam, so
# define it here.
type.register UIC_H : : H ;
generators.register-standard qt3.uic-h : UI : UIC_H : <allow>qt ;
generators.register-standard qt3.uic-h : UI : UIC_H : <allow>qt3 ;
# The following generator is used to convert UI files to CPP
# It creates UIC_H from UI, and constructs CPP from UI/UIC_H
@@ -73,7 +73,7 @@ rule init ( prefix ? )
{
rule __init__ ( )
{
generator.__init__ qt3.uic-cpp : UI UIC_H : CPP : <allow>qt ;
generator.__init__ qt3.uic-cpp : UI UIC_H : CPP : <allow>qt3 ;
}
rule run ( project name ? : properties * : sources + )
@@ -118,14 +118,14 @@ rule init ( prefix ? )
<include>$(.prefix)/include
<dll-path>$(.prefix)/lib
<library-path>$(.prefix)/lib
<allow>qt
<allow>qt3
;
lib qt : : <name>qt-mt <threading>multi : : $(usage-requirements) ;
lib qt : : <name>qt <threading>single : : $(usage-requirements) ;
}
}
class moc-h-generator : generator
class moc-h-generator-qt3 : generator
{
rule __init__ ( * : * )
{

View File

@@ -1,5 +1,7 @@
# Copyright 2002 Vladimir Prus
# Copyright 2002-2006 Vladimir Prus
# Copyright 2005 Alo Sarv
# Copyright 2005-2006 Juergen Hunold
#
# 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)
@@ -48,10 +50,16 @@ import virtual-target ;
project.initialize $(__name__) ;
project qt ;
# Save the project so that we tolerate 'import + using' combo.
.project = [ project.current ] ;
# Initialized the QT support module. The 'prefix' parameter
# tells where QT is installed.
rule init ( prefix )
{
project.push-current $(.project) ;
if $(.initialized)
{
if $(prefix) != $(.prefix)
@@ -66,19 +74,20 @@ rule init ( prefix )
.prefix = $(prefix) ;
# Generates cpp files from header files using "moc" tool
generators.register-standard qt4.moc : H : CPP(moc_%) ;
generators.register-standard qt4.moc : H : CPP(moc_%) : <allow>qt4 ;
# The OBJ result type is a fake, 'H' will be really produces.
# See comments on the generator calss, defined below
# the 'init' function.
generators.register [ new uic-h-generator qt4.uic-h : UI : OBJ ] ;
generators.register [ new uic-h-generator qt4.uic-h : UI : OBJ
: <allow>qt4 ] ;
# The OBJ result type is a fake here too.
generators.register [ new moc-h-generator
qt4.moc.inc : MOCCABLE_CPP : OBJ ] ;
qt4.moc.inc : MOCCABLE_CPP : OBJ : <allow>qt4 ] ;
generators.register [ new moc-inc-generator
qt4.moc.inc : MOCCABLE_H : OBJ ] ;
qt4.moc.inc : MOCCABLE_H : OBJ : <allow>qt4 ] ;
# Generates .cpp file from qrc file
generators.register-standard qt4.rcc : QRC : CPP(qrc_%) ;
@@ -90,7 +99,12 @@ rule init ( prefix )
local all-libraries = QtCore QtGui QtNetwork QtXml QtSql QtSvg Qt3Support QtTest QtAssistantClient QtUiTools ;
for local l in $(all-libraries)
{
alias $(l) : $(.prefix)//$(l) ;
alias $(l)
: $(.prefix)//$(l)
:
:
: <allow>qt4
;
explicit $(l) ;
}
}
@@ -101,7 +115,9 @@ rule init ( prefix )
<include>$(.prefix)/include
<library-path>$(.prefix)/lib
<dll-path>$(.prefix)/lib
<threading>multi ;
<threading>multi
<allow>qt4
;
local suffix ;
if [ os.name ] = NT
@@ -294,8 +310,17 @@ rule init ( prefix )
;
}
}
project.pop-current ;
}
rule initialized ( )
{
return $(.initialized) ;
}
# This custom generator is needed because it QT4, UI files are translated
# only in H files, and no C++ files are created. Further, the H files
# need not be passed via MOC. The header is used only via inclusion.

View File

@@ -86,7 +86,7 @@ exe a : a_empty.cpp ;
exe a : a.cpp ;
""")
t.run_build_system("--no-error-backtrace", status=1)
t.fail_test(find(t.stdout(), "because no best-matching alternative could be found") == -1)
t.fail_test(find(t.stdout(), "No best alternative") == -1)
# Another ambiguity test: two matches properties in one alternative are
# neither better nor worse than a single one in another alternative.
@@ -96,7 +96,7 @@ exe a : a.cpp : <debug-symbols>on ;
""")
t.run_build_system("--no-error-backtrace", status=1)
t.fail_test(find(t.stdout(), "because no best-matching alternative could be found") == -1)
t.fail_test(find(t.stdout(), "No best alternative") == -1)

View File

@@ -41,7 +41,7 @@ local here = [ project.attribute $(__name__) location ] ;
here = [ path.root $(here) [ path.pwd ] ] ;
exe main : main.cpp helper ;
lib helper : helper.cpp test_lib : <dll-path>$(here)/lib ;
lib helper : helper.cpp test_lib ;
lib test_lib : : <name>test_lib <search>lib ;
""")
t.write("main.cpp", """
@@ -57,10 +57,32 @@ __declspec(dllexport)
#endif
helper() { foo(); }
""")
t.run_build_system(stderr=None) # gcc warns about libraries which are not in -rpath.
t.run_build_system()
t.expect_addition("bin/$toolset/debug/main.exe")
t.rm("bin/$toolset/debug/main.exe")
# Test the 'unit-test' will correctly add runtime paths
# to searched libraries.
t.write('Jamfile', """
import path ;
import project ;
import testing ;
project : requirements <hardcode-dll-paths>false ;
local here = [ project.attribute $(__name__) location ] ;
here = [ path.root $(here) [ path.pwd ] ] ;
unit-test main : main.cpp helper ;
lib helper : helper.cpp test_lib ;
lib test_lib : : <name>test_lib <search>lib ;
""")
t.run_build_system()
t.expect_addition("bin/$toolset/debug/main.passed")
t.rm("bin/$toolset/debug/main.exe")
# Now try using searched lib from static lib. Request shared version
# of searched lib, since we don't have static one handy.
t.write('Jamfile', """