├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── build.gradle ├── docs ├── developersDoc.md ├── modules │ └── cmake-modules.md └── release-process.md ├── exemples ├── hello-world-multi-modules │ ├── .CMakeLists.txt.kate-swp │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── build.gradle │ ├── cmake_modules │ │ ├── FindCPPUNIT.cmake │ │ ├── gradle-cpp-cppUnitTest.cmake │ │ └── gradle-cpp.cmake │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── hello-library │ │ ├── CMakeLists.txt │ │ ├── build.gradle │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── src │ │ │ ├── main │ │ │ ├── cpp │ │ │ │ └── hello │ │ │ │ │ └── Speaker.cpp │ │ │ └── headers │ │ │ │ └── hello │ │ │ │ └── Speaker.hpp │ │ │ └── test │ │ │ ├── cpp │ │ │ ├── hello │ │ │ │ └── SpeakerTest.cpp │ │ │ └── run_tests.cpp │ │ │ └── headers │ │ │ └── hello │ │ │ └── SpeakerTest.hpp │ ├── hello-main │ │ ├── CMakeLists.txt │ │ ├── build.gradle │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── src │ │ │ └── main │ │ │ └── cpp │ │ │ └── main │ │ │ └── HelloWorld.cpp │ └── settings.gradle ├── hello-world-with-libraries │ ├── .CMakeLists.txt.kate-swp │ ├── .gitignore │ ├── LICENSE │ ├── README.md │ ├── hello-library │ │ ├── CMakeLists.txt │ │ ├── build.gradle │ │ ├── cmake_modules │ │ │ ├── FindCPPUNIT.cmake │ │ │ ├── gradle-cpp-cppUnitTest.cmake │ │ │ └── gradle-cpp.cmake │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── src │ │ │ ├── main │ │ │ ├── cpp │ │ │ │ └── hello │ │ │ │ │ └── Speaker.cpp │ │ │ └── headers │ │ │ │ └── hello │ │ │ │ └── Speaker.hpp │ │ │ └── test │ │ │ ├── cpp │ │ │ ├── hello │ │ │ │ └── SpeakerTest.cpp │ │ │ └── run_tests.cpp │ │ │ └── headers │ │ │ └── hello │ │ │ └── SpeakerTest.hpp │ └── hello-main │ │ ├── CMakeLists.txt │ │ ├── build.gradle │ │ ├── cmake_modules │ │ ├── FindCPPUNIT.cmake │ │ ├── gradle-cpp-cppUnitTest.cmake │ │ └── gradle-cpp.cmake │ │ ├── gradle.properties │ │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ └── src │ │ └── main │ │ └── cpp │ │ └── main │ │ └── HelloWorld.cpp ├── hello-world │ ├── .gitignore │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── build.gradle │ ├── cmake_modules │ │ ├── FindCPPUNIT.cmake │ │ ├── gradle-cpp-cppUnitTest.cmake │ │ └── gradle-cpp.cmake │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── src │ │ └── main │ │ ├── cpp │ │ ├── hello │ │ │ └── Speaker.cpp │ │ └── main │ │ │ └── HelloWorld.cpp │ │ └── headers │ │ └── hello │ │ └── Speaker.h └── version.gradle ├── gradle.properties ├── gradle ├── publish.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images └── cppPluginGraph.jpg ├── modules └── cmake_modules │ ├── FindCPPUNIT.cmake │ ├── gradle-cpp-cppUnitTest.cmake │ └── gradle-cpp.cmake ├── settings.gradle ├── src ├── main │ ├── groovy │ │ └── fr │ │ │ └── echoes │ │ │ └── gradle │ │ │ └── plugins │ │ │ └── cpp │ │ │ ├── CppPlugin.groovy │ │ │ ├── CppPluginUtils.groovy │ │ │ ├── configurations │ │ │ ├── ArchivesConfigurations.groovy │ │ │ └── CppConfiguration.groovy │ │ │ ├── extensions │ │ │ ├── CppExecExtension.groovy │ │ │ └── CppPluginExtension.groovy │ │ │ ├── model │ │ │ └── ApplicationType.groovy │ │ │ └── tasks │ │ │ ├── CppExecTask.groovy │ │ │ ├── DownloadLibTask.groovy │ │ │ └── InitOutputDirsTask.groovy │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ ├── fr.echoes.gradle.cpp.properties │ │ └── fr.echoes.gradle.cpptask.properties └── test │ ├── groovy │ └── fr │ │ └── echoes │ │ └── gradle │ │ └── plugins │ │ └── cpp │ │ ├── CppExecTaskSpec.groovy │ │ ├── DistZipTaskSpec.groovy │ │ ├── DownloadLibTaskSpec.groovy │ │ ├── InitOutputDirsTaskSpec.groovy │ │ ├── ProjectTaskSpec.groovy │ │ ├── UploadArchivesTaskSpec.groovy │ │ └── UtilsSpec.groovy │ └── resources │ ├── distZipTest │ ├── headers │ │ └── hello │ │ │ └── hello.h │ └── lib │ │ └── hello │ │ └── Hello.so │ └── logback.xml ├── systemTests.gradle └── update-gh-pages.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | 4 | # Ignore Gradle GUI config 5 | gradle-app.setting 6 | 7 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 8 | !gradle-wrapper.jar 9 | /bin/ 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | addons: 2 | apt: 3 | packages: 4 | - libcppunit-dev 5 | 6 | language: groovy 7 | script: "./gradlew build install systemTests jacocoTestReport" 8 | jdk: oraclejdk7 9 | after_success: 10 | - "./gradlew coveralls" 11 | - "./gradlew groovydoc" 12 | - "./update-gh-pages.sh" 13 | env: 14 | global: 15 | secure: YVjSUOJU+si4TfcxOFJ9CSA4vozBrgn8X0rfP72Z5IzYpKXO2CRGNMbYfd00hznNQPp2BlZwZMvxj0etTZ+9mG5t6DiAOSDYOfLYnzcJ89bvAchNK8xDmAselSaby9v3iOHysgSX07zCKZhDQHfVRpQ8jc9B72qva3NwLXN1J9up0hbxkujvG3vtm3MoPxIJEXZyKlzsrcijur8aL2RogwXHTSdJ6z55DijD9jN7PmP0325z1b15AeuYza3cImadz4CBHuKhLuHNGA3kZZTsrH+ZWrQnMeYvESCdWItvKd2VuIDgiq3cvUpar0J1BDFJr2lQsEsndjMsoAVo/NWirbOOlig5XbxxzQ8ovWEZpdHYkEXHvI90dYPQ1jDSGNiHD4gX6V3ezmNVyqSj813UUyv8VtR8yMTYC1PK6JWLwddsRWhhxRRAF3w7w28uliN2rus5FXCLx9b72fhZ0tpvafdBvMns82+1463PZKhuHCKC9njTG4hYKSn8ZsgpFAPpWIESmT+2yZZTTvmHPlWR6DlRDebxgcUeHGi9oDqzSO4meGQ4FgGMdAdOxnZZicunGCqBML2SYOJ2pdnT2oh/+3am4RZrREzSpiPDc4r+fjqYix5u1Xuq6hv+H36MdXArhCJoRHKVeVWe7vBRuYy/hnHtcCIZ8yt4OkmrO8MNdQE= 16 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | buildscript { 19 | repositories { 20 | 21 | maven { 22 | url "https://plugins.gradle.org/m2/" 23 | } 24 | } 25 | dependencies { 26 | classpath "com.gradle.publish:plugin-publish-plugin:0.9.1" 27 | } 28 | } 29 | 30 | plugins { 31 | id "org.sonarqube" version "2.0.1" 32 | id "com.github.kt3k.coveralls" version "2.4.0" 33 | id "com.gradle.plugin-publish" version "0.9.1" 34 | id "idea" 35 | id "maven" 36 | id "jacoco" 37 | id "groovy" 38 | } 39 | 40 | apply from: "$gradleConfigUrl/git.gradle" // populates $branch 41 | 42 | apply from: "$gradleConfigUrl/init.gradle" // initialize global variables 43 | apply from: "$gradleConfigUrl/eclipse.gradle" 44 | apply from: "$gradleConfigUrl/sonar.gradle" 45 | apply from: "$gradleConfigUrl/nexus.gradle" 46 | apply from: "$gradleConfigUrl/findbugs.gradle" 47 | apply from: "$gradleConfigUrl/jacoco.gradle" 48 | apply from: "$gradleConfigUrl/javadoc-aggregate.gradle" 49 | apply from: "$gradleConfigUrl/groovydoc-aggregate.gradle" 50 | apply from: "$gradleConfigUrl/documentation-zip.gradle" 51 | 52 | 53 | repositories { 54 | mavenLocal() 55 | mavenCentral() 56 | jcenter() 57 | } 58 | 59 | 60 | compileJava { 61 | sourceCompatibility = javaVersion 62 | targetCompatibility = javaVersion 63 | } 64 | compileGroovy { 65 | sourceCompatibility = javaVersion 66 | targetCompatibility = javaVersion 67 | } 68 | 69 | 70 | configurations { 71 | groovyDoc.extendsFrom runtime 72 | } 73 | 74 | 75 | 76 | dependencies { 77 | compile gradleApi() 78 | compile localGroovy() 79 | compile "commons-io:commons-io:$commonsioVersion" 80 | 81 | testCompile("org.spockframework:spock-core:$spockVersion") { 82 | exclude module: 'groovy-all' 83 | } 84 | testRuntime("com.athaydes:spock-reports:$spockSeportVersion"){ 85 | exclude module: 'groovy-all' 86 | } 87 | 88 | //documentation 89 | dependencies { 90 | groovyDoc "org.codehaus.groovy:groovy-groovydoc:$groovyVersion" 91 | groovyDoc "org.codehaus.groovy:groovy-ant:$groovyVersion" 92 | } 93 | } 94 | 95 | 96 | task sourceJar(type: Jar) { 97 | group 'Build' 98 | description 'An archive of the source code' 99 | classifier 'sources' 100 | from sourceSets.main.allSource 101 | } 102 | 103 | task wrapper(type: Wrapper) { 104 | gradleVersion = gradeleWrapper 105 | } 106 | 107 | 108 | groovydoc { 109 | groovyClasspath = configurations.groovyDoc 110 | } 111 | 112 | jacoco { 113 | toolVersion = '0.7.1.201405082137' 114 | } 115 | 116 | 117 | jacocoTestReport { 118 | reports { 119 | html.enabled = true 120 | xml.enabled = true 121 | csv.enabled = false 122 | } 123 | } 124 | 125 | 126 | 127 | // The configuration example below shows the minimum required properties 128 | // configured to publish your plugin to the plugin portal 129 | pluginBundle { 130 | website = 'http://tocea.github.io/gradle-cpp-plugin/' 131 | vcsUrl = 'https://github.com/Tocea/gradle-cpp-plugin' 132 | description = 'gradle plugin for c++' 133 | tags = ['cpp', 'c++'] 134 | 135 | plugins { 136 | cppPlugin { 137 | id = 'fr.echoes.gradle.cpp' 138 | displayName = 'gradle plugin for c++' 139 | } 140 | } 141 | } 142 | 143 | 144 | 145 | /////////////////// for system testings //////////////////////// 146 | 147 | apply from: 'systemTests.gradle' 148 | 149 | task systemTests(dependsOn: install) 150 | 151 | systemTests.dependsOn helloWorldTest 152 | systemTests.dependsOn helloWordWithDependenciesTest 153 | systemTests.dependsOn helloWorldMulitModulesTest 154 | 155 | -------------------------------------------------------------------------------- /docs/developersDoc.md: -------------------------------------------------------------------------------- 1 | # Developers documentation 2 | 3 | ## Used technologies 4 | 5 | * Groovy 6 | * Gradle (build tool) 7 | * Spock (unit test) 8 | * Jacoco (code coverage) 9 | 10 | ## Servers Urls 11 | 12 | * Source repository -> Github : https://github.com/Tocea/gradle-cpp-plugin 13 | * Gradle plugin repository -> https://plugins.gradle.org/plugin/fr.echoes.gradle.cpp 14 | * Continious integration server -> Travis : https://travis-ci.org/ (connection with your github account 15 | * Project web site -> http://tocea.github.io/gradle-cpp-plugin/ 16 | * User documentation -> Just a readme at this time : https://github.com/Tocea/gradle-cpp-plugin/blob/master/README.md' 17 | * Release process documentation -> https://github.com/Tocea/gradle-cpp-plugin/blob/master/release-process.md 18 | * Groovydoc -> http://tocea.github.io/gradle-cpp-plugin/groovydoc/1.2.8/ 19 | * test reports -> http://tocea.github.io/gradle-cpp-plugin/spock-reports/1.2.8/ 20 | * Code coverage -> https://coveralls.io/github/Tocea/gradle-cpp-plugin 21 | 22 | ## Notes 23 | 24 | GroovyDoc and test reports are publish in githbub from a Travis build. This upload is done with the file [update-gh-pages.sh] (https://github.com/Tocea/gradle-cpp-plugin/blob/master/update-gh-pages.sh). 25 | It could be a good idea to create a page `latest` for the different documentations. ex : http://tocea.github.io/gradle-cpp-plugin/groovydoc/latest/ 26 | 27 | -------------------------------------------------------------------------------- /docs/modules/cmake-modules.md: -------------------------------------------------------------------------------- 1 | #Using cmake module 2 | 3 | ## Desrcription 4 | 5 | This page describe will help you to use to write c++ projects using cmake simply. 6 | Three modules are provided : 7 | 8 | * 'gradle-cpp-plugin' : the main component 9 | * 'gradle-cpp-cppUnitTest' : to compile and launch test 10 | * 'Find-cppUnitTest' : Use by 'gradle-cppUnitTest' to check if [cppUnit](http://cppunit.sourceforge.net/doc/cvs/cppunit_cookbook.html) is well installed on your computer. 11 | 12 | Thes modules can be find [here](https://github.com/Tocea/gradle-cpp-plugin/tree/master/modules/cmake_modules). 13 | 14 | ## The 'gradle-cpp-plugin' 15 | 16 | This module add this features : 17 | 18 | * the sourceset 'src/main/headers' and 'src/main/cpp'. 19 | * the usage of gradle dependencies. 20 | * the possibility to get values in a '.properties' file 21 | 22 | ### The sourceset 23 | 24 | The plugin add two sourceset 'src/main/headers' and 'src/main/cpp'. 25 | 26 | Files in 'src/main/headers' should only contains headers files. Headers files will be copied in the folder 'build/tmp/headers'. All files in this sourcset will be consequently visible for other projects. If you want to hide a header file, put it in 'src/main/cpp'. 27 | 28 | Files in 'src/main/cpp' should only contains c++ or c files. Sources are placed in a CMake variable ${SOURCES}. This variable is usefull to create libraries : 29 | ''' 30 | add_library ( 31 | ${PROJECT_STATICNAME} 32 | STATIC 33 | ${SOURCES} 34 | ) 35 | 36 | add_library ( 37 | ${PROJECT_NAME} 38 | SHARED 39 | ${SOURCES} 40 | ) 41 | ''' 42 | or executables : 43 | ''' 44 | add_executable(${PROJECT_NAME} ${SOURCES}) 45 | ''' 46 | 47 | 48 | **Good practice :** files in a namespace should be in folder with the same name. 49 | 50 | ### Dependencies 51 | 52 | The module store dinamically all static libraries comming from gradle (ex : 'compile 'foo.bar:my-library:1.0@clib') and place it in a CMake variable '${STATIC_LIBRARIES}'. 53 | 54 | Directly, in your code, you can use API from your dependencies. To link these externals libraries to your executable or your library. add this to your 'CMakelists.txt' file. 55 | ''' 56 | add_executable( ${SOURCES}) 57 | ''' 58 | 59 | ### Read properties file 60 | 61 | Properties file are used to store a list of 'keys', 'values'. One exemple of this type of file is the file 'gradle.properties'. 62 | ''' 63 | group=fr.echoes.example 64 | version=1.0.0-SNAPSHOT 65 | ''' 66 | The module give the possility to read this type of files and find values. One useful case is to get the project version. To do this, call the function get_property_value(FilePath PropertiesKey output_variable) 67 | * FilePath is the location of the propertie file 68 | * PropertiesKey is the property key we want the value 69 | * output_variable is the variable name to store the result. 70 | 71 | **Example :** 72 | ''' 73 | get_property_value(${CMAKE_SOURCE_DIR}/gradle.properties "version" VERSION) 74 | ''' 75 | This line return for the previous 'gradle.properties' the result '1.0.0-SNAPSHOT'. 76 | 77 | 78 | ### Usage Example 79 | 80 | ''' 81 | cmake_minimum_required (VERSION 2.8) 82 | project (hello-main) 83 | 84 | # set the path to find modules 85 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") 86 | # include the module gradle-cpp 87 | include(gradle-cpp) 88 | # do not include the module gradle-cpp-cppUnitTest 89 | # because there are no tests in the projects 90 | # or cppUnit is not installed in your computer 91 | #include(gradle-cpp-cppUnitTest) 92 | 93 | 94 | # read version of the project in the gradle.propersties file 95 | get_property_value(${CMAKE_SOURCE_DIR}/gradle.properties "version" VERSION) 96 | 97 | SET(PROJECT_NAME "hello-main-${VERSION}") 98 | 99 | # create an executable call 'hello-main-1.0.0-SNAPSHOT 100 | # this executable use the sources from 'src/main/java' 101 | add_executable(${PROJECT_NAME} ${SOURCES}) 102 | 103 | # link to this executables all static libraries dependencies coming from gradle 104 | target_link_libraries(${PROJECT_NAME} ${STATIC_LIBRARIES}) 105 | ''' 106 | 107 | ## The 'gradle-cpp-cppUnitTest' module 108 | 109 | The 'gradle-ccp-cppUnitTest' module had this features : 110 | * the sourcesets 'src/test/headers' and 'src/test/cpp' 111 | * checking if cppUnit is install on your computer or not (the module does not install it) 112 | * launch test (create a rule 'test' for make for example) 113 | 114 | ## The 'Find-cppUnitTest' module 115 | 116 | The 'find-cppUnitTest' is a module to check in cppUnit is installed on your computer. You don't have to use this module directly. 117 | This module is called by the 'gradle-cpp-cppUnitTest' module. 118 | 119 | ## See examples 120 | 121 | Examples can be found in [here](https://github.com/Tocea/gradle-cpp-plugin/tree/master/exemples). 122 | 123 | ## Notes 124 | 125 | I'm not an expert of cmake. These modules can be improved. You help is welcomed :). You can see the next cool features or issues to fix [here](https://github.com/Tocea/gradle-cpp-plugin/issues). 126 | -------------------------------------------------------------------------------- /docs/release-process.md: -------------------------------------------------------------------------------- 1 | # How to release the plugin 2 | 3 | ## Prerequisite 4 | 5 | This page use git-flow to process release. So you need to install it : https://www.atlassian.com/git/tutorials/comparing-workflows/centralized-workflow. 6 | 7 | ## Process 8 | 9 | 1. prepare the release with git flow. 10 | * `git flow release start ` 11 | 2. update version in the file build.gradle to ``. 12 | 3. change some informations in `readme.md` file. 13 | 1. change the branch name in the two first link in the two first lines. 14 | ```markdown 15 | [![Build Status](https://travis-ci.org/Tocea/gradle-cpp-plugin.svg?branch=develop)](https://travis-ci.org/Tocea/gradle-cpp-plugin) 16 | [![Coverage Status](https://coveralls.io/repos/Tocea/gradle-cpp-plugin/badge.svg?branch=develop)](https://coveralls.io/r/Tocea/gradle-cpp-plugin?branch=develop) 17 | ``` 18 | must be replaced by : 19 | ```markdown 20 | [![Build Status](https://travis-ci.org/Tocea/gradle-cpp-plugin.svg?branch=master)](https://travis-ci.org/Tocea/gradle-cpp-plugin) 21 | [![Coverage Status](https://coveralls.io/repos/Tocea/gradle-cpp-plugin/badge.svg?branch=master)](https://coveralls.io/r/Tocea/gradle-cpp-plugin?branch=master) 22 | ``` 23 | 2. change the buildScript information 24 | ```groovy 25 | buildscript { 26 | repositories { 27 | mavenCentral() 28 | } 29 | dependencies { 30 | classpath "gradle.plugin.fr.echoes.gradle.plugins:cpp-project-plugin:-SNAPSHOT" 31 | } 32 | } 33 | ``` 34 | must be replaced with : 35 | ```groovy 36 | buildscript { 37 | repositories { 38 | maven { 39 | url "https://plugins.gradle.org/m2/" 40 | } 41 | } 42 | dependencies { 43 | classpath "gradle.plugin.fr.echoes.gradle.plugins:cpp-project-plugin:" 44 | } 45 | } 46 | ``` 47 | 4. finish the release. 48 | * `git flow release finish` 49 | 5. Publish the `master` branch on *github* 50 | 6. publish on the graple plugin repository. 51 | 1. To do that. you need first to have an account and well configured on the [gradle plugin repository](https://plugins.gradle.org/) 52 | 2. checkout the tag produce by the release process : 53 | * `git checkout cpp_` 54 | 3. publish the plugin with the command : 55 | * `./gradlew publishPlugins -Dgradle.publish.key= -Dgradle.publish.secret=`. 56 | * The *secret* and the *public* key come from your gradle account --> [see documentation](https://plugins.gradle.org/docs/submit). 57 | 58 | ## Prepare the develop version 59 | 60 | 1. update the develop branch source for the next version : . 61 | 2. change some informations in `readme.md` file. 62 | 63 | 1. change the branch name in the two first link in the two first lines. 64 | 65 | ```markdown 66 | [![Build Status](https://travis-ci.org/Tocea/gradle-cpp-plugin.svg?branch=master)](https://travis-ci.org/Tocea/gradle-cpp-plugin) 67 | [![Coverage Status](https://coveralls.io/repos/Tocea/gradle-cpp-plugin/badge.svg?branch=master)](https://coveralls.io/r/Tocea/gradle-cpp-plugin?branch=master) 68 | ``` 69 | must be replaced by : 70 | 71 | ```markdown 72 | [![Build Status](https://travis-ci.org/Tocea/gradle-cpp-plugin.svg?branch=develop)](https://travis-ci.org/Tocea/gradle-cpp-plugin) 73 | [![Coverage Status](https://coveralls.io/repos/Tocea/gradle-cpp-plugin/badge.svg?branch=develop)](https://coveralls.io/r/Tocea/gradle-cpp-plugin?branch=develop) 74 | ``` 75 | 2. change the buildScript information. 76 | 77 | ```groovy 78 | buildscript { 79 | repositories { 80 | maven { 81 | url "https://plugins.gradle.org/m2/" 82 | } 83 | } 84 | dependencies { 85 | classpath "gradle.plugin.fr.echoes.gradle.plugins:cpp-project-plugin:" 86 | } 87 | } 88 | ``` 89 | must be replaced with : 90 | 91 | ```groovy 92 | buildscript { 93 | repositories { 94 | mavenCentral() 95 | } 96 | dependencies { 97 | classpath "gradle.plugin.fr.echoes.gradle.plugins:cpp-project-plugin:-SNAPSHOT" 98 | } 99 | } 100 | ``` 101 | 102 | 103 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/.CMakeLists.txt.kate-swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tocea/gradle-cpp-plugin/8aa0129d9ac38ca922ba7e439f03442c74e81341/exemples/hello-world-multi-modules/.CMakeLists.txt.kate-swp -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | cmake_install.cmake 4 | **/CMakeFiles/ 5 | **/cmake_install.cmake 6 | Makefile 7 | CMakeHelloWorld 8 | *.a 9 | **/*.a 10 | build/** 11 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) <2013> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/README.md: -------------------------------------------------------------------------------- 1 | This is an extremely simple example C++ application which uses CMake. 2 | It will build and install an application called CMakeHelloWorld which simply outputs "Hello, world!" to stdout. 3 | 4 | ### Installation ### 5 | As this is an example of how to use CMake you'll need to download it (http://www.cmake.org/cmake/resources/software.html) or install it via: 6 | ```bash 7 | sudo apt-get install cmake 8 | ``` 9 | Once CMake has been install navigate to the root of the project and issue the following commands: 10 | ```bash 11 | mkdir build 12 | cd build 13 | cmake .. && make 14 | make install 15 | ``` 16 | You may need to use`sudo make install` command as it will install to /usr/local/bin . This might be a good opportunity to investigate stow (http://www.gnu.org/software/stow/manual/stow.html) as a means of managing the installation of applications in this manner, however I haven't gotten far enough into my CMake knowledge to take that step. 17 | 18 | ### Usage ### 19 | Once the executable has been created simply call `CMakeHelloWorld`, either from the build directory or anywhere (if you installed to /usr/local/bin, etc). 20 | 21 | ***Uninstallation*** 22 | Removing the application is straight-forward. Simply delete the binary 'CMakeHelloWorld' from /usr/local/bin. 23 | 24 | 25 | ***Caution*** 26 | I am a complete C++ noob. I've created this project as part of an effort to kickstart my C++ recovery as I have recently been placed on a team which is developing an embedded application. There may be any number of things wrong with this example. If you see something you know to be implemented incorrectly please contact me via github and I will do my best to correct it. Better, fork the project, fix it and issue a pull request. 27 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This build file was auto generated by running the Gradle 'init' task 3 | * by 'jguidoux' at '05/10/15 21:43' with Gradle 2.4 4 | * 5 | * This generated file contains a commented-out sample Java project to get you started. 6 | * For more details take a look at the Java Quickstart chapter in the Gradle 7 | * user guide available at http://gradle.org/docs/2.4/userguide/tutorial_java_projects.html 8 | */ 9 | 10 | /* 11 | // Apply the java plugin to add support for Java 12 | apply plugin: 'java' 13 | 14 | // In this section you declare where to find the dependencies of your project 15 | repositories { 16 | // Use 'jcenter' for resolving your dependencies. 17 | // You can declare any Maven/Ivy/file repository here. 18 | jcenter() 19 | } 20 | 21 | // In this section you declare the dependencies for your production and test code 22 | dependencies { 23 | // The production code uses the SLF4J logging API at compile time 24 | compile 'org.slf4j:slf4j-api:1.7.12' 25 | 26 | // Declare the dependency for your favourite test framework you want to use in your tests. 27 | // TestNG is also supported by the Gradle Test task. Just change the 28 | // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add 29 | // 'test.useTestNG()' to your build script. 30 | testCompile 'junit:junit:4.12' 31 | } 32 | */ 33 | 34 | 35 | buildscript { 36 | apply from: '../version.gradle' 37 | 38 | repositories { 39 | mavenLocal() 40 | jcenter() 41 | } 42 | dependencies { 43 | classpath "fr.echoes.gradle.plugins:cpp-project-plugin:${cppPluginVersion('../../gradle.properties')}" 44 | } 45 | } 46 | 47 | allprojects { 48 | task wrapper(type: Wrapper) { 49 | gradleVersion = '2.7' 50 | } 51 | } 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/cmake_modules/FindCPPUNIT.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Find the CppUnit includes and library 3 | # 4 | # This module defines 5 | # CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc. 6 | # CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit. 7 | # CPPUNIT_FOUND, If false, do not try to use CppUnit. 8 | 9 | # also defined, but not for general use are 10 | # CPPUNIT_LIBRARY, where to find the CppUnit library. 11 | # CPPUNIT_DEBUG_LIBRARY, where to find the CppUnit library in debug 12 | # mode. 13 | 14 | SET(CPPUNIT_FOUND "NO") 15 | 16 | FIND_PATH(CPPUNIT_INCLUDE_DIR cppunit/TestCase.h /usr/local/include /usr/include) 17 | 18 | # With Win32, important to have both 19 | IF(WIN32) 20 | FIND_LIBRARY(CPPUNIT_LIBRARY cppunit 21 | ${CPPUNIT_INCLUDE_DIR}/../lib 22 | /usr/local/lib 23 | /usr/lib) 24 | FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunitd 25 | ${CPPUNIT_INCLUDE_DIR}/../lib 26 | /usr/local/lib 27 | /usr/lib) 28 | ELSE(WIN32) 29 | # On unix system, debug and release have the same name 30 | FIND_LIBRARY(CPPUNIT_LIBRARY cppunit 31 | ${CPPUNIT_INCLUDE_DIR}/../lib 32 | /usr/local/lib 33 | /usr/lib) 34 | FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunit 35 | ${CPPUNIT_INCLUDE_DIR}/../lib 36 | /usr/local/lib 37 | /usr/lib) 38 | ENDIF(WIN32) 39 | 40 | IF(CPPUNIT_INCLUDE_DIR) 41 | IF(CPPUNIT_LIBRARY) 42 | SET(CPPUNIT_FOUND "YES") 43 | SET(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY} ${CMAKE_DL_LIBS}) 44 | SET(CPPUNIT_DEBUG_LIBRARIES ${CPPUNIT_DEBUG_LIBRARY} ${CMAKE_DL_LIBS}) 45 | ELSE (CPPUNIT_LIBRARY) 46 | IF (CPPUNIT_FIND_REQUIRED) 47 | MESSAGE(SEND_ERROR "Could not find library CppUnit.") 48 | ENDIF (CPPUNIT_FIND_REQUIRED) 49 | ENDIF(CPPUNIT_LIBRARY) 50 | ELSE(CPPUNIT_INCLUDE_DIR) 51 | IF (CPPUNIT_FIND_REQUIRED) 52 | MESSAGE(SEND_ERROR "Could not find library CppUnit.") 53 | ENDIF(CPPUNIT_FIND_REQUIRED) 54 | ENDIF(CPPUNIT_INCLUDE_DIR) 55 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/cmake_modules/gradle-cpp-cppUnitTest.cmake: -------------------------------------------------------------------------------- 1 | 2 | SET(TEST_SRC ${PROJECT_SOURCE_DIR}/src/test/cpp) 3 | SET(TEST_HEADERS ${PROJECT_SOURCE_DIR}/src/test/headers) 4 | file(GLOB_RECURSE TEST_SOURCES ${TEST_SRC}/*.cpp) 5 | 6 | # ------------------------- 7 | 8 | # Usefull to get CPPUNIT ... 9 | # I would love to find a way to have cppunit 10 | # only required for builds where unit test make sense ... 11 | #set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") 12 | FIND_PACKAGE(CPPUNIT REQUIRED) 13 | 14 | ##################### tests ################## 15 | 16 | enable_testing() 17 | 18 | 19 | #set(TMP_VAR ${EXECUTABLE_OUTPUT_PATH}) 20 | #set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build/test-obj) 21 | include_directories(${TEST_HEADERS}) 22 | 23 | 24 | add_executable(launchTest ${SOURCES} ${TEST_SOURCES}) 25 | target_link_libraries(launchTest cppunit ${STATIC_LIBRARIES}) 26 | add_test(NAME aTest COMMAND launchTest) 27 | 28 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/cmake_modules/gradle-cpp.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Main useful constants 3 | SET(MAIN_SRC ${PROJECT_SOURCE_DIR}/src/main/cpp) 4 | SET(MAIN_HEADERS ${PROJECT_SOURCE_DIR}/src/main/headers) 5 | 6 | 7 | set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build) 8 | 9 | 10 | # Default output directories 11 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tmp/bin) 12 | set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tmp/lib) 13 | file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) 14 | file(MAKE_DIRECTORY ${LIBRARY_OUTPUT_PATH}) 15 | FILE(GLOB_RECURSE SOURCES ${MAIN_SRC}/*.cpp) 16 | 17 | 18 | ## Default include directories 19 | 20 | include_directories(${MAIN_HEADERS}) 21 | include_directories(${MAIN_SRC}) 22 | 23 | 24 | # Variables de compilation (et valeurs par défaut) 25 | if(NOT DEFINED LIBRARY_TYPE) # STATIC 26 | SET(LIBRARY_TYPE "SHARED") # STATIC|MODULE|SHARED 27 | endif() 28 | if(NOT DEFINED VERSION) 29 | SET(VERSION "1.0-SNAPSHOT") 30 | endif() 31 | 32 | 33 | if(DEFINED VERSION) 34 | SET(SOVERSION ${VERSION}) 35 | endif() 36 | 37 | if(NOT DEFINED LIB_READLINE) 38 | SET(LIB_READLINE "no") 39 | endif() 40 | if(NOT DEFINED LIB_ICONV) 41 | SET(LIB_ICONV "yes") 42 | endif() 43 | if(NOT DEFINED LIB_GETTEXT) 44 | SET(LIB_GETTEXT "yes") 45 | endif() 46 | if(NOT DEFINED LIB_DL) 47 | SET(LIB_DL "no") 48 | endif() 49 | 50 | # DEFAULT FLAGS 51 | if(NOT DEFINED FLAGS) 52 | # for gcc > 4.9 53 | #SET(FLAGS "-fdiagnostics-color=always") 54 | endif() 55 | 56 | # Initialisation specifique OS 57 | #---------------------------------------------------------- 58 | if( ${CMAKE_SYSTEM_NAME} MATCHES Linux) 59 | LIST(APPEND REQUIRED_LIBS "resolv") 60 | SET(FLAGS "${FLAGS} -DLINUX") 61 | endif() 62 | 63 | if( ${CMAKE_SYSTEM_NAME} MATCHES Linux) 64 | SET( LIB_GETTEXT "yes") 65 | SET( LIB_ICONV "yes") 66 | elseif( ${CMAKE_SYSTEM_NAME} MATCHES Windows ) 67 | SET( LIB_GETTEXT "no") 68 | SET( LIB_ICONV "no") 69 | endif() 70 | 71 | 72 | 73 | 74 | # Triggers des options 75 | #-------------------------------------------------------- 76 | 77 | 78 | # Triggers simples 79 | 80 | if ( ${LIB_READLINE}) 81 | SET(LIB_DL "yes") 82 | SET(FLAGS "${FLAGS} -DREADLINE") 83 | endif() 84 | 85 | if ( ${LIB_GETTEXT} ) 86 | SET(FLAGS "${FLAGS} -DGETTEXT") 87 | #SI AIX -lintl 88 | endif() 89 | 90 | if ( ${LIB_ICONV} ) 91 | SET(FLAGS "${FLAGS} -DICONV") 92 | #SI AIX -liconv 93 | #SI SUNOS -liconv 94 | endif() 95 | 96 | # Triggers complexes 97 | 98 | 99 | if( NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows AND ${LIB_DL} MATCHES "yes") 100 | LIST(APPEND REQUIRED_LIBS "dl") 101 | endif() 102 | 103 | 104 | set(CUSTOM_LIBRARY_PATH ${CMAKE_BINARY_DIR}/extLib) 105 | MESSAGE( STATUS "CUSTOM LIBRARY PATH : ${CUSTOM_LIBRARY_PATH}" ) 106 | file(MAKE_DIRECTORY ${CUSTOM_LIBRARY_PATH}) 107 | 108 | 109 | file(GLOB sub-dir ${CUSTOM_LIBRARY_PATH}/*) 110 | foreach(dir ${sub-dir}) 111 | if(IS_DIRECTORY ${dir}) 112 | set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}:${dir}) 113 | endif() 114 | endforeach() 115 | 116 | # to find libraries 117 | file( GLOB LIB_HEADERS ${CUSTOM_LIBRARY_PATH}/*/headers ) 118 | file( GLOB STATIC_LIBRARIES ${CUSTOM_LIBRARY_PATH}/*/lib/*.a ) 119 | 120 | 121 | ## Default include headers libraries 122 | include_directories(${LIB_HEADERS}) 123 | 124 | 125 | #------------------------------------------------------------------------------------------------------------ 126 | # CREATION DU PROFIL DE COMPILATION 127 | 128 | SET(MULTITHREAD_FLAGS "-DRENT -D_THREAD_SAFE -L/usr/lib/threads -L/usr/lib/dce -lpthread -DMULTITHREAD -pthread ") 129 | 130 | # Profiles de compilation -DCMAKE_BUILD_TYPE= 131 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-strict-overflow ${FLAGS}") 132 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-strict-overflow ${FLAGS}") 133 | 134 | #-------------------------------------------------------- 135 | # PROFIL Release 136 | SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3" ${CMAKE_CXX_FLAGS}) 137 | SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3" ${CMAKE_C_FLAGS}) 138 | 139 | 140 | #-------------------------------------------------------- 141 | # PROFIL Debug 142 | SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -ggdb -g3 ${CMAKE_CXX_FLAGS}") 143 | SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -ggdb -g3 ${CMAKE_C_FLAGS}") 144 | 145 | 146 | ######################## additives functions ########################$ 147 | 148 | #thi function read propersties form a propersties file. 149 | # a preperties file look like that : 150 | # key#1 = valeur1 151 | # key2 = valeur2 152 | # … 153 | # this function return the value associate to a key 154 | function(get_property_value FilePath Key ResultValue) 155 | 156 | 157 | file(READ ${FilePath} Contents) 158 | # Set the variable "Esc" to the ASCII value 27 - basically something 159 | # which is unlikely to conflict with anything in the file contents. 160 | string(ASCII 27 Esc) 161 | 162 | # Turn the contents into a list of strings, each ending with an Esc. 163 | # This allows us to preserve blank lines in the file since CMake 164 | # automatically prunes empty list items during a foreach loop. 165 | string(REGEX REPLACE "\n" "${Esc};" ContentsAsList ${Contents}) 166 | 167 | 168 | 169 | unset(ModifiedContents) 170 | foreach(Line ${ContentsAsList}) 171 | message("Line = ${Line}") 172 | #STRING(REGEX MATCH "${Key}[ ]*=[ ]*.*" Value ${Line}) 173 | #message("temp value=${Value}") 174 | if("${Line}" MATCHES "${Key}[ ]*=[ ]*.*") 175 | string(REGEX REPLACE "${Key}[ ]*=[ ]*" "" Value ${Line}) 176 | endif() 177 | 178 | endforeach() 179 | string(REGEX REPLACE "${Esc}" "" Value ${Value}) 180 | SET(${ResultValue} ${Value} PARENT_SCOPE) 181 | endfunction() 182 | 183 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/gradle.properties: -------------------------------------------------------------------------------- 1 | group=fr.echoes.example 2 | version=1.0.0-SNAPSHOT 3 | optionDone=false 4 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tocea/gradle-cpp-plugin/8aa0129d9ac38ca922ba7e439f03442c74e81341/exemples/hello-world-multi-modules/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Oct 06 16:57:50 CEST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip 7 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8) 2 | project (hello-library) 3 | 4 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake_modules/") 5 | include(gradle-cpp) 6 | include(gradle-cpp-cppUnitTest) 7 | 8 | 9 | 10 | 11 | # read version of the project in the gradle.propersties file 12 | get_property_value(${CMAKE_SOURCE_DIR}/../gradle.properties "version" VERSION) 13 | 14 | SET(PROJECT_NAME "hello-${VERSION}") 15 | SET(PROJECT_STATICNAME "hello_static-${VERSION}") 16 | 17 | 18 | 19 | 20 | ####################################" 21 | add_library ( 22 | ${PROJECT_STATICNAME} 23 | STATIC 24 | ${SOURCES} 25 | ) 26 | ####################################" 27 | add_library ( 28 | ${PROJECT_NAME} 29 | SHARED 30 | ${SOURCES} 31 | ) 32 | 33 | 34 | ####################################" 35 | # FIN INITIALISATION VARIABLES 36 | # 37 | 38 | 39 | # LINK LIBRARIES 40 | 41 | target_link_libraries( ${PROJECT_STATICNAME} ${STATIC_LIBRARIES} ) 42 | target_link_libraries( ${PROJECT_NAME} ${STATIC_LIBRARIES} ) 43 | 44 | 45 | # Add own output directory to library dir 46 | LIST(APPEND CMAKE_PREFIX_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) 47 | 48 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-library/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This build file was auto generated by running the Gradle 'init' task 3 | * by 'jguidoux' at '23/09/15 13:12' with Gradle 2.4 4 | * 5 | * This generated file contains a commented-out sample Java project to get you started. 6 | * For more details take a look at the Java Quickstart chapter in the Gradle 7 | * user guide available at http://gradle.org/docs/2.4/userguide/tutorial_java_projects.html 8 | */ 9 | 10 | /* 11 | // Apply the java plugin to add support for Java 12 | apply plugin: 'java' 13 | 14 | // In this section you declare where to find the dependencies of your project 15 | repositories { 16 | // Use 'jcenter' for resolving your dependencies. 17 | // You can declare any Maven/Ivy/file repository here. 18 | jcenter() 19 | } 20 | 21 | // In this section you declare the dependencies for your production and test code 22 | dependencies { 23 | // The production code uses the SLF4J logging API at compile time 24 | compile 'org.slf4j:slf4j-api:1.7.12' 25 | 26 | // Declare the dependency for your favourite test framework you want to use in your tests. 27 | // TestNG is also supported by the Gradle Test task. Just change the 28 | // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add 29 | // 'test.useTestNG()' to your build script. 30 | testCompile 'junit:junit:4.12' 31 | } 32 | */ 33 | 34 | 35 | apply plugin: "fr.echoes.gradle.cpp" 36 | 37 | println configurations 38 | configurations { 39 | cOnArchives { 40 | extendsFrom cArchives 41 | } 42 | } 43 | 44 | task launchCMake(type: Exec, group: "init") { 45 | 46 | workingDir = "build" 47 | executable = "cmake" 48 | if (optionDone) { 49 | println "option = $optionDone" 50 | args "-DMyOption:BOOL=ON", ".." 51 | } else { 52 | args ".." 53 | } 54 | } 55 | 56 | ///////////// only for the example ///////////// 57 | // just for the demo to facilicate update modulesS 58 | task copyModules(type: Copy) { 59 | def modules = file('../../../modules/cmake_modules') 60 | if (! modules.exists()) { 61 | throw new RuntimeException("modules path ${modules} is wrong") 62 | } 63 | from modules 64 | into "$rootDir/cmake_modules" 65 | } 66 | launchCMake.dependsOn copyModules 67 | ///////////////////////////////////////// 68 | 69 | 70 | 71 | compileCpp.dependsOn launchCMake 72 | 73 | cpp { 74 | applicationType = "clibrary" 75 | exec.with { 76 | execPath = 'echo' 77 | compileCppExecPath = 'make' 78 | compileCppExecWorkingDir = "build" 79 | testCppExecPath = "make" 80 | testCppBaseArgs = "test" 81 | testCppExecWorkingDir = "$buildDir" 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-library/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tocea/gradle-cpp-plugin/8aa0129d9ac38ca922ba7e439f03442c74e81341/exemples/hello-world-multi-modules/hello-library/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-library/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Oct 06 16:43:08 CEST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip 7 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-library/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-library/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-library/src/main/cpp/hello/Speaker.cpp: -------------------------------------------------------------------------------- 1 | #include "hello/Speaker.hpp" 2 | 3 | using namespace Hello; 4 | using namespace std; 5 | 6 | namespace Hello { 7 | 8 | string Speaker::sayHello() { 9 | return "Hello, world!\n"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-library/src/main/headers/hello/Speaker.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | namespace Hello { 7 | 8 | class Speaker { 9 | 10 | public: 11 | string sayHello(); 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-library/src/test/cpp/hello/SpeakerTest.cpp: -------------------------------------------------------------------------------- 1 | // ? #include "stdafx.h" 2 | 3 | #include "hello/SpeakerTest.hpp" 4 | 5 | using namespace Hello; 6 | // Registers the fixture into the 'registry' 7 | CPPUNIT_TEST_SUITE_REGISTRATION( SpeakerTest ); 8 | 9 | 10 | void 11 | SpeakerTest::setUp() 12 | { 13 | } 14 | 15 | 16 | void 17 | SpeakerTest::tearDown() 18 | { 19 | } 20 | 21 | 22 | void 23 | SpeakerTest::testSayHello() 24 | { 25 | // // Given a speaker 26 | Speaker* speaker = new Speaker(); 27 | 28 | 29 | // when the speaker say hello. 30 | string sentence = speaker->sayHello(); 31 | 32 | // then he must say 'hello world: 33 | string expected = "Hello, world!\n"; 34 | CPPUNIT_ASSERT_EQUAL( expected, sentence ); 35 | } 36 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-library/src/test/cpp/run_tests.cpp: -------------------------------------------------------------------------------- 1 | // ? #include "stdafx.h" 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | // Get the top level suite from the registry 10 | CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); 11 | 12 | // Adds the test to the list of test to run 13 | CppUnit::TextUi::TestRunner runner; 14 | runner.addTest( suite ); 15 | 16 | // Change the default outputter to a compiler error format outputter 17 | runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), 18 | std::cerr ) ); 19 | // Run the tests. 20 | bool wasSucessful = runner.run(); 21 | 22 | // Return error code 1 if the one of test failed. 23 | return wasSucessful ? 0 : 1; 24 | } 25 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-library/src/test/headers/hello/SpeakerTest.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef SPEAKERTEST_H 3 | #define SPEAKERTEST_H 4 | 5 | #include 6 | #include "hello/Speaker.hpp" 7 | 8 | class SpeakerTest : public CppUnit::TestFixture 9 | { 10 | CPPUNIT_TEST_SUITE( SpeakerTest ); 11 | CPPUNIT_TEST( testSayHello ); 12 | CPPUNIT_TEST_SUITE_END(); 13 | 14 | public: 15 | void setUp(); 16 | void tearDown(); 17 | 18 | void testSayHello(); 19 | }; 20 | 21 | #endif // MONEYTEST_H 22 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8) 2 | project (hello-main) 3 | 4 | 5 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake_modules/") 6 | include(gradle-cpp) 7 | #include(gradle-cpp-cppUnitTest) 8 | 9 | # read version of the project in the gradle.propersties file 10 | get_property_value(${CMAKE_SOURCE_DIR}/../gradle.properties "version" VERSION) 11 | 12 | SET(PROJECT_NAME "hello-main-${VERSION}") 13 | 14 | 15 | add_executable(${PROJECT_NAME} ${SOURCES}) 16 | 17 | target_link_libraries(${PROJECT_NAME} ${STATIC_LIBRARIES}) 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-main/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This build file was auto generated by running the Gradle 'init' task 3 | * by 'jguidoux' at '23/09/15 13:35' with Gradle 2.4 4 | * 5 | * This generated file contains a commented-out sample Java project to get you started. 6 | * For more details take a look at the Java Quickstart chapter in the Gradle 7 | * user guide available at http://gradle.org/docs/2.4/userguide/tutorial_java_projects.html 8 | */ 9 | 10 | /* 11 | // Apply the java plugin to add support for Java 12 | apply plugin: 'java' 13 | 14 | // In this section you declare where to find the dependencies of your project 15 | repositories { 16 | // Use 'jcenter' for resolving your dependencies. 17 | // You can declare any Maven/Ivy/file repository here. 18 | jcenter() 19 | } 20 | 21 | // In this section you declare the dependencies for your production and test code 22 | dependencies { 23 | // The production code uses the SLF4J logging API at compile time 24 | compile 'org.slf4j:slf4j-api:1.7.12' 25 | 26 | // Declare the dependency for your favourite test framework you want to use in your tests. 27 | // TestNG is also supported by the Gradle Test task. Just change the 28 | // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add 29 | // 'test.useTestNG()' to your build script. 30 | testCompile 'junit:junit:4.12' 31 | } 32 | */ 33 | 34 | 35 | apply plugin: "fr.echoes.gradle.cpp" 36 | 37 | 38 | repositories { 39 | mavenLocal() 40 | } 41 | 42 | dependencies { 43 | compile project(path: ":hello-library", configuration: "cArchives") 44 | } 45 | 46 | 47 | task launchCMake(type: Exec, group: "init") { 48 | 49 | workingDir "$buildDir" 50 | executable "cmake" 51 | args ".." 52 | } 53 | 54 | 55 | ///////////// only for the example ///////////// 56 | // just for the demo to facilicate update modulesS 57 | task copyModules(type: Copy) { 58 | def modules = file('../../../modules/cmake_modules') 59 | if (! modules.exists()) { 60 | throw new RuntimeException("modules path ${modules} is wrong") 61 | } 62 | from modules 63 | into "$rootDir/cmake_modules" 64 | } 65 | launchCMake.dependsOn copyModules 66 | ///////////////////////////////////////// 67 | 68 | 69 | compileCpp.dependsOn launchCMake 70 | 71 | 72 | cpp { 73 | applicationType = "capplication" 74 | exec.with { 75 | execPath = 'echo' 76 | compileCppExecPath = 'make' 77 | compileCppExecWorkingDir = "$buildDir" 78 | } 79 | } 80 | 81 | task run(type: Exec, dependsOn: build) { 82 | workingDir "$buildDir/tmp/bin" 83 | executable "./${project.name}-$version" 84 | } -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-main/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tocea/gradle-cpp-plugin/8aa0129d9ac38ca922ba7e439f03442c74e81341/exemples/hello-world-multi-modules/hello-main/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-main/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Oct 06 16:57:50 CEST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip 7 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-main/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-main/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/hello-main/src/main/cpp/main/HelloWorld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | using namespace Hello; 5 | 6 | int main(int argc, char *argv[]) { 7 | Speaker* speaker = new Speaker(); 8 | 9 | cout << speaker->sayHello(); 10 | } 11 | -------------------------------------------------------------------------------- /exemples/hello-world-multi-modules/settings.gradle: -------------------------------------------------------------------------------- 1 | 2 | include 'hello-library' 3 | include 'hello-main' 4 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/.CMakeLists.txt.kate-swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tocea/gradle-cpp-plugin/8aa0129d9ac38ca922ba7e439f03442c74e81341/exemples/hello-world-with-libraries/.CMakeLists.txt.kate-swp -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | cmake_install.cmake 4 | **/CMakeFiles/ 5 | **/cmake_install.cmake 6 | Makefile 7 | CMakeHelloWorld 8 | *.a 9 | **/*.a 10 | build/** 11 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) <2013> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/README.md: -------------------------------------------------------------------------------- 1 | This is an extremely simple example C++ application which uses CMake. 2 | It will build and install an application called CMakeHelloWorld which simply outputs "Hello, world!" to stdout. 3 | 4 | ### Installation ### 5 | As this is an example of how to use CMake you'll need to download it (http://www.cmake.org/cmake/resources/software.html) or install it via: 6 | ```bash 7 | sudo apt-get install cmake 8 | ``` 9 | Once CMake has been install navigate to the root of the project and issue the following commands: 10 | ```bash 11 | mkdir build 12 | cd build 13 | cmake .. && make 14 | make install 15 | ``` 16 | You may need to use`sudo make install` command as it will install to /usr/local/bin . This might be a good opportunity to investigate stow (http://www.gnu.org/software/stow/manual/stow.html) as a means of managing the installation of applications in this manner, however I haven't gotten far enough into my CMake knowledge to take that step. 17 | 18 | ### Usage ### 19 | Once the executable has been created simply call `CMakeHelloWorld`, either from the build directory or anywhere (if you installed to /usr/local/bin, etc). 20 | 21 | ***Uninstallation*** 22 | Removing the application is straight-forward. Simply delete the binary 'CMakeHelloWorld' from /usr/local/bin. 23 | 24 | 25 | ***Caution*** 26 | I am a complete C++ noob. I've created this project as part of an effort to kickstart my C++ recovery as I have recently been placed on a team which is developing an embedded application. There may be any number of things wrong with this example. If you see something you know to be implemented incorrectly please contact me via github and I will do my best to correct it. Better, fork the project, fix it and issue a pull request. 27 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8) 2 | project (hello-library) 3 | 4 | 5 | 6 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") 7 | 8 | include(gradle-cpp) 9 | include(gradle-cpp-cppUnitTest) 10 | 11 | # read version of the project in the gradle.propersties file 12 | get_property_value(${CMAKE_SOURCE_DIR}/gradle.properties "version" VERSION) 13 | MESSAGE("VERSION = ${VERSION}bb") 14 | SET(PROJECT_NAME "hello-${VERSION}") 15 | SET(PROJECT_STATICNAME "hello_static-${VERSION}") 16 | 17 | 18 | 19 | ####################################" 20 | add_library ( 21 | ${PROJECT_STATICNAME} 22 | STATIC 23 | ${SOURCES} 24 | ) 25 | ####################################" 26 | add_library ( 27 | ${PROJECT_NAME} 28 | SHARED 29 | ${SOURCES} 30 | ) 31 | 32 | 33 | # LINK LIBRARIES 34 | 35 | target_link_libraries( ${PROJECT_STATICNAME} ${STATIC_LIBRARIES} ) 36 | target_link_libraries( ${PROJECT_NAME} ${STATIC_LIBRARIES} ) 37 | 38 | 39 | # Add own output directory to library dir 40 | LIST(APPEND CMAKE_PREFIX_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) 41 | 42 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This build file was auto generated by running the Gradle 'init' task 3 | * by 'jguidoux' at '23/09/15 13:12' with Gradle 2.4 4 | * 5 | * This generated file contains a commented-out sample Java project to get you started. 6 | * For more details take a look at the Java Quickstart chapter in the Gradle 7 | * user guide available at http://gradle.org/docs/2.4/userguide/tutorial_java_projects.html 8 | */ 9 | 10 | /* 11 | // Apply the java plugin to add support for Java 12 | apply plugin: 'java' 13 | 14 | // In this section you declare where to find the dependencies of your project 15 | repositories { 16 | // Use 'jcenter' for resolving your dependencies. 17 | // You can declare any Maven/Ivy/file repository here. 18 | jcenter() 19 | } 20 | 21 | // In this section you declare the dependencies for your production and test code 22 | dependencies { 23 | // The production code uses the SLF4J logging API at compile time 24 | compile 'org.slf4j:slf4j-api:1.7.12' 25 | 26 | // Declare the dependency for your favourite test framework you want to use in your tests. 27 | // TestNG is also supported by the Gradle Test task. Just change the 28 | // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add 29 | // 'test.useTestNG()' to your build script. 30 | testCompile 'junit:junit:4.12' 31 | } 32 | */ 33 | 34 | buildscript { 35 | apply from: '../../version.gradle' 36 | 37 | repositories { 38 | mavenLocal() 39 | jcenter() 40 | } 41 | dependencies { 42 | classpath "fr.echoes.gradle.plugins:cpp-project-plugin:${cppPluginVersion('../../../gradle.properties')}" 43 | } 44 | } 45 | 46 | apply plugin: "fr.echoes.gradle.cpp" 47 | 48 | task launchCMake(type: Exec, group: "init") { 49 | 50 | workingDir = "build" 51 | executable = "cmake" 52 | args ".." 53 | } 54 | 55 | 56 | ///////////// only for the example ///////////// 57 | // just for the demo to facilicate update modulesS 58 | task copyModules(type: Copy) { 59 | def modules = file('../../../modules/cmake_modules') 60 | if (! modules.exists()) { 61 | throw new RuntimeException("modules path ${modules} is wrong") 62 | } 63 | from modules 64 | into "cmake_modules" 65 | } 66 | launchCMake.dependsOn copyModules 67 | ///////////////////////////////////////// 68 | 69 | 70 | 71 | compileCpp.dependsOn launchCMake 72 | 73 | cpp { 74 | applicationType = "clibrary" 75 | exec.with { 76 | execPath = 'echo' 77 | compileCppExecPath = 'make' 78 | compileCppExecWorkingDir = "build" 79 | testCppExecPath = "make" 80 | testCppBaseArgs = "test" 81 | testCppExecWorkingDir = "build" 82 | } 83 | } 84 | 85 | task wrapper(type: Wrapper) { 86 | gradleVersion = '2.7' 87 | } 88 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/cmake_modules/FindCPPUNIT.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Find the CppUnit includes and library 3 | # 4 | # This module defines 5 | # CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc. 6 | # CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit. 7 | # CPPUNIT_FOUND, If false, do not try to use CppUnit. 8 | 9 | # also defined, but not for general use are 10 | # CPPUNIT_LIBRARY, where to find the CppUnit library. 11 | # CPPUNIT_DEBUG_LIBRARY, where to find the CppUnit library in debug 12 | # mode. 13 | 14 | SET(CPPUNIT_FOUND "NO") 15 | 16 | FIND_PATH(CPPUNIT_INCLUDE_DIR cppunit/TestCase.h /usr/local/include /usr/include) 17 | 18 | # With Win32, important to have both 19 | IF(WIN32) 20 | FIND_LIBRARY(CPPUNIT_LIBRARY cppunit 21 | ${CPPUNIT_INCLUDE_DIR}/../lib 22 | /usr/local/lib 23 | /usr/lib) 24 | FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunitd 25 | ${CPPUNIT_INCLUDE_DIR}/../lib 26 | /usr/local/lib 27 | /usr/lib) 28 | ELSE(WIN32) 29 | # On unix system, debug and release have the same name 30 | FIND_LIBRARY(CPPUNIT_LIBRARY cppunit 31 | ${CPPUNIT_INCLUDE_DIR}/../lib 32 | /usr/local/lib 33 | /usr/lib) 34 | FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunit 35 | ${CPPUNIT_INCLUDE_DIR}/../lib 36 | /usr/local/lib 37 | /usr/lib) 38 | ENDIF(WIN32) 39 | 40 | IF(CPPUNIT_INCLUDE_DIR) 41 | IF(CPPUNIT_LIBRARY) 42 | SET(CPPUNIT_FOUND "YES") 43 | SET(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY} ${CMAKE_DL_LIBS}) 44 | SET(CPPUNIT_DEBUG_LIBRARIES ${CPPUNIT_DEBUG_LIBRARY} ${CMAKE_DL_LIBS}) 45 | ELSE (CPPUNIT_LIBRARY) 46 | IF (CPPUNIT_FIND_REQUIRED) 47 | MESSAGE(SEND_ERROR "Could not find library CppUnit.") 48 | ENDIF (CPPUNIT_FIND_REQUIRED) 49 | ENDIF(CPPUNIT_LIBRARY) 50 | ELSE(CPPUNIT_INCLUDE_DIR) 51 | IF (CPPUNIT_FIND_REQUIRED) 52 | MESSAGE(SEND_ERROR "Could not find library CppUnit.") 53 | ENDIF(CPPUNIT_FIND_REQUIRED) 54 | ENDIF(CPPUNIT_INCLUDE_DIR) 55 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/cmake_modules/gradle-cpp-cppUnitTest.cmake: -------------------------------------------------------------------------------- 1 | 2 | SET(TEST_SRC ${PROJECT_SOURCE_DIR}/src/test/cpp) 3 | SET(TEST_HEADERS ${PROJECT_SOURCE_DIR}/src/test/headers) 4 | file(GLOB_RECURSE TEST_SOURCES ${TEST_SRC}/*.cpp) 5 | 6 | # ------------------------- 7 | 8 | # Usefull to get CPPUNIT ... 9 | # I would love to find a way to have cppunit 10 | # only required for builds where unit test make sense ... 11 | #set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") 12 | FIND_PACKAGE(CPPUNIT REQUIRED) 13 | 14 | ##################### tests ################## 15 | 16 | enable_testing() 17 | 18 | 19 | #set(TMP_VAR ${EXECUTABLE_OUTPUT_PATH}) 20 | #set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build/test-obj) 21 | include_directories(${TEST_HEADERS}) 22 | 23 | 24 | add_executable(launchTest ${SOURCES} ${TEST_SOURCES}) 25 | target_link_libraries(launchTest cppunit ${STATIC_LIBRARIES}) 26 | add_test(NAME aTest COMMAND launchTest) 27 | 28 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/cmake_modules/gradle-cpp.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Main useful constants 3 | SET(MAIN_SRC ${PROJECT_SOURCE_DIR}/src/main/cpp) 4 | SET(MAIN_HEADERS ${PROJECT_SOURCE_DIR}/src/main/headers) 5 | 6 | 7 | set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build) 8 | 9 | 10 | # Default output directories 11 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tmp/bin) 12 | set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tmp/lib) 13 | file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) 14 | file(MAKE_DIRECTORY ${LIBRARY_OUTPUT_PATH}) 15 | FILE(GLOB_RECURSE SOURCES ${MAIN_SRC}/*.cpp) 16 | 17 | 18 | ## Default include directories 19 | 20 | include_directories(${MAIN_HEADERS}) 21 | include_directories(${MAIN_SRC}) 22 | 23 | 24 | # Variables de compilation (et valeurs par défaut) 25 | if(NOT DEFINED LIBRARY_TYPE) # STATIC 26 | SET(LIBRARY_TYPE "SHARED") # STATIC|MODULE|SHARED 27 | endif() 28 | if(NOT DEFINED VERSION) 29 | SET(VERSION "1.0-SNAPSHOT") 30 | endif() 31 | 32 | 33 | if(DEFINED VERSION) 34 | SET(SOVERSION ${VERSION}) 35 | endif() 36 | 37 | if(NOT DEFINED LIB_READLINE) 38 | SET(LIB_READLINE "no") 39 | endif() 40 | if(NOT DEFINED LIB_ICONV) 41 | SET(LIB_ICONV "yes") 42 | endif() 43 | if(NOT DEFINED LIB_GETTEXT) 44 | SET(LIB_GETTEXT "yes") 45 | endif() 46 | if(NOT DEFINED LIB_DL) 47 | SET(LIB_DL "no") 48 | endif() 49 | 50 | # DEFAULT FLAGS 51 | if(NOT DEFINED FLAGS) 52 | # for gcc > 4.9 53 | #SET(FLAGS "-fdiagnostics-color=always") 54 | endif() 55 | 56 | # Initialisation specifique OS 57 | #---------------------------------------------------------- 58 | if( ${CMAKE_SYSTEM_NAME} MATCHES Linux) 59 | LIST(APPEND REQUIRED_LIBS "resolv") 60 | SET(FLAGS "${FLAGS} -DLINUX") 61 | endif() 62 | 63 | if( ${CMAKE_SYSTEM_NAME} MATCHES Linux) 64 | SET( LIB_GETTEXT "yes") 65 | SET( LIB_ICONV "yes") 66 | elseif( ${CMAKE_SYSTEM_NAME} MATCHES Windows ) 67 | SET( LIB_GETTEXT "no") 68 | SET( LIB_ICONV "no") 69 | endif() 70 | 71 | 72 | 73 | 74 | # Triggers des options 75 | #-------------------------------------------------------- 76 | 77 | 78 | # Triggers simples 79 | 80 | if ( ${LIB_READLINE}) 81 | SET(LIB_DL "yes") 82 | SET(FLAGS "${FLAGS} -DREADLINE") 83 | endif() 84 | 85 | if ( ${LIB_GETTEXT} ) 86 | SET(FLAGS "${FLAGS} -DGETTEXT") 87 | #SI AIX -lintl 88 | endif() 89 | 90 | if ( ${LIB_ICONV} ) 91 | SET(FLAGS "${FLAGS} -DICONV") 92 | #SI AIX -liconv 93 | #SI SUNOS -liconv 94 | endif() 95 | 96 | # Triggers complexes 97 | 98 | 99 | if( NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows AND ${LIB_DL} MATCHES "yes") 100 | LIST(APPEND REQUIRED_LIBS "dl") 101 | endif() 102 | 103 | 104 | set(CUSTOM_LIBRARY_PATH ${CMAKE_BINARY_DIR}/extLib) 105 | MESSAGE( STATUS "CUSTOM LIBRARY PATH : ${CUSTOM_LIBRARY_PATH}" ) 106 | file(MAKE_DIRECTORY ${CUSTOM_LIBRARY_PATH}) 107 | 108 | 109 | file(GLOB sub-dir ${CUSTOM_LIBRARY_PATH}/*) 110 | foreach(dir ${sub-dir}) 111 | if(IS_DIRECTORY ${dir}) 112 | set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}:${dir}) 113 | endif() 114 | endforeach() 115 | 116 | # to find libraries 117 | file( GLOB LIB_HEADERS ${CUSTOM_LIBRARY_PATH}/*/headers ) 118 | file( GLOB STATIC_LIBRARIES ${CUSTOM_LIBRARY_PATH}/*/lib/*.a ) 119 | 120 | 121 | ## Default include headers libraries 122 | include_directories(${LIB_HEADERS}) 123 | 124 | 125 | #------------------------------------------------------------------------------------------------------------ 126 | # CREATION DU PROFIL DE COMPILATION 127 | 128 | SET(MULTITHREAD_FLAGS "-DRENT -D_THREAD_SAFE -L/usr/lib/threads -L/usr/lib/dce -lpthread -DMULTITHREAD -pthread ") 129 | 130 | # Profiles de compilation -DCMAKE_BUILD_TYPE= 131 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-strict-overflow ${FLAGS}") 132 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-strict-overflow ${FLAGS}") 133 | 134 | #-------------------------------------------------------- 135 | # PROFIL Release 136 | SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3" ${CMAKE_CXX_FLAGS}) 137 | SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3" ${CMAKE_C_FLAGS}) 138 | 139 | 140 | #-------------------------------------------------------- 141 | # PROFIL Debug 142 | SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -ggdb -g3 ${CMAKE_CXX_FLAGS}") 143 | SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -ggdb -g3 ${CMAKE_C_FLAGS}") 144 | 145 | 146 | ######################## additives functions ########################$ 147 | 148 | #thi function read propersties form a propersties file. 149 | # a preperties file look like that : 150 | # key#1 = valeur1 151 | # key2 = valeur2 152 | # … 153 | # this function return the value associate to a key 154 | function(get_property_value FilePath Key ResultValue) 155 | 156 | 157 | file(READ ${FilePath} Contents) 158 | # Set the variable "Esc" to the ASCII value 27 - basically something 159 | # which is unlikely to conflict with anything in the file contents. 160 | string(ASCII 27 Esc) 161 | 162 | # Turn the contents into a list of strings, each ending with an Esc. 163 | # This allows us to preserve blank lines in the file since CMake 164 | # automatically prunes empty list items during a foreach loop. 165 | string(REGEX REPLACE "\n" "${Esc};" ContentsAsList ${Contents}) 166 | 167 | 168 | 169 | unset(ModifiedContents) 170 | foreach(Line ${ContentsAsList}) 171 | message("Line = ${Line}") 172 | #STRING(REGEX MATCH "${Key}[ ]*=[ ]*.*" Value ${Line}) 173 | #message("temp value=${Value}") 174 | if("${Line}" MATCHES "${Key}[ ]*=[ ]*.*") 175 | string(REGEX REPLACE "${Key}[ ]*=[ ]*" "" Value ${Line}) 176 | endif() 177 | 178 | endforeach() 179 | string(REGEX REPLACE "${Esc}" "" Value ${Value}) 180 | SET(${ResultValue} ${Value} PARENT_SCOPE) 181 | endfunction() 182 | 183 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/gradle.properties: -------------------------------------------------------------------------------- 1 | group=fr.echoes.example 2 | version=1.0.0-SNAPSHOT -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tocea/gradle-cpp-plugin/8aa0129d9ac38ca922ba7e439f03442c74e81341/exemples/hello-world-with-libraries/hello-library/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Oct 06 16:52:05 CEST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip 7 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/src/main/cpp/hello/Speaker.cpp: -------------------------------------------------------------------------------- 1 | #include "hello/Speaker.hpp" 2 | 3 | using namespace Hello; 4 | using namespace std; 5 | 6 | namespace Hello { 7 | 8 | string Speaker::sayHello() { 9 | return "Hello, world!\n"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/src/main/headers/hello/Speaker.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | namespace Hello { 7 | 8 | class Speaker { 9 | 10 | public: 11 | string sayHello(); 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/src/test/cpp/hello/SpeakerTest.cpp: -------------------------------------------------------------------------------- 1 | // ? #include "stdafx.h" 2 | 3 | #include "hello/SpeakerTest.hpp" 4 | 5 | using namespace Hello; 6 | // Registers the fixture into the 'registry' 7 | CPPUNIT_TEST_SUITE_REGISTRATION( SpeakerTest ); 8 | 9 | 10 | void 11 | SpeakerTest::setUp() 12 | { 13 | } 14 | 15 | 16 | void 17 | SpeakerTest::tearDown() 18 | { 19 | } 20 | 21 | 22 | void 23 | SpeakerTest::testSayHello() 24 | { 25 | // // Given a speaker 26 | Speaker* speaker = new Speaker(); 27 | 28 | 29 | // when the speaker say hello. 30 | string sentence = speaker->sayHello(); 31 | 32 | // then he must say 'hello world: 33 | string expected = "Hello, world!\n"; 34 | CPPUNIT_ASSERT_EQUAL( expected, sentence ); 35 | } 36 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/src/test/cpp/run_tests.cpp: -------------------------------------------------------------------------------- 1 | // ? #include "stdafx.h" 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | int main(int argc, char* argv[]) 8 | { 9 | // Get the top level suite from the registry 10 | CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); 11 | 12 | // Adds the test to the list of test to run 13 | CppUnit::TextUi::TestRunner runner; 14 | runner.addTest( suite ); 15 | 16 | // Change the default outputter to a compiler error format outputter 17 | runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), 18 | std::cerr ) ); 19 | // Run the tests. 20 | bool wasSucessful = runner.run(); 21 | 22 | // Return error code 1 if the one of test failed. 23 | return wasSucessful ? 0 : 1; 24 | } 25 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-library/src/test/headers/hello/SpeakerTest.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef SPEAKERTEST_H 3 | #define SPEAKERTEST_H 4 | 5 | #include 6 | #include "hello/Speaker.hpp" 7 | 8 | class SpeakerTest : public CppUnit::TestFixture 9 | { 10 | CPPUNIT_TEST_SUITE( SpeakerTest ); 11 | CPPUNIT_TEST( testSayHello ); 12 | CPPUNIT_TEST_SUITE_END(); 13 | 14 | public: 15 | void setUp(); 16 | void tearDown(); 17 | 18 | void testSayHello(); 19 | }; 20 | 21 | #endif // MONEYTEST_H 22 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8) 2 | project (hello-main) 3 | 4 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") 5 | include(gradle-cpp) 6 | #include(gradle-cpp-cppUnitTest) 7 | 8 | 9 | # read version of the project in the gradle.propersties file 10 | get_property_value(${CMAKE_SOURCE_DIR}/gradle.properties "version" VERSION) 11 | 12 | SET(PROJECT_NAME "hello-main-${VERSION}") 13 | 14 | 15 | add_executable(${PROJECT_NAME} ${SOURCES}) 16 | 17 | target_link_libraries(${PROJECT_NAME} ${STATIC_LIBRARIES}) 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-main/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This build file was auto generated by running the Gradle 'init' task 3 | * by 'jguidoux' at '23/09/15 13:35' with Gradle 2.4 4 | * 5 | * This generated file contains a commented-out sample Java project to get you started. 6 | * For more details take a look at the Java Quickstart chapter in the Gradle 7 | * user guide available at http://gradle.org/docs/2.4/userguide/tutorial_java_projects.html 8 | */ 9 | 10 | /* 11 | // Apply the java plugin to add support for Java 12 | apply plugin: 'java' 13 | 14 | // In this section you declare where to find the dependencies of your project 15 | repositories { 16 | // Use 'jcenter' for resolving your dependencies. 17 | // You can declare any Maven/Ivy/file repository here. 18 | jcenter() 19 | } 20 | 21 | // In this section you declare the dependencies for your production and test code 22 | dependencies { 23 | // The production code uses the SLF4J logging API at compile time 24 | compile 'org.slf4j:slf4j-api:1.7.12' 25 | 26 | // Declare the dependency for your favourite test framework you want to use in your tests. 27 | // TestNG is also supported by the Gradle Test task. Just change the 28 | // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add 29 | // 'test.useTestNG()' to your build script. 30 | testCompile 'junit:junit:4.12' 31 | } 32 | */ 33 | 34 | buildscript { 35 | apply from: '../../version.gradle' 36 | 37 | repositories { 38 | mavenLocal() 39 | jcenter() 40 | } 41 | dependencies { 42 | classpath "fr.echoes.gradle.plugins:cpp-project-plugin:${cppPluginVersion('../../../gradle.properties')}" 43 | } 44 | } 45 | 46 | apply plugin: "fr.echoes.gradle.cpp" 47 | 48 | 49 | repositories { 50 | mavenLocal() 51 | } 52 | 53 | dependencies { 54 | compile "fr.echoes.example:hello-library:1.0.0-SNAPSHOT@clib" 55 | } 56 | 57 | 58 | task launchCMake(type: Exec, group: "init") { 59 | 60 | workingDir "$buildDir" 61 | executable "cmake" 62 | args ".." 63 | } 64 | 65 | ///////////// only for the example ///////////// 66 | // just for the demo to facilicate update modulesS 67 | task copyModules(type: Copy) { 68 | def modules = file('../../../modules/cmake_modules') 69 | if (! modules.exists()) { 70 | throw new RuntimeException("modules path ${modules} is wrong") 71 | } 72 | from modules 73 | into "cmake_modules" 74 | } 75 | launchCMake.dependsOn copyModules 76 | ///////////////////////////////////////// 77 | 78 | compileCpp.dependsOn launchCMake 79 | 80 | 81 | cpp { 82 | applicationType = "capplication" 83 | exec.with { 84 | execPath = 'echo' 85 | compileCppExecPath = 'make' 86 | compileCppExecWorkingDir = "$buildDir" 87 | } 88 | } 89 | 90 | task run(type: Exec, dependsOn: build) { 91 | workingDir "$buildDir/tmp/bin" 92 | executable "./${project.name}-$version" 93 | } 94 | 95 | 96 | 97 | task wrapper(type: Wrapper) { 98 | gradleVersion = '2.7' 99 | } -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-main/cmake_modules/FindCPPUNIT.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Find the CppUnit includes and library 3 | # 4 | # This module defines 5 | # CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc. 6 | # CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit. 7 | # CPPUNIT_FOUND, If false, do not try to use CppUnit. 8 | 9 | # also defined, but not for general use are 10 | # CPPUNIT_LIBRARY, where to find the CppUnit library. 11 | # CPPUNIT_DEBUG_LIBRARY, where to find the CppUnit library in debug 12 | # mode. 13 | 14 | SET(CPPUNIT_FOUND "NO") 15 | 16 | FIND_PATH(CPPUNIT_INCLUDE_DIR cppunit/TestCase.h /usr/local/include /usr/include) 17 | 18 | # With Win32, important to have both 19 | IF(WIN32) 20 | FIND_LIBRARY(CPPUNIT_LIBRARY cppunit 21 | ${CPPUNIT_INCLUDE_DIR}/../lib 22 | /usr/local/lib 23 | /usr/lib) 24 | FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunitd 25 | ${CPPUNIT_INCLUDE_DIR}/../lib 26 | /usr/local/lib 27 | /usr/lib) 28 | ELSE(WIN32) 29 | # On unix system, debug and release have the same name 30 | FIND_LIBRARY(CPPUNIT_LIBRARY cppunit 31 | ${CPPUNIT_INCLUDE_DIR}/../lib 32 | /usr/local/lib 33 | /usr/lib) 34 | FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunit 35 | ${CPPUNIT_INCLUDE_DIR}/../lib 36 | /usr/local/lib 37 | /usr/lib) 38 | ENDIF(WIN32) 39 | 40 | IF(CPPUNIT_INCLUDE_DIR) 41 | IF(CPPUNIT_LIBRARY) 42 | SET(CPPUNIT_FOUND "YES") 43 | SET(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY} ${CMAKE_DL_LIBS}) 44 | SET(CPPUNIT_DEBUG_LIBRARIES ${CPPUNIT_DEBUG_LIBRARY} ${CMAKE_DL_LIBS}) 45 | ELSE (CPPUNIT_LIBRARY) 46 | IF (CPPUNIT_FIND_REQUIRED) 47 | MESSAGE(SEND_ERROR "Could not find library CppUnit.") 48 | ENDIF (CPPUNIT_FIND_REQUIRED) 49 | ENDIF(CPPUNIT_LIBRARY) 50 | ELSE(CPPUNIT_INCLUDE_DIR) 51 | IF (CPPUNIT_FIND_REQUIRED) 52 | MESSAGE(SEND_ERROR "Could not find library CppUnit.") 53 | ENDIF(CPPUNIT_FIND_REQUIRED) 54 | ENDIF(CPPUNIT_INCLUDE_DIR) 55 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-main/cmake_modules/gradle-cpp-cppUnitTest.cmake: -------------------------------------------------------------------------------- 1 | 2 | SET(TEST_SRC ${PROJECT_SOURCE_DIR}/src/test/cpp) 3 | SET(TEST_HEADERS ${PROJECT_SOURCE_DIR}/src/test/headers) 4 | file(GLOB_RECURSE TEST_SOURCES ${TEST_SRC}/*.cpp) 5 | 6 | # ------------------------- 7 | 8 | # Usefull to get CPPUNIT ... 9 | # I would love to find a way to have cppunit 10 | # only required for builds where unit test make sense ... 11 | #set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") 12 | FIND_PACKAGE(CPPUNIT REQUIRED) 13 | 14 | ##################### tests ################## 15 | 16 | enable_testing() 17 | 18 | 19 | #set(TMP_VAR ${EXECUTABLE_OUTPUT_PATH}) 20 | #set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build/test-obj) 21 | include_directories(${TEST_HEADERS}) 22 | 23 | 24 | add_executable(launchTest ${SOURCES} ${TEST_SOURCES}) 25 | target_link_libraries(launchTest cppunit ${STATIC_LIBRARIES}) 26 | add_test(NAME aTest COMMAND launchTest) 27 | 28 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-main/cmake_modules/gradle-cpp.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Main useful constants 3 | SET(MAIN_SRC ${PROJECT_SOURCE_DIR}/src/main/cpp) 4 | SET(MAIN_HEADERS ${PROJECT_SOURCE_DIR}/src/main/headers) 5 | 6 | 7 | set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build) 8 | 9 | 10 | # Default output directories 11 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tmp/bin) 12 | set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tmp/lib) 13 | file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) 14 | file(MAKE_DIRECTORY ${LIBRARY_OUTPUT_PATH}) 15 | FILE(GLOB_RECURSE SOURCES ${MAIN_SRC}/*.cpp) 16 | 17 | 18 | ## Default include directories 19 | 20 | include_directories(${MAIN_HEADERS}) 21 | include_directories(${MAIN_SRC}) 22 | 23 | 24 | # Variables de compilation (et valeurs par défaut) 25 | if(NOT DEFINED LIBRARY_TYPE) # STATIC 26 | SET(LIBRARY_TYPE "SHARED") # STATIC|MODULE|SHARED 27 | endif() 28 | if(NOT DEFINED VERSION) 29 | SET(VERSION "1.0-SNAPSHOT") 30 | endif() 31 | 32 | 33 | if(DEFINED VERSION) 34 | SET(SOVERSION ${VERSION}) 35 | endif() 36 | 37 | if(NOT DEFINED LIB_READLINE) 38 | SET(LIB_READLINE "no") 39 | endif() 40 | if(NOT DEFINED LIB_ICONV) 41 | SET(LIB_ICONV "yes") 42 | endif() 43 | if(NOT DEFINED LIB_GETTEXT) 44 | SET(LIB_GETTEXT "yes") 45 | endif() 46 | if(NOT DEFINED LIB_DL) 47 | SET(LIB_DL "no") 48 | endif() 49 | 50 | # DEFAULT FLAGS 51 | if(NOT DEFINED FLAGS) 52 | # for gcc > 4.9 53 | #SET(FLAGS "-fdiagnostics-color=always") 54 | endif() 55 | 56 | # Initialisation specifique OS 57 | #---------------------------------------------------------- 58 | if( ${CMAKE_SYSTEM_NAME} MATCHES Linux) 59 | LIST(APPEND REQUIRED_LIBS "resolv") 60 | SET(FLAGS "${FLAGS} -DLINUX") 61 | endif() 62 | 63 | if( ${CMAKE_SYSTEM_NAME} MATCHES Linux) 64 | SET( LIB_GETTEXT "yes") 65 | SET( LIB_ICONV "yes") 66 | elseif( ${CMAKE_SYSTEM_NAME} MATCHES Windows ) 67 | SET( LIB_GETTEXT "no") 68 | SET( LIB_ICONV "no") 69 | endif() 70 | 71 | 72 | 73 | 74 | # Triggers des options 75 | #-------------------------------------------------------- 76 | 77 | 78 | # Triggers simples 79 | 80 | if ( ${LIB_READLINE}) 81 | SET(LIB_DL "yes") 82 | SET(FLAGS "${FLAGS} -DREADLINE") 83 | endif() 84 | 85 | if ( ${LIB_GETTEXT} ) 86 | SET(FLAGS "${FLAGS} -DGETTEXT") 87 | #SI AIX -lintl 88 | endif() 89 | 90 | if ( ${LIB_ICONV} ) 91 | SET(FLAGS "${FLAGS} -DICONV") 92 | #SI AIX -liconv 93 | #SI SUNOS -liconv 94 | endif() 95 | 96 | # Triggers complexes 97 | 98 | 99 | if( NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows AND ${LIB_DL} MATCHES "yes") 100 | LIST(APPEND REQUIRED_LIBS "dl") 101 | endif() 102 | 103 | 104 | set(CUSTOM_LIBRARY_PATH ${CMAKE_BINARY_DIR}/extLib) 105 | MESSAGE( STATUS "CUSTOM LIBRARY PATH : ${CUSTOM_LIBRARY_PATH}" ) 106 | file(MAKE_DIRECTORY ${CUSTOM_LIBRARY_PATH}) 107 | 108 | 109 | file(GLOB sub-dir ${CUSTOM_LIBRARY_PATH}/*) 110 | foreach(dir ${sub-dir}) 111 | if(IS_DIRECTORY ${dir}) 112 | set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}:${dir}) 113 | endif() 114 | endforeach() 115 | 116 | # to find libraries 117 | file( GLOB LIB_HEADERS ${CUSTOM_LIBRARY_PATH}/*/headers ) 118 | file( GLOB STATIC_LIBRARIES ${CUSTOM_LIBRARY_PATH}/*/lib/*.a ) 119 | 120 | 121 | ## Default include headers libraries 122 | include_directories(${LIB_HEADERS}) 123 | 124 | 125 | #------------------------------------------------------------------------------------------------------------ 126 | # CREATION DU PROFIL DE COMPILATION 127 | 128 | SET(MULTITHREAD_FLAGS "-DRENT -D_THREAD_SAFE -L/usr/lib/threads -L/usr/lib/dce -lpthread -DMULTITHREAD -pthread ") 129 | 130 | # Profiles de compilation -DCMAKE_BUILD_TYPE= 131 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-strict-overflow ${FLAGS}") 132 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-strict-overflow ${FLAGS}") 133 | 134 | #-------------------------------------------------------- 135 | # PROFIL Release 136 | SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3" ${CMAKE_CXX_FLAGS}) 137 | SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3" ${CMAKE_C_FLAGS}) 138 | 139 | 140 | #-------------------------------------------------------- 141 | # PROFIL Debug 142 | SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -ggdb -g3 ${CMAKE_CXX_FLAGS}") 143 | SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -ggdb -g3 ${CMAKE_C_FLAGS}") 144 | 145 | 146 | ######################## additives functions ########################$ 147 | 148 | #thi function read propersties form a propersties file. 149 | # a preperties file look like that : 150 | # key#1 = valeur1 151 | # key2 = valeur2 152 | # … 153 | # this function return the value associate to a key 154 | function(get_property_value FilePath Key ResultValue) 155 | 156 | 157 | file(READ ${FilePath} Contents) 158 | # Set the variable "Esc" to the ASCII value 27 - basically something 159 | # which is unlikely to conflict with anything in the file contents. 160 | string(ASCII 27 Esc) 161 | 162 | # Turn the contents into a list of strings, each ending with an Esc. 163 | # This allows us to preserve blank lines in the file since CMake 164 | # automatically prunes empty list items during a foreach loop. 165 | string(REGEX REPLACE "\n" "${Esc};" ContentsAsList ${Contents}) 166 | 167 | 168 | 169 | unset(ModifiedContents) 170 | foreach(Line ${ContentsAsList}) 171 | message("Line = ${Line}") 172 | #STRING(REGEX MATCH "${Key}[ ]*=[ ]*.*" Value ${Line}) 173 | #message("temp value=${Value}") 174 | if("${Line}" MATCHES "${Key}[ ]*=[ ]*.*") 175 | string(REGEX REPLACE "${Key}[ ]*=[ ]*" "" Value ${Line}) 176 | endif() 177 | 178 | endforeach() 179 | string(REGEX REPLACE "${Esc}" "" Value ${Value}) 180 | SET(${ResultValue} ${Value} PARENT_SCOPE) 181 | endfunction() 182 | 183 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-main/gradle.properties: -------------------------------------------------------------------------------- 1 | group=fr.echoes.example 2 | version=1.0.0-SNAPSHOT 3 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-main/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tocea/gradle-cpp-plugin/8aa0129d9ac38ca922ba7e439f03442c74e81341/exemples/hello-world-with-libraries/hello-main/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-main/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Oct 06 16:52:14 CEST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip 7 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-main/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-main/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /exemples/hello-world-with-libraries/hello-main/src/main/cpp/main/HelloWorld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | using namespace Hello; 5 | 6 | int main(int argc, char *argv[]) { 7 | Speaker* speaker = new Speaker(); 8 | 9 | cout << speaker->sayHello(); 10 | } 11 | -------------------------------------------------------------------------------- /exemples/hello-world/.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | cmake_install.cmake 4 | **/CMakeFiles/ 5 | **/cmake_install.cmake 6 | Makefile 7 | CMakeHelloWorld 8 | *.a 9 | **/*.a 10 | build/** 11 | -------------------------------------------------------------------------------- /exemples/hello-world/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.8) 2 | project (CMakeHelloWorld) 3 | 4 | 5 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") 6 | include(gradle-cpp) 7 | 8 | 9 | 10 | 11 | # read version of the project in the gradle.propersties file 12 | get_property_value(${CMAKE_SOURCE_DIR}/gradle.properties "version" VERSION) 13 | 14 | 15 | SET(CMakeHelloWorldName "hello-world-${VERSION}") 16 | 17 | add_executable(${CMakeHelloWorldName} ${SOURCES}) 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /exemples/hello-world/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) <2013> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /exemples/hello-world/README.md: -------------------------------------------------------------------------------- 1 | This is an extremely simple example C++ application which uses CMake. 2 | It will build and install an application called CMakeHelloWorld which simply outputs "Hello, world!" to stdout. 3 | 4 | ### Installation ### 5 | As this is an example of how to use CMake you'll need to download it (http://www.cmake.org/cmake/resources/software.html) or install it via: 6 | ```bash 7 | sudo apt-get install cmake 8 | ``` 9 | Once CMake has been install navigate to the root of the project and issue the following commands: 10 | ```bash 11 | mkdir build 12 | cd build 13 | cmake .. && make 14 | make install 15 | ``` 16 | You may need to use`sudo make install` command as it will install to /usr/local/bin . This might be a good opportunity to investigate stow (http://www.gnu.org/software/stow/manual/stow.html) as a means of managing the installation of applications in this manner, however I haven't gotten far enough into my CMake knowledge to take that step. 17 | 18 | ### Usage ### 19 | Once the executable has been created simply call `CMakeHelloWorld`, either from the build directory or anywhere (if you installed to /usr/local/bin, etc). 20 | 21 | ***Uninstallation*** 22 | Removing the application is straight-forward. Simply delete the binary 'CMakeHelloWorld' from /usr/local/bin. 23 | 24 | 25 | ***Caution*** 26 | I am a complete C++ noob. I've created this project as part of an effort to kickstart my C++ recovery as I have recently been placed on a team which is developing an embedded application. There may be any number of things wrong with this example. If you see something you know to be implemented incorrectly please contact me via github and I will do my best to correct it. Better, fork the project, fix it and issue a pull request. 27 | -------------------------------------------------------------------------------- /exemples/hello-world/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This build file was auto generated by running the Gradle 'init' task 3 | * by 'jguidoux' at '23/09/15 13:35' with Gradle 2.4 4 | * 5 | * This generated file contains a commented-out sample Java project to get you started. 6 | * For more details take a look at the Java Quickstart chapter in the Gradle 7 | * user guide available at http://gradle.org/docs/2.4/userguide/tutorial_java_projects.html 8 | */ 9 | 10 | /* 11 | // Apply the java plugin to add support for Java 12 | apply plugin: 'java' 13 | 14 | // In this section you declare where to find the dependencies of your project 15 | repositories { 16 | // Use 'jcenter' for resolving your dependencies. 17 | // You can declare any Maven/Ivy/file repository here. 18 | jcenter() 19 | } 20 | 21 | // In this section you declare the dependencies for your production and test code 22 | dependencies { 23 | // The production code uses the SLF4J logging API at compile time 24 | compile 'org.slf4j:slf4j-api:1.7.12' 25 | 26 | // Declare the dependency for your favourite test framework you want to use in your tests. 27 | // TestNG is also supported by the Gradle Test task. Just change the 28 | // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add 29 | // 'test.useTestNG()' to your build script. 30 | testCompile 'junit:junit:4.12' 31 | } 32 | */ 33 | 34 | 35 | 36 | 37 | 38 | buildscript { 39 | apply from: '../version.gradle' 40 | 41 | repositories { 42 | mavenLocal() 43 | jcenter() 44 | } 45 | dependencies { 46 | classpath "fr.echoes.gradle.plugins:cpp-project-plugin:${cppPluginVersion('../../gradle.properties')}" 47 | } 48 | } 49 | 50 | apply plugin: "fr.echoes.gradle.cpp" 51 | 52 | 53 | 54 | 55 | 56 | task launchCMake(type: Exec, group: "init") { 57 | 58 | workingDir "$buildDir" 59 | executable "cmake" 60 | args ".." 61 | } 62 | 63 | ///////////// only for the example ///////////// 64 | // just for the demo to facilicate update modulesS 65 | task copyModules(type: Copy) { 66 | def modules = file('../../modules/cmake_modules') 67 | if (! modules.exists()) { 68 | throw new RuntimeException("modules path ${modules} is wrong") 69 | } 70 | from modules 71 | into "cmake_modules" 72 | } 73 | launchCMake.dependsOn copyModules 74 | ///////////////////////////////////////// 75 | 76 | compileCpp.dependsOn launchCMake 77 | 78 | 79 | cpp { 80 | applicationType = "capplication" 81 | exec.with { 82 | execPath = 'echo' 83 | compileCppExecPath = 'make' 84 | compileCppExecWorkingDir = "$buildDir" 85 | } 86 | } 87 | 88 | task run(type: Exec, dependsOn: build) { 89 | workingDir "$buildDir/tmp/bin" 90 | executable "./${project.name}-$version" 91 | } 92 | 93 | 94 | 95 | task wrapper(type: Wrapper) { 96 | gradleVersion = '2.7' 97 | } -------------------------------------------------------------------------------- /exemples/hello-world/cmake_modules/FindCPPUNIT.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Find the CppUnit includes and library 3 | # 4 | # This module defines 5 | # CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc. 6 | # CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit. 7 | # CPPUNIT_FOUND, If false, do not try to use CppUnit. 8 | 9 | # also defined, but not for general use are 10 | # CPPUNIT_LIBRARY, where to find the CppUnit library. 11 | # CPPUNIT_DEBUG_LIBRARY, where to find the CppUnit library in debug 12 | # mode. 13 | 14 | SET(CPPUNIT_FOUND "NO") 15 | 16 | FIND_PATH(CPPUNIT_INCLUDE_DIR cppunit/TestCase.h /usr/local/include /usr/include) 17 | 18 | # With Win32, important to have both 19 | IF(WIN32) 20 | FIND_LIBRARY(CPPUNIT_LIBRARY cppunit 21 | ${CPPUNIT_INCLUDE_DIR}/../lib 22 | /usr/local/lib 23 | /usr/lib) 24 | FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunitd 25 | ${CPPUNIT_INCLUDE_DIR}/../lib 26 | /usr/local/lib 27 | /usr/lib) 28 | ELSE(WIN32) 29 | # On unix system, debug and release have the same name 30 | FIND_LIBRARY(CPPUNIT_LIBRARY cppunit 31 | ${CPPUNIT_INCLUDE_DIR}/../lib 32 | /usr/local/lib 33 | /usr/lib) 34 | FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunit 35 | ${CPPUNIT_INCLUDE_DIR}/../lib 36 | /usr/local/lib 37 | /usr/lib) 38 | ENDIF(WIN32) 39 | 40 | IF(CPPUNIT_INCLUDE_DIR) 41 | IF(CPPUNIT_LIBRARY) 42 | SET(CPPUNIT_FOUND "YES") 43 | SET(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY} ${CMAKE_DL_LIBS}) 44 | SET(CPPUNIT_DEBUG_LIBRARIES ${CPPUNIT_DEBUG_LIBRARY} ${CMAKE_DL_LIBS}) 45 | ELSE (CPPUNIT_LIBRARY) 46 | IF (CPPUNIT_FIND_REQUIRED) 47 | MESSAGE(SEND_ERROR "Could not find library CppUnit.") 48 | ENDIF (CPPUNIT_FIND_REQUIRED) 49 | ENDIF(CPPUNIT_LIBRARY) 50 | ELSE(CPPUNIT_INCLUDE_DIR) 51 | IF (CPPUNIT_FIND_REQUIRED) 52 | MESSAGE(SEND_ERROR "Could not find library CppUnit.") 53 | ENDIF(CPPUNIT_FIND_REQUIRED) 54 | ENDIF(CPPUNIT_INCLUDE_DIR) 55 | -------------------------------------------------------------------------------- /exemples/hello-world/cmake_modules/gradle-cpp-cppUnitTest.cmake: -------------------------------------------------------------------------------- 1 | 2 | SET(TEST_SRC ${PROJECT_SOURCE_DIR}/src/test/cpp) 3 | SET(TEST_HEADERS ${PROJECT_SOURCE_DIR}/src/test/headers) 4 | file(GLOB_RECURSE TEST_SOURCES ${TEST_SRC}/*.cpp) 5 | 6 | # ------------------------- 7 | 8 | # Usefull to get CPPUNIT ... 9 | # I would love to find a way to have cppunit 10 | # only required for builds where unit test make sense ... 11 | #set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") 12 | FIND_PACKAGE(CPPUNIT REQUIRED) 13 | 14 | ##################### tests ################## 15 | 16 | enable_testing() 17 | 18 | 19 | #set(TMP_VAR ${EXECUTABLE_OUTPUT_PATH}) 20 | #set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build/test-obj) 21 | include_directories(${TEST_HEADERS}) 22 | 23 | 24 | add_executable(launchTest ${SOURCES} ${TEST_SOURCES}) 25 | target_link_libraries(launchTest cppunit ${STATIC_LIBRARIES}) 26 | add_test(NAME aTest COMMAND launchTest) 27 | 28 | -------------------------------------------------------------------------------- /exemples/hello-world/cmake_modules/gradle-cpp.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Main useful constants 3 | SET(MAIN_SRC ${PROJECT_SOURCE_DIR}/src/main/cpp) 4 | SET(MAIN_HEADERS ${PROJECT_SOURCE_DIR}/src/main/headers) 5 | 6 | 7 | set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build) 8 | 9 | 10 | # Default output directories 11 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tmp/bin) 12 | set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tmp/lib) 13 | file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) 14 | file(MAKE_DIRECTORY ${LIBRARY_OUTPUT_PATH}) 15 | FILE(GLOB_RECURSE SOURCES ${MAIN_SRC}/*.cpp) 16 | 17 | 18 | ## Default include directories 19 | 20 | include_directories(${MAIN_HEADERS}) 21 | include_directories(${MAIN_SRC}) 22 | 23 | 24 | # Variables de compilation (et valeurs par défaut) 25 | if(NOT DEFINED LIBRARY_TYPE) # STATIC 26 | SET(LIBRARY_TYPE "SHARED") # STATIC|MODULE|SHARED 27 | endif() 28 | if(NOT DEFINED VERSION) 29 | SET(VERSION "1.0-SNAPSHOT") 30 | endif() 31 | 32 | 33 | if(DEFINED VERSION) 34 | SET(SOVERSION ${VERSION}) 35 | endif() 36 | 37 | if(NOT DEFINED LIB_READLINE) 38 | SET(LIB_READLINE "no") 39 | endif() 40 | if(NOT DEFINED LIB_ICONV) 41 | SET(LIB_ICONV "yes") 42 | endif() 43 | if(NOT DEFINED LIB_GETTEXT) 44 | SET(LIB_GETTEXT "yes") 45 | endif() 46 | if(NOT DEFINED LIB_DL) 47 | SET(LIB_DL "no") 48 | endif() 49 | 50 | # DEFAULT FLAGS 51 | if(NOT DEFINED FLAGS) 52 | # for gcc > 4.9 53 | #SET(FLAGS "-fdiagnostics-color=always") 54 | endif() 55 | 56 | # Initialisation specifique OS 57 | #---------------------------------------------------------- 58 | if( ${CMAKE_SYSTEM_NAME} MATCHES Linux) 59 | LIST(APPEND REQUIRED_LIBS "resolv") 60 | SET(FLAGS "${FLAGS} -DLINUX") 61 | endif() 62 | 63 | if( ${CMAKE_SYSTEM_NAME} MATCHES Linux) 64 | SET( LIB_GETTEXT "yes") 65 | SET( LIB_ICONV "yes") 66 | elseif( ${CMAKE_SYSTEM_NAME} MATCHES Windows ) 67 | SET( LIB_GETTEXT "no") 68 | SET( LIB_ICONV "no") 69 | endif() 70 | 71 | 72 | 73 | 74 | # Triggers des options 75 | #-------------------------------------------------------- 76 | 77 | 78 | # Triggers simples 79 | 80 | if ( ${LIB_READLINE}) 81 | SET(LIB_DL "yes") 82 | SET(FLAGS "${FLAGS} -DREADLINE") 83 | endif() 84 | 85 | if ( ${LIB_GETTEXT} ) 86 | SET(FLAGS "${FLAGS} -DGETTEXT") 87 | #SI AIX -lintl 88 | endif() 89 | 90 | if ( ${LIB_ICONV} ) 91 | SET(FLAGS "${FLAGS} -DICONV") 92 | #SI AIX -liconv 93 | #SI SUNOS -liconv 94 | endif() 95 | 96 | # Triggers complexes 97 | 98 | 99 | if( NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows AND ${LIB_DL} MATCHES "yes") 100 | LIST(APPEND REQUIRED_LIBS "dl") 101 | endif() 102 | 103 | 104 | set(CUSTOM_LIBRARY_PATH ${CMAKE_BINARY_DIR}/extLib) 105 | MESSAGE( STATUS "CUSTOM LIBRARY PATH : ${CUSTOM_LIBRARY_PATH}" ) 106 | file(MAKE_DIRECTORY ${CUSTOM_LIBRARY_PATH}) 107 | 108 | 109 | file(GLOB sub-dir ${CUSTOM_LIBRARY_PATH}/*) 110 | foreach(dir ${sub-dir}) 111 | if(IS_DIRECTORY ${dir}) 112 | set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}:${dir}) 113 | endif() 114 | endforeach() 115 | 116 | # to find libraries 117 | file( GLOB LIB_HEADERS ${CUSTOM_LIBRARY_PATH}/*/headers ) 118 | file( GLOB STATIC_LIBRARIES ${CUSTOM_LIBRARY_PATH}/*/lib/*.a ) 119 | 120 | 121 | ## Default include headers libraries 122 | include_directories(${LIB_HEADERS}) 123 | 124 | 125 | #------------------------------------------------------------------------------------------------------------ 126 | # CREATION DU PROFIL DE COMPILATION 127 | 128 | SET(MULTITHREAD_FLAGS "-DRENT -D_THREAD_SAFE -L/usr/lib/threads -L/usr/lib/dce -lpthread -DMULTITHREAD -pthread ") 129 | 130 | # Profiles de compilation -DCMAKE_BUILD_TYPE= 131 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-strict-overflow ${FLAGS}") 132 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-strict-overflow ${FLAGS}") 133 | 134 | #-------------------------------------------------------- 135 | # PROFIL Release 136 | SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3" ${CMAKE_CXX_FLAGS}) 137 | SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3" ${CMAKE_C_FLAGS}) 138 | 139 | 140 | #-------------------------------------------------------- 141 | # PROFIL Debug 142 | SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -ggdb -g3 ${CMAKE_CXX_FLAGS}") 143 | SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -ggdb -g3 ${CMAKE_C_FLAGS}") 144 | 145 | 146 | ######################## additives functions ########################$ 147 | 148 | #thi function read propersties form a propersties file. 149 | # a preperties file look like that : 150 | # key#1 = valeur1 151 | # key2 = valeur2 152 | # … 153 | # this function return the value associate to a key 154 | function(get_property_value FilePath Key ResultValue) 155 | 156 | 157 | file(READ ${FilePath} Contents) 158 | # Set the variable "Esc" to the ASCII value 27 - basically something 159 | # which is unlikely to conflict with anything in the file contents. 160 | string(ASCII 27 Esc) 161 | 162 | # Turn the contents into a list of strings, each ending with an Esc. 163 | # This allows us to preserve blank lines in the file since CMake 164 | # automatically prunes empty list items during a foreach loop. 165 | string(REGEX REPLACE "\n" "${Esc};" ContentsAsList ${Contents}) 166 | 167 | 168 | 169 | unset(ModifiedContents) 170 | foreach(Line ${ContentsAsList}) 171 | message("Line = ${Line}") 172 | #STRING(REGEX MATCH "${Key}[ ]*=[ ]*.*" Value ${Line}) 173 | #message("temp value=${Value}") 174 | if("${Line}" MATCHES "${Key}[ ]*=[ ]*.*") 175 | string(REGEX REPLACE "${Key}[ ]*=[ ]*" "" Value ${Line}) 176 | endif() 177 | 178 | endforeach() 179 | string(REGEX REPLACE "${Esc}" "" Value ${Value}) 180 | SET(${ResultValue} ${Value} PARENT_SCOPE) 181 | endfunction() 182 | 183 | -------------------------------------------------------------------------------- /exemples/hello-world/gradle.properties: -------------------------------------------------------------------------------- 1 | group = fr.echoes.example 2 | version = 1.0.0-SNAPSHOT 3 | -------------------------------------------------------------------------------- /exemples/hello-world/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tocea/gradle-cpp-plugin/8aa0129d9ac38ca922ba7e439f03442c74e81341/exemples/hello-world/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /exemples/hello-world/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Oct 06 16:14:23 CEST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip 7 | -------------------------------------------------------------------------------- /exemples/hello-world/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /exemples/hello-world/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /exemples/hello-world/src/main/cpp/hello/Speaker.cpp: -------------------------------------------------------------------------------- 1 | #include "hello/Speaker.h" 2 | 3 | using namespace Hello; 4 | using namespace std; 5 | 6 | namespace Hello { 7 | void Speaker::sayHello() { 8 | cout << "Hello, world!\n"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /exemples/hello-world/src/main/cpp/main/HelloWorld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | using namespace Hello; 5 | 6 | int main(int argc, char *argv[]) { 7 | Speaker* speaker = new Speaker(); 8 | 9 | speaker->sayHello(); 10 | } 11 | -------------------------------------------------------------------------------- /exemples/hello-world/src/main/headers/hello/Speaker.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace Hello { 5 | 6 | class Speaker { 7 | 8 | public: 9 | void sayHello(); 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /exemples/version.gradle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | def getCppPluginVersion(String _gradlePropertiesPath) { 5 | Properties properties = new Properties() 6 | File propertiesFile = new File(_gradlePropertiesPath) 7 | propertiesFile.withInputStream { 8 | properties.load(it) 9 | } 10 | properties.version 11 | } 12 | 13 | 14 | 15 | ext { 16 | cppPluginVersion = this.&getCppPluginVersion 17 | } 18 | 19 | 20 | //println getCppPluginVersion('../../gradle.properties') 21 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | 2 | #Global Project Information--------------- 3 | version=1.2.9 4 | group=fr.echoes.ksf.gradle.plugins 5 | 6 | lang=en 7 | title=Gradle CPP Plugin 8 | author=Jérémie Guidoux/Sylvain Leroy 9 | # Sonar 10 | key=gradle-cpp-plugin 11 | contact=contact@echoes.fr 12 | website=http://echoes.fr 13 | description=CPP Plugin for Gradle 14 | 15 | 16 | #NEXUS Configuration--------------- 17 | localNexusURL=http://zeus.tocea.local:8081 18 | 19 | nexusSnapshotPath=/nexus/content/groups/echoes-lab-snapshot 20 | nexusReleasePath=/nexus/content/groups/echoes-lab-release 21 | nexusUploadPath=/nexus/content/repositories/oss-releases/ 22 | 23 | 24 | #Remote--------------- 25 | # the URL from which gradle scripts are fetched 26 | gradleConfigUrl=https://raw.githubusercontent.com/echoes-tech/elabs-gradle-remote-config/master/ 27 | # the GIT repository on witch the documentation template is hosted 28 | htmlTempalteGitRepoUri=https://github.com/echoes-tech/elabs-html-doc-template.git 29 | 30 | 31 | javaVersion=1.7 32 | gradeleWrapper=2.7 33 | groovyVersion=2.3.10 34 | 35 | #dependencies version 36 | commonsioVersion=2.4 37 | spockVersion=1.0-groovy-2.4 38 | spockSeportVersion=1.2.7 39 | -------------------------------------------------------------------------------- /gradle/publish.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.text.SimpleDateFormat 18 | 19 | Date buildTimeAndDate = new Date() 20 | ext { 21 | buildTime = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate) 22 | buildDate = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate) 23 | } 24 | 25 | apply plugin: 'maven-publish' 26 | apply plugin: 'bintray' 27 | 28 | jar { 29 | manifest { 30 | attributes( 31 | 'Built-By': System.properties['user.name'], 32 | 'Created-By': System.properties['java.version'] + " (" + System.properties['java.vendor'] + " " + System.getProperty("java.vm.version") + ")", 33 | 'Build-Date': project.buildTime, 34 | 'Build-Time': project.buildDate, 35 | 'Specification-Title': project.name, 36 | 'Specification-Version': project.version, 37 | 'Specification-Vendor': 'https://github.com/sleroy/gradle-pandoc-plugin', 38 | 'Implementation-Title': project.name, 39 | 'Implementation-Version': project.version, 40 | 'Implementation-Vendor': 'https://github.com/sleroy/gradle-pandoc-plugin' 41 | ) 42 | } 43 | } 44 | 45 | def pomConfig = { 46 | name project.name 47 | description 'A Gradle plugin for transforming Markdown/Latex to HTML/PDF/EPUB/Eclipse with Pandoc' 48 | url 'https://github.com/sleroy/gradle-pandoc-plugin' 49 | inceptionYear '2014' 50 | licenses { 51 | license { 52 | name 'The Apache Software License, Version 2.0' 53 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' 54 | distribution 'repo' 55 | } 56 | } 57 | scm { 58 | url 'https://github.com/sleroy/gradle-pandoc-plugin' 59 | } 60 | developers { 61 | [ 62 | sleroy: 'Sylvain Leroy', 63 | afloch : 'Antoine Floch' 64 | ].each { devId, devName -> 65 | developer { 66 | id devId 67 | name devName 68 | roles { 69 | role 'Developer' 70 | } 71 | } 72 | } 73 | } 74 | } 75 | 76 | publishing { 77 | publications { 78 | mavenCustom(MavenPublication) { 79 | from components.java 80 | artifact sourceJar 81 | 82 | pom.withXml { 83 | asNode().children().last() + pomConfig 84 | } 85 | } 86 | } 87 | } 88 | 89 | task install(dependsOn: publishToMavenLocal) 90 | 91 | if (!project.hasProperty('bintrayUsername')) ext.bintrayUsername = '' 92 | if (!project.hasProperty('bintrayApiKey')) ext.bintrayApiKey = '' 93 | 94 | bintray { 95 | user = project.bintrayUsername 96 | key = project.bintrayApiKey 97 | publications = ['mavenCustom'] 98 | pkg { 99 | repo = 'maven' 100 | userOrg = 'sleroy' 101 | name = 'gradle-pandoc-plugin' 102 | desc = 'A Gradle plugin for transforming Markdown/Latex to HTML/PDF/EPUB/Eclipse with Pandoc' 103 | licenses = ['Apache-2.0'] 104 | labels = ['gradle', 'plugin', 'markdown','latex','eclipse', 'pandoc', 'pdf'] 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tocea/gradle-cpp-plugin/8aa0129d9ac38ca922ba7e439f03442c74e81341/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Oct 01 11:40:03 CEST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /images/cppPluginGraph.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tocea/gradle-cpp-plugin/8aa0129d9ac38ca922ba7e439f03442c74e81341/images/cppPluginGraph.jpg -------------------------------------------------------------------------------- /modules/cmake_modules/FindCPPUNIT.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Find the CppUnit includes and library 3 | # 4 | # This module defines 5 | # CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc. 6 | # CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit. 7 | # CPPUNIT_FOUND, If false, do not try to use CppUnit. 8 | 9 | # also defined, but not for general use are 10 | # CPPUNIT_LIBRARY, where to find the CppUnit library. 11 | # CPPUNIT_DEBUG_LIBRARY, where to find the CppUnit library in debug 12 | # mode. 13 | 14 | SET(CPPUNIT_FOUND "NO") 15 | 16 | FIND_PATH(CPPUNIT_INCLUDE_DIR cppunit/TestCase.h /usr/local/include /usr/include) 17 | 18 | # With Win32, important to have both 19 | IF(WIN32) 20 | FIND_LIBRARY(CPPUNIT_LIBRARY cppunit 21 | ${CPPUNIT_INCLUDE_DIR}/../lib 22 | /usr/local/lib 23 | /usr/lib) 24 | FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunitd 25 | ${CPPUNIT_INCLUDE_DIR}/../lib 26 | /usr/local/lib 27 | /usr/lib) 28 | ELSE(WIN32) 29 | # On unix system, debug and release have the same name 30 | FIND_LIBRARY(CPPUNIT_LIBRARY cppunit 31 | ${CPPUNIT_INCLUDE_DIR}/../lib 32 | /usr/local/lib 33 | /usr/lib) 34 | FIND_LIBRARY(CPPUNIT_DEBUG_LIBRARY cppunit 35 | ${CPPUNIT_INCLUDE_DIR}/../lib 36 | /usr/local/lib 37 | /usr/lib) 38 | ENDIF(WIN32) 39 | 40 | IF(CPPUNIT_INCLUDE_DIR) 41 | IF(CPPUNIT_LIBRARY) 42 | SET(CPPUNIT_FOUND "YES") 43 | SET(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY} ${CMAKE_DL_LIBS}) 44 | SET(CPPUNIT_DEBUG_LIBRARIES ${CPPUNIT_DEBUG_LIBRARY} ${CMAKE_DL_LIBS}) 45 | ELSE (CPPUNIT_LIBRARY) 46 | IF (CPPUNIT_FIND_REQUIRED) 47 | MESSAGE(SEND_ERROR "Could not find library CppUnit.") 48 | ENDIF (CPPUNIT_FIND_REQUIRED) 49 | ENDIF(CPPUNIT_LIBRARY) 50 | ELSE(CPPUNIT_INCLUDE_DIR) 51 | IF (CPPUNIT_FIND_REQUIRED) 52 | MESSAGE(SEND_ERROR "Could not find library CppUnit.") 53 | ENDIF(CPPUNIT_FIND_REQUIRED) 54 | ENDIF(CPPUNIT_INCLUDE_DIR) 55 | -------------------------------------------------------------------------------- /modules/cmake_modules/gradle-cpp-cppUnitTest.cmake: -------------------------------------------------------------------------------- 1 | 2 | SET(TEST_SRC ${PROJECT_SOURCE_DIR}/src/test/cpp) 3 | SET(TEST_HEADERS ${PROJECT_SOURCE_DIR}/src/test/headers) 4 | file(GLOB_RECURSE TEST_SOURCES ${TEST_SRC}/*.cpp) 5 | 6 | # ------------------------- 7 | 8 | # Usefull to get CPPUNIT ... 9 | # I would love to find a way to have cppunit 10 | # only required for builds where unit test make sense ... 11 | #set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") 12 | FIND_PACKAGE(CPPUNIT REQUIRED) 13 | 14 | ##################### tests ################## 15 | 16 | enable_testing() 17 | 18 | 19 | #set(TMP_VAR ${EXECUTABLE_OUTPUT_PATH}) 20 | #set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build/test-obj) 21 | include_directories(${TEST_HEADERS}) 22 | 23 | 24 | add_executable(launchTest ${SOURCES} ${TEST_SOURCES}) 25 | target_link_libraries(launchTest cppunit ${STATIC_LIBRARIES}) 26 | add_test(NAME aTest COMMAND launchTest) 27 | 28 | -------------------------------------------------------------------------------- /modules/cmake_modules/gradle-cpp.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Main useful constants 3 | SET(MAIN_SRC ${PROJECT_SOURCE_DIR}/src/main/cpp) 4 | SET(MAIN_HEADERS ${PROJECT_SOURCE_DIR}/src/main/headers) 5 | 6 | 7 | set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build) 8 | 9 | 10 | # Default output directories 11 | set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tmp/bin) 12 | set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tmp/lib) 13 | file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) 14 | file(MAKE_DIRECTORY ${LIBRARY_OUTPUT_PATH}) 15 | FILE(GLOB_RECURSE SOURCES ${MAIN_SRC}/*.cpp) 16 | 17 | 18 | ## Default include directories 19 | 20 | include_directories(${MAIN_HEADERS}) 21 | include_directories(${MAIN_SRC}) 22 | 23 | 24 | # Variables de compilation (et valeurs par défaut) 25 | if(NOT DEFINED LIBRARY_TYPE) # STATIC 26 | SET(LIBRARY_TYPE "SHARED") # STATIC|MODULE|SHARED 27 | endif() 28 | if(NOT DEFINED VERSION) 29 | SET(VERSION "1.0-SNAPSHOT") 30 | endif() 31 | 32 | 33 | if(DEFINED VERSION) 34 | SET(SOVERSION ${VERSION}) 35 | endif() 36 | 37 | if(NOT DEFINED LIB_READLINE) 38 | SET(LIB_READLINE "no") 39 | endif() 40 | if(NOT DEFINED LIB_ICONV) 41 | SET(LIB_ICONV "yes") 42 | endif() 43 | if(NOT DEFINED LIB_GETTEXT) 44 | SET(LIB_GETTEXT "yes") 45 | endif() 46 | if(NOT DEFINED LIB_DL) 47 | SET(LIB_DL "no") 48 | endif() 49 | 50 | # DEFAULT FLAGS 51 | if(NOT DEFINED FLAGS) 52 | # for gcc > 4.9 53 | #SET(FLAGS "-fdiagnostics-color=always") 54 | endif() 55 | 56 | # Initialisation specifique OS 57 | #---------------------------------------------------------- 58 | if( ${CMAKE_SYSTEM_NAME} MATCHES Linux) 59 | LIST(APPEND REQUIRED_LIBS "resolv") 60 | SET(FLAGS "${FLAGS} -DLINUX") 61 | endif() 62 | 63 | if( ${CMAKE_SYSTEM_NAME} MATCHES Linux) 64 | SET( LIB_GETTEXT "yes") 65 | SET( LIB_ICONV "yes") 66 | elseif( ${CMAKE_SYSTEM_NAME} MATCHES Windows ) 67 | SET( LIB_GETTEXT "no") 68 | SET( LIB_ICONV "no") 69 | endif() 70 | 71 | 72 | 73 | 74 | # Triggers des options 75 | #-------------------------------------------------------- 76 | 77 | 78 | # Triggers simples 79 | 80 | if ( ${LIB_READLINE}) 81 | SET(LIB_DL "yes") 82 | SET(FLAGS "${FLAGS} -DREADLINE") 83 | endif() 84 | 85 | if ( ${LIB_GETTEXT} ) 86 | SET(FLAGS "${FLAGS} -DGETTEXT") 87 | #SI AIX -lintl 88 | endif() 89 | 90 | if ( ${LIB_ICONV} ) 91 | SET(FLAGS "${FLAGS} -DICONV") 92 | #SI AIX -liconv 93 | #SI SUNOS -liconv 94 | endif() 95 | 96 | # Triggers complexes 97 | 98 | 99 | if( NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows AND ${LIB_DL} MATCHES "yes") 100 | LIST(APPEND REQUIRED_LIBS "dl") 101 | endif() 102 | 103 | 104 | set(CUSTOM_LIBRARY_PATH ${CMAKE_BINARY_DIR}/extLib) 105 | MESSAGE( STATUS "CUSTOM LIBRARY PATH : ${CUSTOM_LIBRARY_PATH}" ) 106 | file(MAKE_DIRECTORY ${CUSTOM_LIBRARY_PATH}) 107 | 108 | 109 | file(GLOB sub-dir ${CUSTOM_LIBRARY_PATH}/*) 110 | foreach(dir ${sub-dir}) 111 | if(IS_DIRECTORY ${dir}) 112 | set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}:${dir}) 113 | endif() 114 | endforeach() 115 | 116 | # to find libraries 117 | file( GLOB LIB_HEADERS ${CUSTOM_LIBRARY_PATH}/*/headers ) 118 | file( GLOB STATIC_LIBRARIES ${CUSTOM_LIBRARY_PATH}/*/lib/*.a ) 119 | 120 | 121 | ## Default include headers libraries 122 | include_directories(${LIB_HEADERS}) 123 | 124 | 125 | #------------------------------------------------------------------------------------------------------------ 126 | # CREATION DU PROFIL DE COMPILATION 127 | 128 | SET(MULTITHREAD_FLAGS "-DRENT -D_THREAD_SAFE -L/usr/lib/threads -L/usr/lib/dce -lpthread -DMULTITHREAD -pthread ") 129 | 130 | # Profiles de compilation -DCMAKE_BUILD_TYPE= 131 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-strict-overflow ${FLAGS}") 132 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-strict-overflow ${FLAGS}") 133 | 134 | #-------------------------------------------------------- 135 | # PROFIL Release 136 | SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3" ${CMAKE_CXX_FLAGS}) 137 | SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3" ${CMAKE_C_FLAGS}) 138 | 139 | 140 | #-------------------------------------------------------- 141 | # PROFIL Debug 142 | SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -ggdb -g3 ${CMAKE_CXX_FLAGS}") 143 | SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -ggdb -g3 ${CMAKE_C_FLAGS}") 144 | 145 | 146 | ######################## additives functions ########################$ 147 | 148 | #thi function read propersties form a propersties file. 149 | # a preperties file look like that : 150 | # key#1 = valeur1 151 | # key2 = valeur2 152 | # … 153 | # this function return the value associate to a key 154 | function(get_property_value FilePath Key ResultValue) 155 | 156 | 157 | file(READ ${FilePath} Contents) 158 | # Set the variable "Esc" to the ASCII value 27 - basically something 159 | # which is unlikely to conflict with anything in the file contents. 160 | string(ASCII 27 Esc) 161 | 162 | # Turn the contents into a list of strings, each ending with an Esc. 163 | # This allows us to preserve blank lines in the file since CMake 164 | # automatically prunes empty list items during a foreach loop. 165 | string(REGEX REPLACE "\n" "${Esc};" ContentsAsList ${Contents}) 166 | 167 | 168 | 169 | unset(ModifiedContents) 170 | foreach(Line ${ContentsAsList}) 171 | message("Line = ${Line}") 172 | #STRING(REGEX MATCH "${Key}[ ]*=[ ]*.*" Value ${Line}) 173 | #message("temp value=${Value}") 174 | if("${Line}" MATCHES "${Key}[ ]*=[ ]*.*") 175 | string(REGEX REPLACE "${Key}[ ]*=[ ]*" "" Value ${Line}) 176 | endif() 177 | 178 | endforeach() 179 | string(REGEX REPLACE "${Esc}" "" Value ${Value}) 180 | SET(${ResultValue} ${Value} PARENT_SCOPE) 181 | endfunction() 182 | 183 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'cpp-project-plugin' 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/main/groovy/fr/echoes/gradle/plugins/cpp/CppPlugin.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp 2 | 3 | import fr.echoes.gradle.plugins.cpp.configurations.ArchivesConfigurations 4 | import fr.echoes.gradle.plugins.cpp.configurations.CppConfiguration 5 | import fr.echoes.gradle.plugins.cpp.extensions.CppPluginExtension 6 | import fr.echoes.gradle.plugins.cpp.tasks.CppExecTask 7 | import fr.echoes.gradle.plugins.cpp.tasks.DownloadLibTask 8 | import fr.echoes.gradle.plugins.cpp.tasks.InitOutputDirsTask 9 | import org.gradle.api.Plugin 10 | import org.gradle.api.Project 11 | import org.gradle.api.artifacts.ProjectDependency 12 | import org.gradle.api.internal.plugins.DslObject 13 | import org.gradle.api.plugins.MavenRepositoryHandlerConvention 14 | import org.gradle.api.tasks.Copy 15 | import org.gradle.api.tasks.Upload 16 | import org.gradle.api.tasks.bundling.Zip 17 | 18 | /** 19 | * This class is the entry point of the gradle-cpp-plugin 20 | * 21 | *

