Skip to content

Commit 1f03bec

Browse files
uilianriesaardappel
authored andcommitted
Conan build packages on CI (#4590) (#4594)
* Build Conan package on Travis CI (#4590) - Added multi package support on Linux, running on Travis CI - Only upload when branch is a tag and named "vX.Y.Z" - Replace Conan injection by Conan wrapper - Removed os_build os_arch -- Conan 1.0.1 hotfix Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on OSX (#4590) - Added jobs to build Flatbuffers on OSX running on Travis Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on Windows (#4590) - Added support necessary to build Flatbuffers on Windows (conan) - Added Appveyor jobs to build Conan package - Only build Conan package when release (tag) Signed-off-by: Uilian Ries <uilianries@gmail.com> * Reduce Conan CI support to simple scripts (#4590) - Removed msvc 10 x86_64 workaround - Updated conan remote address - Added Bincrafters' package tools Signed-off-by: Uilian Ries <uilianries@gmail.com> * Add fPIC option on Conan recipe (#4590) - Add fPIC as optional. It works on Linux and OSX - Update recipe metadata: author, homepage, license - Checking for flatc and flathash on Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com> * Build Conan package on CI (#4590) - Add rule to run conan job only for tags - Run Conan on Linux, OSX and Windows - Update package tool to new interface Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update Conan username (#4590) - Use google as default username Signed-off-by: Uilian Ries <uilianries@gmail.com> * Update OSX version on CI (#4590) - Use latest OSX 9.3 version to build Conan package Signed-off-by: Uilian Ries <uilianries@gmail.com>
1 parent c721009 commit 1f03bec

File tree

12 files changed

+257
-18
lines changed

12 files changed

+257
-18
lines changed

.travis.yml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@ env:
22
global:
33
# Set at the root level as this is ignored when set under matrix.env.
44
- GCC_VERSION="4.9"
5+
6+
conan-linux: &conan-linux
7+
os: linux
8+
sudo: required
9+
language: python
10+
python: "3.6"
11+
services:
12+
- docker
13+
install:
14+
- ./conan/travis/install.sh
15+
script:
16+
- ./conan/travis/build.sh
17+
if: tag IS present
18+
19+
conan-osx: &conan-osx
20+
os: osx
21+
language: generic
22+
install:
23+
- ./conan/travis/install.sh
24+
script:
25+
- ./conan/travis/build.sh
26+
if: tag IS present
27+
528
matrix:
629
include:
730
#- language: python
@@ -50,7 +73,7 @@ matrix:
5073

5174
script:
5275
- cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE . && make && make test
53-
- if [ "$CONAN" == "true" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo pip install conan && conan create . flatbuffers/testing -s build_type=$BUILD_TYPE; fi
76+
- if [ "$CONAN" == "true" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo pip install conan && conan create . google/testing -s build_type=$BUILD_TYPE -tf conan/test_package; fi
5477

5578
- language: cpp
5679
os: osx
@@ -62,6 +85,37 @@ matrix:
6285
script:
6386
- cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE . && make && make test
6487

88+
- <<: *conan-linux
89+
env: CONAN_GCC_VERSIONS=4.9 CONAN_DOCKER_IMAGE=lasote/conangcc49
90+
- <<: *conan-linux
91+
env: CONAN_GCC_VERSIONS=5 CONAN_DOCKER_IMAGE=lasote/conangcc5
92+
- <<: *conan-linux
93+
env: CONAN_GCC_VERSIONS=6 CONAN_DOCKER_IMAGE=lasote/conangcc6
94+
- <<: *conan-linux
95+
env: CONAN_GCC_VERSIONS=7 CONAN_DOCKER_IMAGE=lasote/conangcc7
96+
- <<: *conan-linux
97+
env: CONAN_GCC_VERSIONS=8 CONAN_DOCKER_IMAGE=lasote/conangcc8
98+
- <<: *conan-linux
99+
env: CONAN_CLANG_VERSIONS=3.9 CONAN_DOCKER_IMAGE=lasote/conanclang39
100+
- <<: *conan-linux
101+
env: CONAN_CLANG_VERSIONS=4.0 CONAN_DOCKER_IMAGE=lasote/conanclang40
102+
- <<: *conan-linux
103+
env: CONAN_CLANG_VERSIONS=5.0 CONAN_DOCKER_IMAGE=lasote/conanclang50
104+
- <<: *conan-linux
105+
env: CONAN_CLANG_VERSIONS=6.0 CONAN_DOCKER_IMAGE=lasote/conanclang60
106+
- <<: *conan-osx
107+
osx_image: xcode7.3
108+
env: CONAN_APPLE_CLANG_VERSIONS=7.3
109+
- <<: *conan-osx
110+
osx_image: xcode8.3
111+
env: CONAN_APPLE_CLANG_VERSIONS=8.1
112+
- <<: *conan-osx
113+
osx_image: xcode9
114+
env: CONAN_APPLE_CLANG_VERSIONS=9.0
115+
- <<: *conan-osx
116+
osx_image: xcode9.3
117+
env: CONAN_APPLE_CLANG_VERSIONS=9.1
118+
65119
#- language: android
66120
# sudo: true
67121
# android:

appveyor.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ environment:
1313

1414
matrix:
1515
- CMAKE_VS_VERSION: "10 2010"
16+
- CMAKE_VS_VERSION: "12 2013"
1617
- CMAKE_VS_VERSION: "14 2015"
1718

1819
platform:
@@ -32,6 +33,10 @@ build:
3233
project: ALL_BUILD.vcxproj
3334
verbosity: minimal
3435

36+
after_build:
37+
- python conan/appveyor/install.py
38+
- python conan/appveyor/build.py
39+
3540
install:
3641
- set PATH=%CONDA_INSTALL_LOCN%;%CONDA_INSTALL_LOCN%\scripts;%PATH%;
3742

conan/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
3+
message(STATUS "Conan FlatBuffers Wrapper")
4+
5+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
6+
conan_basic_setup()
7+
8+
if (WIN32 AND MSVC AND FLATBUFFERS_BUILD_SHAREDLIB)
9+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
10+
endif(WIN32 AND MSVC AND FLATBUFFERS_BUILD_SHAREDLIB)
11+
12+
include(${CMAKE_SOURCE_DIR}/CMakeListsOriginal.txt)

conan/appveyor/build.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import os
4+
5+
if os.getenv("APPVEYOR_REPO_TAG") != "true":
6+
print("Skip build step. It's not TAG")
7+
else:
8+
os.system("python conan/build.py")

conan/appveyor/install.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
import os
4+
5+
if os.getenv("APPVEYOR_REPO_TAG") != "true":
6+
print("Skip step. It's not TAG")
7+
else:
8+
os.system("pip install conan conan-package-tools")

conan/build.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
from cpt.packager import ConanMultiPackager
4+
import os
5+
6+
def set_appveyor_environment():
7+
if os.getenv("APPVEYOR") is not None:
8+
compiler_version = os.getenv("CMAKE_VS_VERSION").split(" ")[0].replace('"', '')
9+
os.environ["CONAN_VISUAL_VERSIONS"] = compiler_version
10+
os.environ["CONAN_STABLE_BRANCH_PATTERN"] = "master"
11+
ci_platform = os.getenv("Platform").replace('"', '')
12+
ci_platform = "x86" if ci_platform == "x86" else "x86_64"
13+
os.environ["CONAN_ARCHS"] = ci_platform
14+
os.environ["CONAN_BUILD_TYPES"] = os.getenv("Configuration").replace('"', '')
15+
16+
if __name__ == "__main__":
17+
login_username = os.getenv("CONAN_LOGIN_USERNAME", "aardappel")
18+
username = os.getenv("CONAN_USERNAME", "google")
19+
upload = os.getenv("CONAN_UPLOAD", "https://api.bintray.com/conan/aardappel/flatbuffers")
20+
stable_branch_pattern = os.getenv("CONAN_STABLE_BRANCH_PATTERN", r"v\d+\.\d+\.\d+.*")
21+
test_folder = os.getenv("CPT_TEST_FOLDER", os.path.join("conan", "test_package"))
22+
upload_only_when_stable = os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True)
23+
set_appveyor_environment()
24+
25+
builder = ConanMultiPackager(username=username,
26+
login_username=login_username,
27+
upload=upload,
28+
stable_branch_pattern=stable_branch_pattern,
29+
upload_only_when_stable=upload_only_when_stable,
30+
test_folder=test_folder)
31+
builder.add_common_builds(pure_c=False)
32+
builder.run()

conan/test_package/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
project(test_package CXX)
2+
cmake_minimum_required(VERSION 2.8.11)
3+
4+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
5+
conan_basic_setup()
6+
7+
add_executable(${PROJECT_NAME} test_package.cpp)
8+
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
9+
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)

conan/test_package/conanfile.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
from conans import ConanFile, CMake
5+
import os
6+
7+
8+
class TestPackageConan(ConanFile):
9+
settings = "os", "compiler", "build_type", "arch"
10+
generators = "cmake"
11+
12+
def build(self):
13+
cmake = CMake(self)
14+
cmake.configure()
15+
cmake.build()
16+
17+
def test(self):
18+
bin_path = os.path.join("bin", "test_package")
19+
self.run(bin_path, run_environment=True)
20+
self.run("flatc --version", run_environment=True)
21+
self.run("flathash fnv1_16 conan", run_environment=True)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2018 Google Inc. All rights reserved.
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+
#include <cstdlib>
18+
#include <iostream>
19+
#include "flatbuffers/util.h"
20+
21+
// Test to validate Conan package generated
22+
23+
int main(int /*argc*/, const char * /*argv*/ []) {
24+
25+
const std::string filename("conanbuildinfo.cmake");
26+
27+
if (flatbuffers::FileExists(filename.c_str())) {
28+
std::cout << "File " << filename << " exists.\n";
29+
} else {
30+
std::cout << "File " << filename << " does not exist.\n";
31+
return EXIT_FAILURE;
32+
}
33+
34+
return EXIT_SUCCESS;
35+
}

conan/travis/build.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -x
5+
6+
if [[ "$(uname -s)" == 'Darwin' ]]; then
7+
if which pyenv > /dev/null; then
8+
eval "$(pyenv init -)"
9+
fi
10+
pyenv activate conan
11+
fi
12+
13+
conan user
14+
python conan/build.py

0 commit comments

Comments
 (0)