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

Merge branch 'develop' of https://github.com/boostorg/build into develop

This commit is contained in:
Rene Rivera
2020-04-08 07:53:46 -05:00
11 changed files with 111 additions and 39 deletions

View File

@@ -234,6 +234,7 @@ include::../../src/tools/features/find-lib-feature.jam[tag=doc]
include::../../src/tools/features/flags-feature.jam[tag=doc]
include::../../src/tools/features/dll-feature.jam[tag=hardcode-doc]
include::../../src/tools/features/dependency-feature.jam[tag=impl-doc]
include::../../src/tools/features/force-include-feature.jam[tag=doc]
include::../../src/tools/features/include-feature.jam[tag=doc]
include::../../src/tools/features/optimization-feature.jam[tag=inline-doc]
include::../../src/tools/features/instruction-set-feature.jam[tag=doc]

View File

@@ -588,8 +588,6 @@ source file needs to include some header, explicitly include it in the
source file, even if the same header is included from the precompiled
header. This makes sure that your project will build even if precompiled
headers are not supported.
* On the gcc compiler, the name of the header being precompiled must be
equal to the name of the `cpp-pch` target. This is a gcc requirement.
* Prior to version 4.2, the gcc compiler did not allow anonymous
namespaces in precompiled headers, which limits their utility. See the
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29085[bug report] for

View File

