Boost C++ Libraries Home Libraries People FAQ More

PrevUpHome

Differences to Boost.Build V1 與 Boost.Build V1 的差異

Configuration 配置
Writing Jamfiles 編寫 Jamfiles
Build process 構建過程

While Boost.Build V2 is based on the same ideas as Boost.Build V1, some of the syntax was changed, and some new important features were added. This chapter describes most of the changes.
雖然 Boost.Build V2 是基於與 Boost.Build V1 一樣的想法,但是改變了一些語法,並增加一些新的重要特性。本章將講述這些變化。

Configuration 配置

In V1, toolsets were configured by environment variables. If you wanted to use two versions of the same toolset, you had to create a new toolset module that would set the variables and then invoke the base toolset. In V2, toolsets are configured by the using, and you can easily configure several versions of a toolset. See the section called 「Configuration」 for details.
在 V1 中,工具集是通過環境變量來配置的。如果你想使用同一個工具集的兩個版本,你必須創建一個新的工具集模塊,它設置變量然後調用基本工具集。在 V2 中,工具集是通過 using 來配置的,你可以很容易地配置同一個工具集的多個版本。詳見 「配置」一節

Writing Jamfiles 編寫 Jamfiles

Probably one of the most important differences in V2 Jamfiles is the use of project requirements. In V1, if several targets had the same requirements (for example, a common #include path), it was necessary to manually write the requirements or use a helper rule or template target. In V2, the common properties can be specified with the requirements project attribute, as documented in the section called 「Projects」.
也許在 V2 的 Jamfiles 中一個最重要的差別就是,工程要求的使用。在 V1 中,如果多個目標具有相同的要求(例如,一個公用的 #include 路徑),那麼就需要手工編寫這個要求,或者使用一個輔助規則或模板目標。在 V2 中,公用的屬性可以用 requirements 工程屬性來指定,如 「工程」一節 中所說。

Usage requirements also help to simplify Jamfiles. If a library requires all clients to use specific #include paths or macros when compiling code that depends on the library, that information can be cleanly represented.
使用要求 也有助於簡化 Jamfiles。如果一個庫要求所有用戶在編譯依賴於該庫的代碼時,使用特定的 #include 路徑或者宏,那麼這些信息可以被清楚地表達出來。

The difference between lib and dll targets in V1 is completely eliminated in V2. There's only one library target type, lib, which can create either static or shared libraries depending on the value of the <link> feature. If your target should be only built in one way, you can add <link>shared or <link>static to its requirements.
在 V1 中的 lib 目標與 dll 目標之間的差異,在 V2 中已完成消除。只有一個庫目標類型 lib,可以根據 <link> 特性 的值創建靜態的或共享的庫。如果你的目標只按一種方式構建,那麼你可以將 <link>shared<link>static 增加到它的要求中。

The syntax for referring to other targets was changed a bit. While in V1 one would use:
引用其它目標的語法也有一點變化。在 V1 中你要用:

exe a : a.cpp <lib>../foo/bar ;

the V2 syntax is:
而 V2 的語法變為:

exe a : a.cpp ../foo//bar ;

Note that you don't need to specify the type of other target, but the last element should be separated from the others by a double slash to indicate that you're referring to target bar in project ../foo, and not to project ../foo/bar.
注意,你不需要指定另一個目標的類型,但是在另一個目標中以雙斜槓分隔的最後一個元素會被取出,用以表示你引用的是工程 ../foo 中的目標 bar,而不是工程 ../foo/bar

Build process 構建過程

The command line syntax in V2 is completely different. For example
在 V2 中的命令行語法是完全不一樣的。例如:

bjam -sTOOLS=msvc -sBUILD=release some_target

now becomes:
現在變成了:

bjam toolset=msvc variant=release some_target

or, using implicit features, just:
或者使用隱式特性,只需寫:

bjam msvc release some_target

See the reference for a complete description of the syntax.
對於語法的完整說明,請見 參考手冊


PrevUpHome