22 | * Created by jguidoux on 03/09/15. 23 | */ 24 | class CppPlugin implements Plugin { 25 | 26 | /** 27 | * @see org.gradle.api.Plugin#apply 28 | */ 29 | @Override 30 | void apply(final Project _project) { 31 | _project.apply(plugin: 'base') 32 | _project.apply(plugin: 'distribution') 33 | _project.apply(plugin: 'maven') 34 | 35 | 36 | projectConfigurations(_project) 37 | createTasks(_project) 38 | 39 | 40 | 41 | _project.extensions.create("cpp", CppPluginExtension, _project) 42 | ArchivesConfigurations archiveConf = new ArchivesConfigurations(project: _project) 43 | def cppConfiguration = new CppConfiguration() 44 | archiveConf.configureDistribution() 45 | archiveConf.initCppArchives() 46 | archiveConf.configureArtifact() 47 | 48 | _project.afterEvaluate { 49 | // Access extension variables here, now that they are set 50 | 51 | archiveConf.ConfigureDistZip() 52 | 53 | configureTasks(_project) 54 | cppConfiguration.configureCppExecTask(_project) 55 | 56 | 57 | 58 | 59 | def enabled = _project.cpp.buildTasksEnabled 60 | if (enabled) { 61 | configureBuildTasksDependencies(_project) 62 | } else { 63 | println "no build tasks" 64 | } 65 | List dependentProjects = findDependentProjects(_project) 66 | _project.tasks.downloadLibs.dependsOn dependentProjects.tasks.build 67 | 68 | } 69 | 70 | } 71 | 72 | private configureTasks(Project _project) { 73 | 74 | if (_project.cpp.outPutDirs) { 75 | CppPluginUtils.OUTPUT_DIRS << _project.cpp.outPutDirs 76 | _project.tasks.initOutputDirs.outpoutDirs = CppPluginUtils.OUTPUT_DIRS 77 | if (CppPluginUtils.OUTPUT_DIRS[CppPluginUtils.EXT_LIB_DIR]) { 78 | DownloadLibTask dlTask = _project.tasks.downloadLibs 79 | dlTask.changeExtLibLocation(CppPluginUtils.OUTPUT_DIRS[CppPluginUtils.EXT_LIB_DIR]) 80 | } 81 | } 82 | 83 | Copy copyHeaders = _project.tasks.copyHeaders 84 | copyHeaders.from(CppPluginUtils.SOURCE_HEADERS) 85 | copyHeaders.into("${_project.buildDir}" + 86 | "/${CppPluginUtils.OUTPUT_DIRS[CppPluginUtils.TMP_DIR]}" + 87 | "/${CppPluginUtils.OUTPUT_TMP_DIRS.headers}") 88 | } 89 | 90 | private void projectConfigurations(Project _project) { 91 | _project.configurations.create("compile") 92 | _project.configurations.compile.transitive = false 93 | } 94 | 95 | 96 | private void createTasks(Project _project) { 97 | _project.task('downloadLibs', type: DownloadLibTask, group: 'dependancies') 98 | _project.task('initOutputDirs', type: InitOutputDirsTask, group: "init") 99 | _project.task('copyHeaders', type: Copy) 100 | _project.task('compileCpp', type: CppExecTask, group: 'build') 101 | _project.task('testCompileCpp', type: CppExecTask, group: 'build') 102 | _project.task('testCpp', type: CppExecTask, group: 'build') 103 | configureInstall(_project) 104 | configureTasksDependencies(_project) 105 | 106 | } 107 | 108 | 109 | private configureTasksDependencies(Project _project) { 110 | 111 | _project.tasks.downloadLibs.dependsOn _project.tasks.initOutputDirs 112 | _project.tasks.copyHeaders.dependsOn _project.tasks.initOutputDirs 113 | _project.tasks.distZip.dependsOn _project.tasks.copyHeaders 114 | _project.tasks.distZip.dependsOn _project.tasks.compileCpp 115 | _project.tasks.install.dependsOn _project.tasks.assemble 116 | _project.tasks.uploadArchives.dependsOn _project.tasks.build 117 | 118 | } 119 | 120 | private configureBuildTasksDependencies(final Project _project) { 121 | _project.tasks.compileCpp.dependsOn _project.tasks.downloadLibs 122 | _project.tasks.testCompileCpp.dependsOn _project.tasks.compileCpp 123 | _project.tasks.testCpp.dependsOn _project.tasks.testCompileCpp 124 | _project.tasks.check.dependsOn _project.tasks.testCpp 125 | } 126 | 127 | private List findDependentProjects(Project _project) { 128 | def projectDependencies = _project.configurations.compile.allDependencies.withType(ProjectDependency) 129 | def dependentProjects = projectDependencies*.dependencyProject 130 | dependentProjects 131 | } 132 | 133 | private void configureInstall(Project project) { 134 | Upload installUpload = project.tasks.create("install", Upload); 135 | MavenRepositoryHandlerConvention repositories = 136 | new DslObject(installUpload.repositories).convention.getPlugin(MavenRepositoryHandlerConvention); 137 | repositories.mavenInstaller() 138 | installUpload.description = "Installs the 'archives' artifacts into the local Maven repository." 139 | } 140 | 141 | 142 | 143 | 144 | } 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /src/main/groovy/fr/echoes/gradle/plugins/cpp/CppPluginUtils.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp 2 | 3 | /** 4 | * Created by jguidoux on 03/09/15. 5 | */ 6 | class CppPluginUtils { 7 | 8 | public static final String SOURCE_HEADERS = "src/main/headers" 9 | public static final String ZIP_EXTENSION = "zip" 10 | public static final String CLIB_EXTENSION = "clib" 11 | public static final String EXT_LIB_DIR = "extLibDir" 12 | public static final String MAIN_OBJ_DIR = "mainDir" 13 | public static final String TEST_OBJ_DIR = "testDir" 14 | public static final String TMP_DIR = "tmpDir" 15 | public static final String REPORT_DIR = "reportDir" 16 | public static final String DOC_DIR = "docDir" 17 | public static final String COMPILE_CMAKE_BASE_ARG = "" 18 | public static final String TEST_COMPILE_CMAKE_BASE_ARG = "" 19 | public static final String TEST_CMAKE_BASE_ARG = "" 20 | public static Map OUTPUT_DIRS = ["mainDir": "main-obj", "testDir": "test-obj", "extLibDir": "extLib", 21 | "tmpDir" : "tmp", "report": "reports", "doc": "docDir"] 22 | public static Map OUTPUT_TMP_DIRS = ["headers": "headers", "bin":"bin","lib": "lib", 23 | "doc":"doc", "doxygen":"doxygen"] 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/groovy/fr/echoes/gradle/plugins/cpp/configurations/ArchivesConfigurations.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp.configurations 2 | 3 | import fr.echoes.gradle.plugins.cpp.CppPluginUtils 4 | import fr.echoes.gradle.plugins.cpp.extensions.CppPluginExtension 5 | import fr.echoes.gradle.plugins.cpp.model.ApplicationType 6 | import org.gradle.api.Project 7 | import org.gradle.api.distribution.DistributionContainer 8 | import org.gradle.api.tasks.Upload 9 | import org.gradle.api.tasks.bundling.Zip 10 | 11 | /** 12 | * Created by jguidoux on 06/09/15. 13 | */ 14 | class ArchivesConfigurations { 15 | 16 | Project project 17 | 18 | def configureDistribution() { 19 | DistributionContainer distrib = project.extensions["distributions"] 20 | distrib["main"].contents { 21 | from "${project.buildDir}/tmp" 22 | } 23 | } 24 | 25 | def configureUpload(){ 26 | Upload install = project.tasks["install"] 27 | install.configuration = project.configurations.getByName("cArchives") 28 | Upload upload = project.tasks["uploadArchives"] 29 | upload.configuration = project.configurations.getByName("cArchives") 30 | } 31 | 32 | def ConfigureDistZip() { 33 | Zip cppArchive = project.tasks["distZip"] 34 | configureArchive(cppArchive) 35 | } 36 | 37 | def configureArtifact() { 38 | project.configurations.create("cArchives") 39 | Zip cppArchive = project.tasks["distZip"] 40 | project.artifacts { 41 | 42 | project.artifacts.add("cArchives", cppArchive) 43 | } 44 | configureUpload() 45 | } 46 | 47 | private void configureArchive(Zip _cppArchive) { 48 | CppPluginExtension cpp = project.extensions["cpp"] 49 | _cppArchive.classifier = cpp.classifier 50 | 51 | switch (cpp.applicationType) { 52 | case ApplicationType.clibrary: 53 | configureCLibrary(_cppArchive) 54 | break 55 | case ApplicationType.capplication: 56 | configureCApplcation(_cppArchive) 57 | break 58 | default: 59 | configureCLibrary(_cppArchive) 60 | break 61 | } 62 | } 63 | 64 | private def configureCApplcation(final Zip _zip) { 65 | _zip.extension = CppPluginUtils.ZIP_EXTENSION 66 | } 67 | 68 | private def configureCLibrary(final Zip _zip) { 69 | _zip.extension = CppPluginUtils.CLIB_EXTENSION 70 | } 71 | 72 | def initCppArchives() { 73 | Zip distZip = project.tasks["distZip"] 74 | distZip.extension = project.cpp.applicationType 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/groovy/fr/echoes/gradle/plugins/cpp/configurations/CppConfiguration.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp.configurations 2 | 3 | import fr.echoes.gradle.plugins.cpp.tasks.CppExecTask 4 | import org.gradle.api.Project 5 | import org.gradle.api.tasks.TaskCollection 6 | 7 | /** 8 | * Created by jguidoux on 23/09/15. 9 | */ 10 | class CppConfiguration { 11 | 12 | void configureCppExecTask(Project _project) { 13 | 14 | TaskCollection tasks = _project.tasks.withType(CppExecTask) 15 | tasks.each { CppExecTask task -> 16 | initFields(_project, task) 17 | } 18 | 19 | } 20 | 21 | private void initFields(Project _project, CppExecTask _task) { 22 | if (_project.cpp.exec.execPath) { 23 | def isWindows = System.properties['os.name'].toLowerCase().contains('windows') 24 | def commandLinePrefix = isWindows ? ['cmd', '/c'] : [] 25 | _task.executable _project.cpp.exec.execPath 26 | _task.commandLine commandLinePrefix + _task.executable 27 | } 28 | if (_project.cpp.exec."${_task.name}ExecPath") { 29 | _task.executable _project.cpp.exec."${_task.name}ExecPath" 30 | } 31 | if (_project.cpp.exec."${_task.name}StandardOutput") { 32 | _task.standardOutput = new ByteArrayOutputStream()//_project.cpp.exec."${_task.name}StandardOutput" 33 | } 34 | def args = [] 35 | if (_project.cpp.exec."${_task.name}BaseArgs" ) { 36 | args.addAll _project.cpp.exec."${_task.name}BaseArgs".split('\\s') 37 | } 38 | if (_project.cpp.exec."${_task.name}Args") { 39 | args.addAll _project.cpp.exec."${_task.name}Args".split('\\s') 40 | } 41 | _task.args args 42 | if (_project.cpp.exec."${_task.name}ExecWorkingDir") { 43 | _task.workingDir _project.cpp.exec."${_task.name}ExecWorkingDir" 44 | } 45 | if (_project.cpp.exec.env) { 46 | _task.environment _project.cpp.exec.env 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/groovy/fr/echoes/gradle/plugins/cpp/extensions/CppExecExtension.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp.extensions 2 | 3 | import fr.echoes.gradle.plugins.cpp.tasks.CppExecTask 4 | import org.gradle.api.Project 5 | import org.gradle.api.tasks.TaskCollection 6 | 7 | /** 8 | * This class set the configurations of all tasks of type {@link CppExecTask}. 9 | * 10 | *

11 | * In addition of basic properties, dynamically, some others properties are added. 12 | * For each task of type {@link CppExecTask}, these properties are addes : 13 | *

    14 | *
  • ${task.name}ExecPath : command path te execute for this task
  • 15 | *
  • ${task.name}BaseArgs : arguments of the command of this task
  • 16 | *
  • ${task.name}Args : more arguments for the command of this task
  • 17 | *
  • ${task.name}StandardOutput : output of type {@link OutputStream} for the command of this task
  • 18 | *
  • ${task.name}ExecPath : location to execute the command for this task
  • 19 | *
20 | *

21 | * Usage example 22 | *

23 |  *    cpp.exec.with{
24 |  *
25 |  *    }
26 |  *    
27 | *

28 | * Created by jguidoux on 01/10/15. 29 | */ 30 | class CppExecExtension { 31 | 32 | /** 33 | * The default command path to execute for each task of type {@link CppExecTask} 34 | * if they don't override it with the property ${task.name}ExecPath} 35 | * 36 | *

37 | * Usage example 38 | *

39 |      *    cpp.exec.with{
40 |      *        execPath = "make"
41 |      *    }
42 |      *   
43 | * 44 | */ 45 | def execPath = "" 46 | 47 | /** 48 | * Set the environment variable for the command execution for each task of type {@link CppExecTask} 49 | *

50 | * Usage example 51 | *

52 |      *    cpp.exec.with{
53 |      *        env = [JAVA_HOME: "/usr/lib/jvm/java-8-oracle"]
54 |      *    }
55 |      *   
56 | * 57 | */ 58 | Map env 59 | 60 | CppExecExtension(Project _project) { 61 | 62 | 63 | 64 | TaskCollection tasks = _project.tasks.withType(CppExecTask) 65 | tasks.each { 66 | this.metaClass."${it.name}ExecPath" = "" 67 | this.metaClass."${it.name}BaseArgs" = null 68 | this.metaClass."${it.name}Args" = "" 69 | this.metaClass."${it.name}StandardOutput" = null 70 | this.metaClass."${it.name}ExecWorkingDir" = null 71 | } 72 | } 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/main/groovy/fr/echoes/gradle/plugins/cpp/extensions/CppPluginExtension.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp.extensions 2 | 3 | import fr.echoes.gradle.plugins.cpp.model.ApplicationType 4 | import org.gradle.api.Project 5 | 6 | /** 7 | * Extension to configure the gradle-cpp-plugin. 8 | *

9 | * This extension can be used like this in build.gradle file. 10 | *

11 | * usage example : 12 | *

13 |  *  cpp {
14 |  *
15 |  *    }
16 |  * 
17 | *

18 | * Created by jguidoux on 01/10/15. 19 | */ 20 | class CppPluginExtension { 21 | 22 | /** 23 | * Enable build tasks ('compileCpp', 'testCompileCpp', 'testCpp'). 24 | *

25 | * Default value : 'true' 26 | *

27 | * Usage example: 28 | *

29 |      *  cpp.buildTasksEnabled = false
30 |      *  
31 | * 32 | */ 33 | def buildTasksEnabled = true 34 | 35 | /** 36 | * Set application type. 37 | *

38 | * possible values are : 39 | *

    40 | *
  • 'clibrary' : for library application (no main). Produce a '.clib' archive
  • 41 | *
  • 'capplication' : for runnable application. Produce a '.zip' archive
  • 42 | *
43 | *

44 | * Default value : 'clibrary' 45 | *

46 | * Usage example: 47 | *

48 |      *    cpp.applicationType = "capplication"
49 |      *    
50 | */ 51 | ApplicationType applicationType = ApplicationType.clibrary 52 | 53 | /** 54 | * Set application specificity. 55 | *

56 | * An application for the same version can be build : 57 | *

    58 | *
  • for a specific OS (Windows, linux, …)
  • 59 | *
  • with a specific compilator with a specific version (gcc 5.2, g++ 4.4,… )
  • 60 | *
  • for a specific architecture
  • 61 | *
  • for a specific client with a specific configuration
  • 62 | *
  • 63 | *
64 | *

65 | * Default value : "" 66 | *

67 | * Usage example: 68 | *

69 |      *   cpp.classifier = "linux_gcc-5.2_x86_64"
70 |      *   
71 | * 72 | */ 73 | String classifier = "" 74 | 75 | def outPutDirs = new HashMap() 76 | 77 | /** 78 | * Set the configuration of all tasks of type {@link fr.echoes.gradle.plugins.cpp.tasks.CppExecTask}. ('compileCpp', 'testCompileCpp', 'testCpp') 79 | *

80 | * Usage example: 81 | *

82 |      *  cpp.exec.with{
83 |      *
84 |      *   }
85 |      *   
86 | */ 87 | CppExecExtension exec 88 | 89 | CppPluginExtension(Project _project) { 90 | exec = new CppExecExtension(_project) 91 | 92 | } 93 | 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/groovy/fr/echoes/gradle/plugins/cpp/model/ApplicationType.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp.model 2 | 3 | /** 4 | * Enum to store the two kinds of c application 'clibrary' or 'capplication' 5 | *

6 | * Created by jguidoux on 06/09/15. 7 | */ 8 | enum ApplicationType { 9 | clibrary, capplication 10 | } 11 | -------------------------------------------------------------------------------- /src/main/groovy/fr/echoes/gradle/plugins/cpp/tasks/CppExecTask.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp.tasks 2 | 3 | import org.gradle.api.tasks.Exec 4 | 5 | /** 6 | * This class is use for build tasks for the gradle-cpp-plugin. 7 | *

8 | * Existing CppExecTask are 'compileCpp', 'testCompileCpp', 'testCpp'. 9 | *

10 | * User can create this CppExecTask like this : 11 | *

12 |  *       task testIntegration(type: CppExecTask)
13 |  *       testIntegration.dependsOn testCpp
14 |  *       check.dependsOn testIntegration
15 |  *   
16 | * User can configure this task directly. CppExecTask is of type {@link Exec}, 17 | * so, all properties of {@link Exec} class can be used. 18 | *
19 |  *     task testIntegration(type: CppExecTask) {
20 |  *       workingDir = "build/test-obj"
21 |  *       executable = "make"
22 |  *       args  "IT"
23 |  *     }
24 |  *     
25 | * 26 | * Or in the configuration of the plugin 27 | *
28 |  *      cpp.exec.with {
29 |  *          testIntegrationExecPath = "make"
30 |  *          testIntegrationExecWorkingDir = "build/test-obj"
31 |  *          testIntegrationBaseArgs = "IT"
32 |  *      }
33 |  *   
34 | * 35 | *

36 | * Created by jguidoux on 04/09/15. 37 | *

38 | * @see org.gradle.api.tasks.Exec 39 | * 40 | * 41 | * 42 | */ 43 | public class CppExecTask extends Exec { 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/groovy/fr/echoes/gradle/plugins/cpp/tasks/DownloadLibTask.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp.tasks 2 | 3 | import fr.echoes.gradle.plugins.cpp.CppPluginUtils 4 | import org.apache.commons.io.FilenameUtils 5 | import org.gradle.api.DefaultTask 6 | import org.gradle.api.tasks.TaskAction 7 | 8 | /** 9 | * This class is used by the task 'downloadLibs'. 10 | * 11 | *

12 | * The downloadLibs download libraries from a known repository 13 | * and place it in the 'build/extLib' directory. 14 | * 15 | *

16 | * Usage exemple : 17 | *

18 |  *   compile  "fr.extern:sqlapi:4.1.4:lin_x86_64@clib"
19 |  *   
20 | * Or : 21 | *
22 |  *   compile group: "fr.extern", name: "sqlapi", version: "4.1.4", classifier: "lin_x86_64", ext: "clib"
23 |  *   
24 | * Or if you want to use an internal project dependency un multi-modules projects 25 | *
26 |  *    compile project(path: ":projectPath", configuration: "cArchives"
27 |  *   
28 | * 29 | * Created by jguidoux on 03/09/15. 30 | */ 31 | public class DownloadLibTask extends DefaultTask { 32 | 33 | /** 34 | * The location where libraries are downloads. 35 | *

36 | * Default Value : 'build/extLib' 37 | */ 38 | File extLibLocation 39 | 40 | /** 41 | * execute the task 42 | */ 43 | @TaskAction 44 | void exec() { 45 | 46 | extLibLocation = new File(project.buildDir, CppPluginUtils.OUTPUT_DIRS[CppPluginUtils.EXT_LIB_DIR]) 47 | def files = project.configurations.compile.files 48 | 49 | 50 | files.each { File file -> 51 | project.copy { 52 | 53 | from project.zipTree(file) 54 | println "archive ${file} has ${project.zipTree(file).files.size()} file" 55 | if (file.name.endsWith(CppPluginUtils.CLIB_EXTENSION)) { 56 | into extLibLocation.path 57 | } else { 58 | into getOutputLibDirectory(file).path 59 | } 60 | } 61 | } 62 | } 63 | 64 | def changeExtLibLocation(final String _newPath) { 65 | def newLocation = new File(project.buildDir, _newPath) 66 | if (newLocation.absolutePath != extLibLocation.absolutePath) { 67 | extLibLocation.delete() 68 | extLibLocation = newLocation 69 | } 70 | 71 | } 72 | 73 | def getOutputLibDirectory(file) { 74 | def simpleName = FilenameUtils.getBaseName(file.name) 75 | new File(extLibLocation, simpleName) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/groovy/fr/echoes/gradle/plugins/cpp/tasks/InitOutputDirsTask.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp.tasks 2 | 3 | import fr.echoes.gradle.plugins.cpp.CppPluginUtils 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.tasks.TaskAction 6 | 7 | /** 8 | * This sask init build directories with directories. 9 | * 10 | *

11 | * Default directories struture is 12 | * project/ 13 | * |___build/ 14 | * |___main-obj/ 15 | * |___test-obj/ 16 | * |___extLib/ 17 | * |___reports/ 18 | * |___docDir/ 19 | * |___tmp/ 20 | * |___headers/ 21 | * |___bin/ 22 | * |___lib/ 23 | * |___doc/ 24 | * |___doxyger/ 25 | * 26 | * 27 | * Created by jguidoux on 08/09/15. 28 | */ 29 | public class InitOutputDirsTask extends DefaultTask { 30 | 31 | 32 | def outpoutDirs = CppPluginUtils.OUTPUT_DIRS 33 | def outpoutTmpDirs = CppPluginUtils.OUTPUT_TMP_DIRS 34 | 35 | @TaskAction 36 | void initOutputs() { 37 | def buildDirSet = new HashSet() 38 | outpoutDirs.each { k,v -> 39 | buildDirSet << new File(project.buildDir, v) 40 | } 41 | def tmpDir = new File(project.buildDir, CppPluginUtils.OUTPUT_DIRS[CppPluginUtils.TMP_DIR]) 42 | outpoutTmpDirs.each { k,v -> 43 | buildDirSet << new File(tmpDir, v) 44 | } 45 | outpoutDirs[CppPluginUtils.TMP_DIR] 46 | buildDirSet.each { File file -> 47 | if (!file.exists()) { 48 | file.mkdirs() 49 | } 50 | } 51 | 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/fr.echoes.gradle.cpp.properties: -------------------------------------------------------------------------------- 1 | implementation-class=fr.echoes.gradle.plugins.cpp.CppPlugin 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/gradle-plugins/fr.echoes.gradle.cpptask.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.tocea.gradle.plugins.cpp.tasks.CppTaskPlugin 2 | -------------------------------------------------------------------------------- /src/test/groovy/fr/echoes/gradle/plugins/cpp/DistZipTaskSpec.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp 2 | 3 | import fr.echoes.gradle.plugins.cpp.extensions.CppPluginExtension 4 | import org.apache.commons.io.FileUtils 5 | import org.apache.commons.io.FilenameUtils 6 | import org.gradle.api.Project 7 | import org.gradle.api.tasks.bundling.Zip 8 | import org.gradle.testfixtures.ProjectBuilder 9 | import org.junit.Rule 10 | import org.junit.rules.TemporaryFolder 11 | import spock.lang.Shared 12 | import spock.lang.Specification 13 | 14 | import java.util.zip.ZipFile 15 | 16 | 17 | /** 18 | * test the DistZipTask class 19 | * Created by jguidoux on 03/09/15. 20 | */ 21 | class DistZipTaskSpec extends Specification { 22 | 23 | 24 | @Rule 25 | TemporaryFolder tempFolder 26 | 27 | @Shared 28 | def projectDir 29 | 30 | @Shared 31 | Project project 32 | 33 | def setup() { 34 | projectDir = tempFolder.newFolder("dlLibProjectTest") 35 | project = ProjectBuilder.builder().withProjectDir(projectDir).build() 36 | } 37 | 38 | 39 | def "check zip created"() { 40 | given: "a cpp project of type 'clibrabry' with classifie 'lin_x86_64'" 41 | 42 | project.with { 43 | apply plugin: "fr.echoes.gradle.cpp" 44 | CppPluginExtension cpp = project.extensions["cpp"] 45 | version = "1.0" 46 | cpp.with { 47 | applicationType "clibrary" 48 | classifier "lin_x86_64" 49 | } 50 | } 51 | 52 | copy() 53 | 54 | 55 | when: "I launch the distZip task" 56 | project.evaluate() 57 | Zip distZip = project.tasks["distZip"] 58 | distZip.execute() 59 | ZipFile file = new ZipFile(new File(projectDir, "build/distributions/test-1.0-lin_x86_64.clib")) 60 | 61 | 62 | then: "the file 'build/distributions/test-1.0-lin_x86_64.clib' must contain the correct content" 63 | !file.entries().toList().isEmpty() 64 | file.getEntry("test-1.0-lin_x86_64") != null 65 | file.getEntry("test-1.0-lin_x86_64/lib") != null 66 | file.getEntry("test-1.0-lin_x86_64/lib/hello") != null 67 | file.getEntry("test-1.0-lin_x86_64/lib/hello/Hello.so") != null 68 | file.getEntry("test-1.0-lin_x86_64/headers") != null 69 | file.getEntry("test-1.0-lin_x86_64/headers/hello") != null 70 | file.getEntry("test-1.0-lin_x86_64/headers/hello/hello.h") != null 71 | 72 | } 73 | 74 | def "check zip has valid extension and classifier"() { 75 | given: "a cpp project of type 'clibrabry' with classifie 'lin_x86_64' and version '1.0'" 76 | 77 | project.with { 78 | apply plugin: "fr.echoes.gradle.cpp" 79 | version = "1.0" 80 | 81 | CppPluginExtension cpp = project.extensions["cpp"] 82 | 83 | cpp.with { 84 | applicationType "clibrary" 85 | classifier "lin_x86_64" 86 | } 87 | } 88 | 89 | copy() 90 | 91 | when: "I launch the distZip task" 92 | project.evaluate() 93 | Zip distZip = project.tasks["distZip"] 94 | distZip.execute() 95 | 96 | then: "the file 'build/distributions/test-1.0-lin_x86_64.clib' must exist with correct content" 97 | new File(projectDir, "build/distributions/test-1.0-lin_x86_64.clib").exists() 98 | 99 | } 100 | 101 | def copy() { 102 | FileUtils.copyDirectory(new File("src/test/resources/distZipTest"), new File(projectDir, "build/tmp")) 103 | } 104 | 105 | def "check change packaging type to 'clib'"() { 106 | 107 | given: "a cpp project of type 'clibrabry' " 108 | project.with { 109 | apply plugin: "fr.echoes.gradle.cpp" 110 | CppPluginExtension cpp = project.extensions["cpp"] 111 | version = "1.0" 112 | 113 | cpp.with { 114 | applicationType "clibrary" 115 | classifier "lin_x86_64" 116 | } 117 | 118 | } 119 | copy() 120 | 121 | CppPluginExtension cpp = project.extensions["cpp"] 122 | 123 | 124 | when: "I launch the distZip task" 125 | project.evaluate() 126 | Zip distZip = project.tasks["distZip"] 127 | distZip.execute() 128 | 129 | then: "the produced archive must exist and have 'clib' extension" 130 | new File(projectDir, "build/distributions/test-1.0-lin_x86_64.clib").exists() 131 | FilenameUtils.getExtension(new File(projectDir, "build/distributions/test-1.0-lin_x86_64.clib").name) == 'clib' 132 | 133 | } 134 | 135 | 136 | def "check change packaging type to 'capplication'"() { 137 | 138 | given: "a cpp project of type 'clibrabry' " 139 | project.with { 140 | apply plugin: "fr.echoes.gradle.cpp" 141 | version = "1.0" 142 | 143 | CppPluginExtension cpp = project.extensions["cpp"] 144 | 145 | cpp.with { 146 | applicationType "capplication" 147 | classifier "lin_x86_64" 148 | } 149 | } 150 | copy() 151 | 152 | 153 | when: "I launch the distZip task" 154 | project.evaluate() 155 | Zip distZip = project.tasks["distZip"] 156 | distZip.execute() 157 | 158 | 159 | then: "the produced archive must exist and have 'zip' extension" 160 | new File(projectDir, "build/distributions/test-1.0-lin_x86_64.zip").exists() 161 | FilenameUtils.getExtension(new File(projectDir, "build/distributions/test-1.0-lin_x86_64.zip").name) == 'zip' 162 | 163 | } 164 | 165 | 166 | def "check packaging without architecture information"() { 167 | 168 | given: "a cpp project of type 'capplication' version '1.0' without cla " 169 | project.with { 170 | apply plugin: "fr.echoes.gradle.cpp" 171 | version = "1.0" 172 | 173 | CppPluginExtension cpp = project.extensions["cpp"] 174 | 175 | cpp.with { 176 | applicationType "capplication" 177 | 178 | } 179 | } 180 | copy() 181 | 182 | 183 | when: "I launch the distZip task" 184 | project.evaluate() 185 | Zip distZip = project.tasks["distZip"] 186 | distZip.execute() 187 | 188 | then: "the produced archive must the base name 'test-1.0'" 189 | FilenameUtils.getBaseName(new File(projectDir, "build/distributions/test-1.0.zip").name) == 'test-1.0' 190 | 191 | } 192 | 193 | def cleanup() { 194 | println('Cleaning up after a test!') 195 | project.tasks["clean"].execute() 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /src/test/groovy/fr/echoes/gradle/plugins/cpp/DownloadLibTaskSpec.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp 2 | 3 | import fr.echoes.gradle.plugins.cpp.extensions.CppPluginExtension 4 | import org.gradle.api.Project 5 | import org.gradle.api.tasks.TaskExecutionException 6 | import org.gradle.testfixtures.ProjectBuilder 7 | import org.junit.Rule 8 | import org.junit.rules.TemporaryFolder 9 | import spock.lang.Ignore 10 | import spock.lang.Shared 11 | import spock.lang.Specification 12 | 13 | /** 14 | * test the downloadLib task 15 | * Created by jguidoux on 03/09/15. 16 | */ 17 | class DownloadLibTaskSpec extends Specification { 18 | 19 | 20 | @Rule 21 | TemporaryFolder tempFolder 22 | 23 | @Shared 24 | def projectDir 25 | 26 | @Shared 27 | Project project 28 | 29 | def setup() { 30 | projectDir = tempFolder.newFolder("dlLibProjectTest") 31 | project = ProjectBuilder.builder().withProjectDir(projectDir).build() 32 | } 33 | 34 | 35 | def "download junit in extlib folder"() { 36 | 37 | given: "the project depend of 'junit' version '4.11'" 38 | project.with { 39 | 40 | apply plugin: "fr.echoes.gradle.cpp" 41 | 42 | repositories { 43 | repositories.mavenCentral() 44 | repositories.mavenLocal() 45 | } 46 | 47 | dependencies { 48 | compile "junit:junit:4.11" 49 | } 50 | 51 | } 52 | 53 | 54 | when: "I launch the task 'downloadLibs' task" 55 | project.tasks["downloadLibs"].execute() 56 | def extLib = new File(projectDir, "build/extLib") 57 | def junitDir = new File(extLib, "junit-4.11") 58 | 59 | 60 | then: "the directory 'build/extLib/junit-4.11' must exist" 61 | junitDir.exists() 62 | junitDir.isDirectory() 63 | extLib.list().length ==1 64 | 65 | } 66 | 67 | @Ignore 68 | def "download junit in custom extlib folder"() { 69 | 70 | given: "when I set lib folden in 'tartenpion'" 71 | project.with { 72 | apply plugin: "fr.echoes.gradle.cpp" 73 | 74 | repositories { 75 | repositories.mavenCentral() 76 | } 77 | 78 | configurations { 79 | compile { 80 | description = 'compile classpath' 81 | transitive = false 82 | } 83 | } 84 | 85 | CppPluginExtension cpp = project.extensions["cpp"] 86 | 87 | cpp.outPutDirs[CppPluginUtils.EXT_LIB_DIR] = "tartenpion" 88 | 89 | dependencies { 90 | compile "junit:junit:4.11" 91 | } 92 | 93 | 94 | } 95 | 96 | 97 | when: "I launch the task 'downloadLibs' task" 98 | project.evaluate() 99 | project.tasks["downloadLibs"].execute() 100 | def extLib = new File(projectDir, "build/tartenpion") 101 | def junitDir = new File(extLib, "junit-4.11") 102 | 103 | 104 | then: "the directory 'build/tartenpion/junit-4.11' must exist" 105 | junitDir.exists() 106 | junitDir.isDirectory() 107 | extLib.list().length == 1 108 | 109 | 110 | } 111 | 112 | @Ignore 113 | def "download junit in custom extlib folder and old extlib folder does not exist"() { 114 | 115 | given: 116 | project.with { 117 | apply plugin: "fr.echoes.gradle.cpp" 118 | 119 | repositories { 120 | repositories.mavenCentral() 121 | } 122 | 123 | configurations { 124 | compile { 125 | description = 'compile classpath' 126 | transitive = false 127 | } 128 | } 129 | 130 | CppPluginExtension cpp = project.extensions["cpp"] 131 | 132 | cpp.outPutDirs[CppPluginUtils.EXT_LIB_DIR] = "tartenpion" 133 | 134 | dependencies { 135 | compile "junit:junit:4.11" 136 | } 137 | 138 | 139 | } 140 | 141 | 142 | when: 143 | project.tasks["downloadLibs"].execute() 144 | def extLib = new File(projectDir, "build/extLib") 145 | 146 | 147 | then: 148 | !extLib.exists() 149 | 150 | 151 | } 152 | 153 | 154 | @Ignore 155 | def "download junit in custom extlib bad syntax folder"() { 156 | 157 | given: 158 | project.with { 159 | apply plugin: "fr.echoes.gradle.cpp" 160 | 161 | repositories { 162 | repositories.mavenCentral() 163 | } 164 | 165 | configurations { 166 | compile { 167 | description = 'compile classpath' 168 | transitive = false 169 | } 170 | } 171 | 172 | CppPluginExtension cpp = project.extensions["cpp"] 173 | 174 | cpp.extLibPath = "etiae teauisrt aieut13»" 175 | 176 | dependencies { 177 | compile "junit:junit:4.11" 178 | } 179 | 180 | 181 | } 182 | 183 | 184 | when: 185 | project.tasks["downloadLibs"].execute() 186 | def extLib = new File(projectDir, "build/extLib") 187 | 188 | 189 | then: 190 | thrown TaskExecutionException 191 | 192 | 193 | } 194 | 195 | def cleanup() { 196 | println('Cleaning up after a test!') 197 | project.tasks["clean"].execute() 198 | } 199 | 200 | 201 | } 202 | -------------------------------------------------------------------------------- /src/test/groovy/fr/echoes/gradle/plugins/cpp/InitOutputDirsTaskSpec.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp 2 | 3 | import org.gradle.api.Project 4 | import org.gradle.testfixtures.ProjectBuilder 5 | import org.junit.Rule 6 | import org.junit.rules.TemporaryFolder 7 | import spock.lang.Shared 8 | import spock.lang.Specification 9 | 10 | /** 11 | * Created by jguidoux on 10/09/15. 12 | */ 13 | class InitOutputDirsTaskSpec extends Specification { 14 | 15 | 16 | @Rule 17 | TemporaryFolder tempFolder 18 | 19 | @Shared 20 | def projectDir 21 | 22 | @Shared 23 | Project project 24 | 25 | def setup() { 26 | projectDir = tempFolder.newFolder("initOutputProjectTest") 27 | project = ProjectBuilder.builder().withProjectDir(projectDir).build() 28 | } 29 | 30 | 31 | def "test build dir is initialised"() { 32 | given: "a gradle project applying che fr.echoes.gradle.cpp" 33 | project.with { 34 | apply plugin: "fr.echoes.gradle.cpp" 35 | } 36 | 37 | when: "when gradle evaluate the file build.gradle" 38 | project.tasks["initOutputDirs"].execute() 39 | 40 | 41 | then: "directories 'build/main-obj', 'build/main-obj', 'build/report', 'build/tmp', 'build/tmp/lib' " 42 | project.buildDir.exists() 43 | new File(project.buildDir, "main-obj").exists() 44 | new File(project.buildDir, "test-obj").exists() 45 | new File(project.buildDir, "reports").exists() 46 | new File(project.buildDir, "tmp").exists() 47 | new File(project.buildDir, "tmp/lib").exists() 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/test/groovy/fr/echoes/gradle/plugins/cpp/ProjectTaskSpec.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp 2 | 3 | import fr.echoes.gradle.plugins.cpp.tasks.CppExecTask 4 | import org.gradle.api.Project 5 | import org.gradle.api.tasks.TaskCollection 6 | import org.gradle.testfixtures.ProjectBuilder 7 | import org.junit.Rule 8 | import org.junit.rules.TemporaryFolder 9 | import spock.lang.Shared 10 | import spock.lang.Specification 11 | 12 | /** 13 | * Created by jguidoux on 07/09/15. 14 | */ 15 | class ProjectTaskSpec extends Specification { 16 | 17 | 18 | @Rule 19 | TemporaryFolder tempFolder 20 | 21 | @Shared 22 | def projectDir 23 | 24 | @Shared 25 | Project project 26 | 27 | def setup() { 28 | projectDir = tempFolder.newFolder("dlLibProjectTest") 29 | project = ProjectBuilder.builder().withProjectDir(projectDir).build() 30 | } 31 | 32 | def "find all tasks of type CppExecTask"() { 33 | 34 | given: "a gradle project applying che fr.echoes.gradle.cpp" 35 | project.with { 36 | apply plugin: "fr.echoes.gradle.cpp" 37 | } 38 | 39 | when: "I ask for task of type 'CppExecTask'" 40 | TaskCollection tasks = project.tasks.withType(CppExecTask) 41 | tasks.each { println it.name } 42 | 43 | then: "the list must contain the 'compileCpp'" 44 | tasks.getByName("compileCpp") 45 | } 46 | 47 | def "check tasks dependencies"() { 48 | 49 | given: "a gradle project applying che fr.echoes.gradle.cpp" 50 | project.with { 51 | apply plugin: "fr.echoes.gradle.cpp" 52 | } 53 | 54 | when: "when gradle evaluate the file build.gradle" 55 | project.evaluate() 56 | 57 | 58 | println project.tasks["build"].dependsOn.asList() 59 | 60 | then: "The Directed Acyclic Graph of task must be correct" 61 | project.tasks["copyHeaders"].dependsOn.contains project.tasks["initOutputDirs"] 62 | project.tasks["downloadLibs"].dependsOn.contains project.tasks["initOutputDirs"] 63 | project.tasks["compileCpp"].dependsOn.contains project.tasks["downloadLibs"] 64 | project.tasks["testCompileCpp"].dependsOn.contains project.tasks["compileCpp"] 65 | project.tasks["testCpp"].dependsOn.contains project.tasks["testCompileCpp"] 66 | project.tasks["check"].dependsOn.contains project.tasks["testCpp"] 67 | project.tasks["distZip"].dependsOn.contains project.tasks["copyHeaders"] 68 | project.tasks["uploadArchives"].dependsOn.contains project.tasks["build"] 69 | 70 | 71 | } 72 | 73 | def clean() { 74 | println('Cleaning up after a test!') 75 | project.tasks["clean"].execute() 76 | 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/test/groovy/fr/echoes/gradle/plugins/cpp/UploadArchivesTaskSpec.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp 2 | 3 | import fr.echoes.gradle.plugins.cpp.extensions.CppPluginExtension 4 | import org.apache.commons.io.FileUtils 5 | import org.gradle.api.Project 6 | import org.gradle.testfixtures.ProjectBuilder 7 | import org.junit.Rule 8 | import org.junit.rules.TemporaryFolder 9 | import spock.lang.Shared 10 | import spock.lang.Specification 11 | 12 | /** 13 | * Created by jguidoux on 05/09/15. 14 | */ 15 | class UploadArchivesTask extends Specification { 16 | 17 | @Rule 18 | TemporaryFolder tempFolder 19 | 20 | @Shared 21 | def projectDir 22 | @Shared 23 | Project project 24 | 25 | def setup() { 26 | projectDir = tempFolder.newFolder("uploadTest") 27 | project = ProjectBuilder.builder().withProjectDir(projectDir).build() 28 | } 29 | 30 | def "check upload archives"() { 31 | given: 32 | project.with { 33 | apply plugin: "fr.echoes.gradle.cpp" 34 | version = "1.0-SNAPSHOT" 35 | group = "com.tocea" 36 | 37 | CppPluginExtension cpp = project.extensions["cpp"] 38 | 39 | cpp.with { 40 | applicationType "clibrary" 41 | classifier "lin_x86_64" 42 | } 43 | 44 | uploadArchives { 45 | repositories { 46 | mavenDeployer { 47 | repository(url: "file://${buildDir}/repo") 48 | } 49 | } 50 | } 51 | } 52 | copy() 53 | 54 | when: 55 | project.evaluate() 56 | project.tasks["distZip"].execute() 57 | project.tasks["distTar"].execute() 58 | def uploadTask = project.tasks["uploadArchives"] 59 | uploadTask.execute() 60 | 61 | then: 62 | 63 | new File("${project.buildDir}/repo/com/tocea/test/1.0-SNAPSHOT/"). 64 | list().any { it ==~ /test-1.0-.*-lin_x86_64.clib/ } 65 | 66 | 67 | } 68 | 69 | def "check upload archives 2"() { 70 | given: 71 | project.with { 72 | apply plugin: "fr.echoes.gradle.cpp" 73 | version = "1.0-SNAPSHOT" 74 | group = "com.tocea" 75 | 76 | CppPluginExtension cpp = project.extensions["cpp"] 77 | 78 | cpp.applicationType "clibrary" 79 | 80 | 81 | cpp.classifier "lin_x86_64" 82 | 83 | 84 | uploadArchives { 85 | repositories { 86 | mavenDeployer { 87 | repository(url: "file://${buildDir}/repo") 88 | } 89 | } 90 | } 91 | } 92 | copy() 93 | 94 | when: 95 | project.evaluate() 96 | project.tasks["distZip"].execute() 97 | project.tasks["distTar"].execute() 98 | def uploadTask = project.tasks["uploadArchives"] 99 | uploadTask.execute() 100 | 101 | then: 102 | 103 | new File("${project.buildDir}/repo/com/tocea/test/1.0-SNAPSHOT/"). 104 | list().any { it ==~ /test-1.0-.*-lin_x86_64.clib/ } 105 | 106 | 107 | } 108 | 109 | def copy() { 110 | FileUtils.copyDirectory(new File("src/test/resources/distZipTest"), new File(projectDir, "build/tmp")) 111 | } 112 | 113 | def cleanup() { 114 | println('Cleaning up after a test!') 115 | project.tasks["clean"].execute() 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/test/groovy/fr/echoes/gradle/plugins/cpp/UtilsSpec.groovy: -------------------------------------------------------------------------------- 1 | package fr.echoes.gradle.plugins.cpp 2 | 3 | import spock.lang.Specification 4 | 5 | 6 | /** 7 | * Created by jguidoux on 07/09/15. 8 | */ 9 | class UtilsSpec extends Specification{ 10 | 11 | class Person { 12 | def name 13 | } 14 | 15 | def "add age property to a class"() { 16 | 17 | given: "a person call 'halyna'" 18 | def person = new Person(name: "halyna") 19 | 20 | when: "I had dinamically the age attribute to 'halyna' ste at '2'" 21 | person.metaClass.age = 2 22 | 23 | then: "'halyna age must be '2'" 24 | person.age == 2 25 | } 26 | 27 | def "find properties number when added dinamcally"() { 28 | 29 | given: "a person call 'halyna'" 30 | def person = new Person(name: "halyna") 31 | 32 | when: "I had dinamically the age attribute to 'halyna' ste at '2'" 33 | person.metaClass.age = 2 34 | 35 | println "mon nom est ${person.name}" 36 | 37 | 38 | then: "'halyna properties must contain the 'age' attribute" 39 | person.properties.containsKey("age") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/resources/distZipTest/headers/hello/hello.h: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/test/resources/distZipTest/lib/hello/Hello.so: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d %5p | %t | %-55logger{55} | %m %n 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /systemTests.gradle: -------------------------------------------------------------------------------- 1 | 2 | 3 | //////////////// test hello-world project ////////////////////// 4 | 5 | task helloWorldTest(type: Exec) { 6 | workingDir 'exemples/hello-world' 7 | commandLine './gradlew' 8 | args '-q', 'clean', 'run' 9 | standardOutput = new ByteArrayOutputStream() 10 | } 11 | 12 | helloWorldTest << { 13 | assert standardOutput.toString().contains('Hello, world!\n') 14 | } 15 | 16 | 17 | //////////////// test hello-world-with-libray project ////////////////////// 18 | 19 | 20 | task installHelloLibrary(type: Exec) { 21 | workingDir 'exemples/hello-world-with-libraries/hello-library/' 22 | commandLine './gradlew' 23 | args '-q', 'clean', 'install' 24 | 25 | } 26 | 27 | 28 | task runHelloMain(type: Exec, dependsOn: installHelloLibrary) { 29 | workingDir 'exemples/hello-world-with-libraries/hello-main/' 30 | commandLine './gradlew' 31 | args '-q', 'clean', 'run' 32 | standardOutput = new ByteArrayOutputStream() 33 | } 34 | 35 | runHelloMain << { 36 | assert standardOutput.toString().contains('Hello, world!\n') 37 | } 38 | 39 | 40 | task helloWordWithDependenciesTest(dependsOn: runHelloMain) 41 | 42 | 43 | //////////////// test hello-world-multi-modules project ////////////////////// 44 | 45 | task helloWorldMulitModulesTest(type: Exec) { 46 | workingDir 'exemples/hello-world-multi-modules' 47 | commandLine './gradlew' 48 | args '-q', 'clean', 'run' 49 | standardOutput = new ByteArrayOutputStream() 50 | } 51 | 52 | 53 | helloWorldMulitModulesTest << { 54 | println standardOutput.toString() 55 | assert standardOutput.toString().contains('Hello, world!\n') 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /update-gh-pages.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then 3 | echo -e "Starting to update gh-pages\n" 4 | 5 | # load gradle.properties 6 | . ./gradle.properties 7 | 8 | #copy data we're interested in to other place 9 | cp -R build/spock-reports $HOME/spock-reports 10 | cp -R build/docs/groovydoc $HOME/groovydoc 11 | 12 | 13 | #go to home and setup git 14 | cd $HOME 15 | git config --global user.email "travis@travis-ci.org" 16 | git config --global user.name "Travis" 17 | 18 | #using token clone gh-pages branch 19 | git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/Tocea/gradle-cpp-plugin.git gh-pages > /dev/null 20 | 21 | #go into diractory and copy data we're interested in to that directory 22 | cd gh-pages 23 | 24 | ## test reports ############ 25 | if [ ! -d "spock-reports/$version" ]; then 26 | # Control will enter here if $DIRECTORY exists. 27 | mkdir -p "spock-reports/$version" 28 | fi 29 | cp -Rf $HOME/spock-reports/* "spock-reports/$version" 30 | 31 | ## groovyDoc reports ############ 32 | cd $HOME 33 | cd gh-pages 34 | if [ ! -d "groovydoc/$version" ]; then 35 | # Control will enter here if $DIRECTORY exists. 36 | mkdir -p "groovydoc/$version" 37 | fi 38 | cp -Rf $HOME/groovydoc/* "groovydoc/$version" 39 | 40 | #add, commit and push files 41 | git add -f . 42 | git commit -m "Travis build $TRAVIS_BUILD_NUMBER pushed to gh-pages" 43 | git push -fq origin gh-pages > /dev/null 44 | 45 | echo -e "Done magic with spock-reports\n" 46 | fi 47 | --------------------------------------------------------------------------------