@@ -146,12 +146,12 @@ rule compile.c++ ( targets * : sources * : properties * ) {
}
actions compile.c++.without-pch {
"$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
"$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -o "$(<)" "$(>)"
}
actions compile.c++.with-pch bind PCH_FILE
{
"$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pch -Xclang "$(PCH_FILE)" -o "$(<)" "$(>)"
"$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pch -Xclang "$(PCH_FILE)" -include"$(FORCE_INCLUDES)" -o "$(<)" "$(>)"
}
rule compile.c ( targets * : sources * : properties * )
@@ -169,12 +169,12 @@ rule compile.c ( targets * : sources * : properties * )
actions compile.c.without-pch
{
"$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
"$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -c -o "$(<)" "$(>)"
}
actions compile.c.with-pch bind PCH_FILE
{
"$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pch -Xclang "$(PCH_FILE)" -c -o "$(<)" "$(>)"
"$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -include-pch -Xclang "$(PCH_FILE)" -include"$(FORCE_INCLUDES)" -c -o "$(<)" "$(>)"
}
###############################################################################
@@ -186,7 +186,7 @@ rule compile.c++.pch ( targets * : sources * : properties * ) {
}
actions compile.c++.pch {
$(RM) -f "$(<)" && "$(CONFIG_COMMAND)" -c -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pch -o "$(<)" "$(>)"
$(RM) -f "$(<)" && "$(CONFIG_COMMAND)" -c -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -Xclang -emit-pch -o "$(<)" "$(>)"
}
rule compile.c.pch ( targets * : sources * : properties * ) {
@@ -194,7 +194,7 @@ rule compile.c.pch ( targets * : sources * : properties * ) {
actions compile.c.pch
{
$(RM) -f "$(<)" && "$(CONFIG_COMMAND)" -c -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang -emit-pch -o "$(<)" "$(>)"
$(RM) -f "$(<)" && "$(CONFIG_COMMAND)" -c -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -Xclang -emit-pch -o "$(<)" "$(>)"
}
###############################################################################

View File

@@ -85,12 +85,12 @@ toolset.flags clang-vxworks.compile OPTIONS <flags> ;
actions compile.c
{
"$(CONFIG_COMMAND)" -x c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
"$(CONFIG_COMMAND)" -x c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -c -o "$(<)" "$(>)"
}
actions compile.c++
{
"$(CONFIG_COMMAND)" -x c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
"$(CONFIG_COMMAND)" -x c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -c -o "$(<)" "$(>)"
}

View File

@@ -137,13 +137,14 @@ rule init ( version ? : command * : options * : requirement * )
# - Set the toolset generic common options.
common.handle-options darwin : $(condition) : $(command) : $(options) ;
real-version = [ regex.split $(real-version) \\. ] ;
# - GCC 4.0 and higher in Darwin does not have -fcoalesce-templates.
if $(real-version) < "4.0.0"
if [ version.version-less $(real-version) : 4 0 ]
{
flags darwin.compile.c++ OPTIONS $(condition) : -fcoalesce-templates ;
}
# - GCC 4.2 and higher in Darwin does not have -Wno-long-double.
if $(real-version) < "4.2.0"
if [ version.version-less $(real-version) : 4 2 ]
{
flags darwin.compile OPTIONS $(condition) : -Wno-long-double ;
}

View File

@@ -394,8 +394,8 @@ rule init ( version ? : command * : options * )
if $(compiler) = bcc32x
{
lib_dir_release = $(root)/lib/win32c/release $(root)/lib/win32/release $(root)/lib/win32/release/psdk ;
lib_dir_debug = $(root)/lib/win32c/debug $(root)/lib/win32/debug $(root)/lib/win32/debug/psdk ;
lib_dir_release = $(root)/lib/win32c/release $(root)/lib/win32c/release/psdk ;
lib_dir_debug = $(root)/lib/win32c/debug ;
archiver = tlib ;
arflags = /P512 ;
implib = implib ;
@@ -403,13 +403,13 @@ rule init ( version ? : command * : options * )
else if $(compiler) = bcc64
{
lib_dir_release = $(root)/lib/win64/release $(root)/lib/win64/release/psdk ;
lib_dir_debug = $(root)/lib/win64/debug $(root)/lib/win64/debug/psdk ;
lib_dir_debug = $(root)/lib/win64/debug ;
archiver = tlib64 ;
arflags = /P2048 ;
implib = mkexp ;
}
flags embarcadero.compile OPTIONS $(condition) : $(system_include_option)$(system_include_directories) ;
flags embarcadero.compile .EMB_SYSINC $(condition) : $(system_include_option)$(system_include_directories) ;
flags embarcadero.link LINKPATH $(condition)/<variant>release : $(lib_dir_release) ;
flags embarcadero.link LINKPATH $(condition)/<variant>debug : $(lib_dir_debug) $(lib_dir_release) ;
flags embarcadero.archive .AR $(condition) : $(root)/bin/$(archiver) ;
@@ -558,12 +558,19 @@ flags embarcadero.compile OPTIONS <address-model>32 : -m32 ;
flags embarcadero.compile OPTIONS <address-model>64 : -m64 ;
flags embarcadero.link OPTIONS <address-model>32 : -m32 ;
flags embarcadero.link OPTIONS <address-model>64 : -m64 ;
flags embarcadero.link .EMBLRSP <variant>release : _emb_lpr ;
flags embarcadero.link .EMBLRSP <variant>debug : _emb_lpd ;
flags embarcadero.compile .EMBCRSP <variant>release : _emb_sir ;
flags embarcadero.compile .EMBCRSP <variant>debug : _emb_sid ;
nl = "
" ;
rule compile.c++ ( targets * : sources * : properties * ) {
}
actions compile.c++ {
"$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
"$(CONFIG_COMMAND)" -c -x c++ @"@($(<[1]:DBW)$(.EMBCRSP)$(<[1]:S).rsp:E=$(nl)"$(.EMB_SYSINC)")" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
}
rule compile.c ( targets * : sources * : properties * )
@@ -572,7 +579,7 @@ rule compile.c ( targets * : sources * : properties * )
actions compile.c
{
"$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
"$(CONFIG_COMMAND)" -c -x c @"@($(<[1]:DBW)$(.EMBCRSP)$(<[1]:S).rsp:E=$(nl)"$(.EMB_SYSINC)")" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
}
rule archive ( targets * : sources * : properties * )
@@ -593,11 +600,11 @@ rule link.dll ( targets * : sources * : properties * ) {
}
actions link bind LIBRARIES {
"$(CONFIG_COMMAND)" -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS) $(USER_OPTIONS)
"$(CONFIG_COMMAND)" @"@($(<[1]:DBW)$(.EMBLRSP)$(<[1]:S).rsp:E=$(nl)-L"$(LINKPATH)")" -o "$(<)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)")" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS) $(USER_OPTIONS)
}
actions link.dll bind LIBRARIES {
"$(CONFIG_COMMAND)" -L"$(LINKPATH)" -o "$(<[1])" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS) $(USER_OPTIONS) && "$(.IMPLIB_COMMAND)" "$(<[2])" "$(<[1])"
"$(CONFIG_COMMAND)" @"@($(<[1]:DBW)$(.EMBLRSP)$(<[1]:S).rsp:E=$(nl)-L"$(LINKPATH)")" -o "$(<[1])" @"@($(<[1]:W).rsp:E=$(nl)"$(>)")" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS) $(USER_OPTIONS) && "$(.IMPLIB_COMMAND)" "$(<[2])" "$(<[1])"
}
rule asm ( targets * : sources * : properties * )

