You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2019/07/11 15:11:53 UTC

[plc4x] 06/06: - Moved the build of Boost into a separate module located under tools (It's no longer in plc4cpp), which is built when enabling the "with-boost" profile. - We are now packing up the libs and includes into an zip assembly which is unpacked if needed (in case of plc4cpp it is needed) - Added a check to the prerequisiteCheck.groovy to check if boost is locally available only if the "with-cpp" profile is enabled and the "with-boost" profile is NOT enabled too.

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch feature/s7-cpp
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 2b9ff5cda0e00815f40e493747c76cdc7a2fc231
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Jul 11 17:11:35 2019 +0200

    - Moved the build of Boost into a separate module located under tools (It's no longer in plc4cpp), which is built when enabling the "with-boost" profile.
    - We are now packing up the libs and includes into an zip assembly which is unpacked if needed (in case of plc4cpp it is needed)
    - Added a check to the prerequisiteCheck.groovy to check if boost is locally available only if the "with-cpp" profile is enabled and the "with-boost" profile is NOT enabled too.
---
 Jenkinsfile                                      |  10 +-
 plc4cpp/pom.xml                                  |  85 +++++---------
 src/main/script/prerequisiteCheck.groovy         |  32 ++++-
 tools/boost/pom.xml                              | 142 +++++++++++++++++++++++
 tools/{pom.xml => boost/src/assembly/bundle.xml} |  48 ++++----
 tools/pom.xml                                    |   6 +
 6 files changed, 233 insertions(+), 90 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 5a3ce86..2b99cfa 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -83,7 +83,7 @@ pipeline {
             }
             steps {
                 echo 'Building'
-                sh 'mvn -P${JENKINS_PROFILE},development,with-cpp,with-java,with-dotnet,with-python,with-proxies,with-sandbox ${MVN_TEST_FAIL_IGNORE} ${MVN_LOCAL_REPO_OPT} clean install'
+                sh 'mvn -P${JENKINS_PROFILE},development,with-boost,with-cpp,with-java,with-dotnet,with-python,with-proxies,with-sandbox ${MVN_TEST_FAIL_IGNORE} ${MVN_LOCAL_REPO_OPT} clean install'
             }
             post {
                 always {
@@ -106,7 +106,7 @@ pipeline {
 
                 // We'll deploy to a relative directory so we can save
                 // that and deploy in a later step on a different node
-                sh 'mvn -U -P${JENKINS_PROFILE},development,with-java,with-dotnet,with-cpp,with-python,with-proxies,with-sandbox ${MVN_TEST_FAIL_IGNORE} ${JQASSISTANT_NEO4J_VERSION} -DaltDeploymentRepository=snapshot-repo::default::file:./local-snapshots-dir clean deploy'
+                sh 'mvn -U -P${JENKINS_PROFILE},development,with-boost,with-java,with-dotnet,with-cpp,with-python,with-proxies,with-sandbox ${MVN_TEST_FAIL_IGNORE} ${JQASSISTANT_NEO4J_VERSION} -DaltDeploymentRepository=snapshot-repo::default::file:./local-snapshots-dir clean deploy'
 
                 // Stash the build results so we can deploy them on another node
                 stash name: 'plc4x-build-snapshots', includes: 'local-snapshots-dir/**'
@@ -126,7 +126,7 @@ pipeline {
             steps {
                 echo 'Checking Code Quality'
                 withSonarQubeEnv('ASF Sonar Analysis') {
-                    sh 'mvn -P${JENKINS_PROFILE},with-java,with-dotnet,with-python,with-proxies sonar:sonar'
+                    sh 'mvn -P${JENKINS_PROFILE},with-boost,with-java,with-dotnet,with-python,with-proxies sonar:sonar'
                 }
             }
         }
@@ -167,7 +167,7 @@ pipeline {
             }
             steps {
                 echo 'Building Site'
-                sh 'mvn -P${JENKINS_PROFILE},with-java,with-dotnet,with-python,with-proxies site'
+                sh 'mvn -P${JENKINS_PROFILE},with-boost,with-java,with-dotnet,with-python,with-proxies site'
             }
         }
 
@@ -178,7 +178,7 @@ pipeline {
             steps {
                 echo 'Staging Site'
                 // Build a directory containing the aggregated website.
-                sh 'mvn -P${JENKINS_PROFILE},with-java,with-dotnet,with-python,with-proxies site:stage'
+                sh 'mvn -P${JENKINS_PROFILE},with-boost,with-java,with-dotnet,with-python,with-proxies site:stage'
                 // Make sure the script is executable.
                 sh 'chmod +x tools/clean-site.sh'
                 // Remove some redundant resources, which shouldn't be required.
diff --git a/plc4cpp/pom.xml b/plc4cpp/pom.xml
index 09b1330..76c5b82 100644
--- a/plc4cpp/pom.xml
+++ b/plc4cpp/pom.xml
@@ -124,7 +124,7 @@
 
   <build>
     <plugins>
-      <!-- First download the cmake binaries and sources for building the boost library -->
+      <!-- First download the cmake binaries -->
       <plugin>
         <groupId>com.googlecode.maven-download-plugin</groupId>
         <artifactId>download-maven-plugin</artifactId>
@@ -142,71 +142,31 @@
               <outputDirectory>${project.build.directory}</outputDirectory>
             </configuration>
           </execution>
-          <execution>
-            <id>get-boost</id>
-            <phase>generate-sources</phase>
-            <goals>
-              <goal>wget</goal>
-            </goals>
-            <configuration>
-              <url>${boost.url}</url>
-              <unpack>true</unpack>
-              <outputDirectory>${project.build.directory}</outputDirectory>
-            </configuration>
-          </execution>
         </executions>
       </plugin>
 
-      <!--
-        Then execute two boost build phases:
-
-        1) bootstrap the boost build
-        2) Perform the actual boost build and install
-      -->
+      <!-- Get the pre-packaged boost library -->
       <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>exec-maven-plugin</artifactId>
-        <version>1.6.0</version>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
         <executions>
           <execution>
-            <id>bootstrap-boost</id>
-            <phase>process-sources</phase>
-            <goals>
-              <goal>exec</goal>
-            </goals>
-            <configuration>
-              <executable>${boost.bootstrap.executable}</executable>
-              <arguments>
-                <argument>gcc</argument>
-              </arguments>
-              <workingDirectory>${project.build.directory}/boost_${boost.version.underline}</workingDirectory>
-            </configuration>
-          </execution>
-          <execution>
-            <id>compile-boost</id>
-            <phase>process-sources</phase>
+            <id>get-boost</id>
+            <phase>generate-sources</phase>
             <goals>
-              <goal>exec</goal>
+              <goal>unpack</goal>
             </goals>
             <configuration>
-              <executable>${boost.build.executable}</executable>
-              <arguments>
-                <!-- Have the build install the built libraries -->
-                <argument>install</argument>
-                <!-- Tell it where to install the libraries and header files -->
-                <argument>--prefix=${project.build.directory}/lib/boost</argument>
-                <!-- List of modules to build -->
-                <argument>--with-system</argument>
-                <argument>--with-thread</argument>
-                <argument>--with-date_time</argument>
-                <argument>--with-regex</argument>
-                <argument>--with-log</argument>
-                <!-- On Windows machines the build failed, if this was not explicitly set -->
-                <argument>address-model=64</argument>
-                <!-- On Linux machines the build failed, if this is not set -->
-                <argument>cxxflags=-fPIC</argument>
-              </arguments>
-              <workingDirectory>${project.build.directory}/boost_${boost.version.underline}</workingDirectory>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.apache.plc4x</groupId>
+                  <artifactId>plc4x-tools-boost</artifactId>
+                  <version>0.5.0-SNAPSHOT</version>
+                  <type>zip</type>
+                  <classifier>lib-${os.classifier}</classifier>
+                  <outputDirectory>${project.build.directory}/lib/boost</outputDirectory>
+                </artifactItem>
+              </artifactItems>
             </configuration>
           </execution>
         </executions>
@@ -279,4 +239,15 @@
     </plugins>
   </build>
 
+  <!-- This dependency is just to ensure boost is built first -->
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4x-tools-boost</artifactId>
+      <version>0.5.0-SNAPSHOT</version>
+      <type>pom</type>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
 </project>
\ No newline at end of file
diff --git a/src/main/script/prerequisiteCheck.groovy b/src/main/script/prerequisiteCheck.groovy
index d24e4d5..4d278c3 100644
--- a/src/main/script/prerequisiteCheck.groovy
+++ b/src/main/script/prerequisiteCheck.groovy
@@ -169,6 +169,26 @@ def checkPython() {
     }
 }
 
+/*
+ * This check does an extremely simple check, if the boost library exists in the maven local repo.
+ * We're not checking if it could be resolved.
+ */
+def checkBoost() {
+    print "Detecting Boost library:  "
+    def localRepoBaseDir = session.getLocalRepository().getBasedir()
+    def expectedFile = new File(localRepoBaseDir, "org/apache/plc4x/plc4x-tools-boost/" + project.version +
+        "/plc4x-tools-boost-" + project.version + "-lib-" + project.properties["os.classifier"] + ".zip")
+    if(!expectedFile.exists()) {
+        println "              missing"
+        println ""
+        println "Missing the Boost library. This has to be built by activating the Maven profile 'with-boost'. This only has to be built once."
+        println ""
+        allConditionsMet = false
+    } else {
+        println "              OK"
+    }
+}
+
 /**
  * Version extraction function/macro. It looks for occurance of x.y or x.y.z
  * in passed input text (likely output from `program --version` command if found).
@@ -200,6 +220,7 @@ println "Detected Arch: " + arch
 /////////////////////////////////////////////////////
 
 println "Enabled profiles:"
+def boostEnabled = false
 def cppEnabled = false
 def dotnetEnabled = false
 def javaEnabled = false
@@ -208,7 +229,10 @@ def proxiesEnabled = false
 def sandboxEnabled = false
 def activeProfiles = session.request.activeProfiles
 for (def activeProfile : activeProfiles) {
-    if(activeProfile == "with-cpp") {
+    if(activeProfile == "with-boost") {
+        boostEnabled = true
+        println "boost"
+    } else if(activeProfile == "with-cpp") {
         cppEnabled = true
         println "cpp"
     } else if(activeProfile == "with-dotnet") {
@@ -276,11 +300,15 @@ if(proxiesEnabled || cppEnabled) {
     checkGpp()
 }
 
-// TODO: Doesn't work yet
 if(pythonEnabled) {
     checkPython()
 }
 
+// We only need this check, if boost is not enabled but we're enabling cpp.
+if(!boostEnabled && cppEnabled) {
+    checkBoost()
+}
+
 if(!allConditionsMet) {
     throw new RuntimeException("Not all conditions met, see log for details.")
 }
diff --git a/tools/boost/pom.xml b/tools/boost/pom.xml
new file mode 100644
index 0000000..6172f1d
--- /dev/null
+++ b/tools/boost/pom.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.plc4x</groupId>
+    <artifactId>plc4x-tools</artifactId>
+    <version>0.5.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>plc4x-tools-boost</artifactId>
+  <packaging>pom</packaging>
+
+  <name>Tools: Boost</name>
+  <description>Building of the Boost library.</description>
+
+  <!-- Disabled for now as C++ support is currently not installed in Apache SonarQube -->
+  <!--properties>
+    <sonar.language>c++</sonar.language>
+  </properties-->
+
+  <build>
+    <plugins>
+      <!-- First download the cmake binaries and sources for building the boost library -->
+      <plugin>
+        <groupId>com.googlecode.maven-download-plugin</groupId>
+        <artifactId>download-maven-plugin</artifactId>
+        <version>1.4.0</version>
+        <executions>
+          <execution>
+            <id>get-boost</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>wget</goal>
+            </goals>
+            <configuration>
+              <url>${boost.url}</url>
+              <unpack>true</unpack>
+              <outputDirectory>${project.build.directory}</outputDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <!--
+        Then execute two boost build phases:
+
+        1) bootstrap the boost build
+        2) Perform the actual boost build and install
+      -->
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>1.6.0</version>
+        <executions>
+          <execution>
+            <id>bootstrap-boost</id>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>exec</goal>
+            </goals>
+            <configuration>
+              <executable>${boost.bootstrap.executable}</executable>
+              <arguments>
+                <argument>gcc</argument>
+              </arguments>
+              <workingDirectory>${project.build.directory}/boost_${boost.version.underline}</workingDirectory>
+            </configuration>
+          </execution>
+          <execution>
+            <id>compile-boost</id>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>exec</goal>
+            </goals>
+            <configuration>
+              <executable>${boost.build.executable}</executable>
+              <arguments>
+                <!-- Have the build install the built libraries -->
+                <argument>install</argument>
+                <!-- Tell it where to install the libraries and header files -->
+                <argument>--prefix=${project.build.directory}/lib/boost</argument>
+                <!-- List of modules to build -->
+                <argument>--with-system</argument>
+                <argument>--with-thread</argument>
+                <argument>--with-date_time</argument>
+                <argument>--with-regex</argument>
+                <argument>--with-log</argument>
+                <!-- On Windows machines the build failed, if this was not explicitly set -->
+                <argument>address-model=64</argument>
+                <!-- On Linux machines the build failed, if this is not set -->
+                <argument>cxxflags=-fPIC</argument>
+              </arguments>
+              <workingDirectory>${project.build.directory}/boost_${boost.version.underline}</workingDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <!-- Build a zip artifact containing the boost library -->
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>3.1.1</version>
+        <executions>
+          <execution>
+            <id>package-boost-library</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <configuration>
+              <finalName>${project.artifactId}-${project.version}</finalName>
+              <descriptors>
+                <descriptor>src/assembly/bundle.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file
diff --git a/tools/pom.xml b/tools/boost/src/assembly/bundle.xml
similarity index 54%
copy from tools/pom.xml
copy to tools/boost/src/assembly/bundle.xml
index ede7394..a4b4b7e 100644
--- a/tools/pom.xml
+++ b/tools/boost/src/assembly/bundle.xml
@@ -1,4 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
 <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
@@ -17,28 +16,25 @@
   specific language governing permissions and limitations
   under the License.
   -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.apache.plc4x</groupId>
-    <artifactId>plc4x-parent</artifactId>
-    <version>0.5.0-SNAPSHOT</version>
-  </parent>
-
-  <artifactId>plc4x-tools</artifactId>
-  <packaging>pom</packaging>
-
-  <name>Tools</name>
-
-  <profiles>
-    <profile>
-      <id>with-proxies</id>
-      <modules>
-        <module>thrift</module>
-      </modules>
-    </profile>
-  </profiles>
-
-</project>
\ No newline at end of file
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+
+  <id>lib-${os.classifier}</id>
+
+  <formats>
+    <format>zip</format>
+  </formats>
+
+  <includeBaseDirectory>false</includeBaseDirectory>
+
+  <fileSets>
+    <fileSet>
+      <directory>${project.build.directory}/lib/boost</directory>
+      <includes>
+        <include>**</include>
+      </includes>
+      <outputDirectory/>
+    </fileSet>
+  </fileSets>
+</assembly>
\ No newline at end of file
diff --git a/tools/pom.xml b/tools/pom.xml
index ede7394..cc06d26 100644
--- a/tools/pom.xml
+++ b/tools/pom.xml
@@ -34,6 +34,12 @@
 
   <profiles>
     <profile>
+      <id>with-boost</id>
+      <modules>
+        <module>boost</module>
+      </modules>
+    </profile>
+    <profile>
       <id>with-proxies</id>
       <modules>
         <module>thrift</module>