編譯順序和平行化

依預設,PDE/Build 編譯外掛程式的方式是透過特性結構委任。會依深度優先造訪特性,然後依相依關係順序(如 OSGi 解析器所決定)編譯每一個特性內的外掛程式。

這表示給定的軟體組的所有相依關係必須包含在相同的特性中,或在特性併入階層的深度優先遍訪時較早出現的特性中。這使得特性難以組織。

壓縮相依關係

3.5 版有一項新增特性是建置器內容 flattenDependencies。將此內容設定為 true 將使 PDE/Build 變成排序所有外掛程式,而不管是否跨越特性界限。然後,PDE/Build 會產生新的建置 Scriptcompile.<feature>.xml,並按照其相依關係排序,列出所有的外掛程式。這樣可讓您根據特性的功能將軟體組分割成不同特性,而不必擔心其之間的相依關係。

平行編譯

如果已指定 flattenDependencies,則 PDE/Build 可以平行編譯軟體組。它的作法是將已排序的軟體組清單分割成群組,讓每一個群組所包含的軟體組僅以較早群組中的軟體組為依據。

然後每一個群組會包裝在 Ant <parallel> 作業中。下列內容控制平行化行為:

parallelCompilation設為 true,以啟用平行編譯。(需要 flattenDependencies=true)
parallelThreadCount要使用的執行緒數目上限。預設值為 3。對應於 Ant 平行作業上的 threadCount。
parallelThreadsPerProcessor每個可用的處理器要使用的執行緒數目上限。對應於 Ant 平行作業上的 threadsPerProcessor。

結果產生如下的編譯 Script:

  <project name="Compile master" default="main">
     <target name="main">
        <parallel threadsPerProcessor='3'>
             <ant antfile="build.xml" dir="plugins/org.eclipse.osgi" target="build.jars"/>
        </parallel>
        <parallel threadsPerProcessor='3'>
             <ant antfile="build.xml" dir="plugins/org.eclipse.equinox.common" target="build.jars"/>
             <ant antfile="build.xml" dir="plugins/org.eclipse.equinox.p2.jarprocessor" target="build.jars"/>
        </parallel>
        <parallel threadsPerProcessor='3'>
             <ant antfile="build.xml" dir="plugins/org.eclipse.update.configurator" target="build.jars"/>
             <ant antfile="build.xml" dir="plugins/org.eclipse.equinox.simpleconfigurator" target="build.jars"/>
             <ant antfile="build.xml" dir="plugins/org.eclipse.equinox.frameworkadmin" target="build.jars"/>
             <ant antfile="build.xml" dir="plugins/org.eclipse.core.jobs" target="build.jars"/>
             <ant antfile="build.xml" dir="plugins/org.eclipse.core.databinding.observable" target="build.jars"/>
             <ant antfile="build.xml" dir="plugins/org.eclipse.swt" target="build.jars"/>
             ...