View File

@@ -0,0 +1,21 @@
# Copyright 2020 Nikita Kniazev
# 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)
import feature ;
#| tag::doc[]
[[bbv2.builtin.features.force-include]]`force-include`::
Specifies an include path that has to be included in a way like if
`#include "file"` appeared as the first line of every target's source file.
The include order is not guaranteed if used multiple times on a single target.
|# # end::doc[]
feature.feature "force-include"
:
: free
;

View File

@@ -574,22 +574,22 @@ rule compile.fortran ( targets * : sources * : properties * )
actions compile.c++ bind PCH_FILE
{
"$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<:W)" "$(>:W)"
"$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -c -o "$(<:W)" "$(>:W)"
}
actions compile.c bind PCH_FILE
{
"$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
"$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" -c -o "$(<)" "$(>)"
}
actions compile.c++.preprocess bind PCH_FILE
{
"$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" "$(>:W)" -E >"$(<:W)"
"$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" "$(>:W)" -E >"$(<:W)"
}
actions compile.c.preprocess bind PCH_FILE
{
"$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" "$(>)" -E >$(<)
"$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -include"$(FORCE_INCLUDES)" "$(>)" -E >$(<)
}
actions compile.fortran
@@ -638,17 +638,11 @@ class gcc-pch-generator : pch-generator
}
}
# Error handling: base header file name should be the same as the base
# precompiled header name.
local header-name = [ $(header).name ] ;
local header-basename = $(header-name:B) ;
if $(header-basename) != $(name)
{
local location = [ $(project).project-module ] ;
import errors : user-error : errors.user-error ;
errors.user-error "in" "$(location):" pch target name '$(name)' should
be the same as the base name of header file '$(header-name)' ;
}
local path-prefix = [ path.join $(name)
[ feature.get-values location-prefix
: $(property-set).raw ] ] ;
property-set = [ $(property-set).add-raw
<location-prefix>$(path-prefix) ] ;
local pch-file = [ generator.run $(project) $(name) : $(property-set)
: $(header) ] ;
@@ -770,6 +764,7 @@ toolset.flags gcc.compile.c++ USER_OPTIONS <cxxflags> ;
toolset.flags gcc.compile.asm USER_OPTIONS <asmflags> ;
toolset.flags gcc.compile DEFINES <define> ;
toolset.flags gcc.compile INCLUDES <include> ;
toolset.flags gcc.compile FORCE_INCLUDES <force-include> ;
toolset.flags gcc.compile.c++ TEMPLATE_DEPTH <c++-template-depth> ;
toolset.flags gcc.compile.fortran USER_OPTIONS <fflags> ;

View File

@@ -1690,7 +1690,7 @@ rule get-rspline ( target : lang-opt )
{
CC_RSPLINE on $(target) = [ on $(target) return $(lang-opt) -U$(UNDEFS)
$(CFLAGS) $(C++FLAGS) $(OPTIONS) -c $(.nl)-D$(DEFINES)
$(.nl)\"-I$(INCLUDES:W)\" ] ;
$(.nl)\"-I$(INCLUDES:W)\" $(.nl)\"-FI$(FORCE_INCLUDES:W)\" ] ;
}
class msvc-linking-generator : linking-generator
@@ -1873,6 +1873,7 @@ local rule register-toolset-really ( )
toolset.flags msvc.compile DEFINES <define> ;
toolset.flags msvc.compile UNDEFS <undef> ;
toolset.flags msvc.compile INCLUDES <include> ;
toolset.flags msvc.compile FORCE_INCLUDES <force-include> ;
# Declare flags for the assembler.
toolset.flags msvc.compile.asm USER_ASMFLAGS <asmflags> ;

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env python
# Copyright 2020 Nikita Kniazev
# 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)
# Tests the force-include feature
import BoostBuild
t = BoostBuild.Tester(use_test_config=False)
t.write("Jamroot.jam", """
obj test-cpp : test.cpp : <force-include>one.h <force-include>two.h ;
obj test-c : test.c : <force-include>one.h <force-include>two.h ;
""")
for name in ("test.cpp", "test.c"):
t.write(name, """
#ifndef ONE
#error Cannot compile without ONE
#endif
#ifndef TWO
#error Cannot compile without TWO
#endif
""")
t.write("one.h", """
#define ONE
""")
t.write("two.h", """
#define TWO
""")
t.run_build_system()
t.expect_addition("bin/$toolset/debug*/test-cpp.obj")
t.expect_addition("bin/$toolset/debug*/test-c.obj")
t.cleanup()

View File

@@ -13,8 +13,11 @@ t = BoostBuild.Tester()
t.write("jamroot.jam", """
import pch ;
project : requirements <warnings-as-errors>on ;
cpp-pch pch : pch.hpp : <toolset>msvc:<source>pch.cpp <include>. ;
cpp-pch pch-afx : pch.hpp : <define>HELLO <toolset>msvc:<source>pch.cpp <include>. ;
exe hello : hello.cpp pch : <include>. ;
exe hello-afx : hello-afx.cpp pch-afx : <define>HELLO <include>. ;
""")
t.write("pch.hpp.bad", """
@@ -25,6 +28,7 @@ THIS WILL NOT COMPILE
# less than timestamp of pch.hpp.bad.
sleep(1)
t.write("pch.hpp", """
#undef HELLO
class TestClass
{
public:
@@ -35,12 +39,14 @@ public:
t.write("pch.cpp", """#include <pch.hpp>
""")
t.write("hello.cpp", """#include <pch.hpp>
for name in ("hello.cpp", "hello-afx.cpp"):
t.write(name, """#include <pch.hpp>
int main() { TestClass c(1, 2); }
""")
t.run_build_system()
t.expect_addition("bin/$toolset/debug*/hello.exe")
t.expect_addition("bin/$toolset/debug*/hello-afx.exe")
# Now make the header unusable, without changing timestamp. If everything is OK,
@@ -49,10 +55,11 @@ t.expect_addition("bin/$toolset/debug*/hello.exe")
t.copy_preserving_timestamp("pch.hpp.bad", "pch.hpp")
t.rm("bin/$toolset/debug/hello.obj")
t.rm("bin/$toolset/debug/*/hello.obj")
t.rm("bin/$toolset/debug*/hello.obj")
t.rm("bin/$toolset/debug*/hello-afx.obj")
t.run_build_system()
t.expect_addition("bin/$toolset/debug*/hello.obj")
t.expect_addition("bin/$toolset/debug*/hello-afx.obj")
t.cleanup()