Permalink
Browse files

Update to use new features in bfg9000 v0.3

  • Loading branch information...
jimporter committed Mar 29, 2017
1 parent 43d41d7 commit 949cd34571137ee7b640583626f236a9bd2d8c3b
Showing with 75 additions and 47 deletions.
  1. +11 −7 .travis.yml
  2. +13 −11 appveyor.yml
  3. +26 −18 build.bfg
  4. +11 −8 doc/install.md
  5. +4 −0 options.bfg
  6. +10 −3 scripts/vendorize_bencode.py
View
@@ -187,7 +187,9 @@ matrix:
addons: *clang-50
- compiler: gcc
env: COMPILER=g++-7 BACKEND=make BUILD_ARGS="-j4" EXTRAFLAGS=-Wsuggest-override
env: >
COMPILER=g++-7 BACKEND=make BUILD_ARGS="-j4"
EXTRAFLAGS=-Wsuggest-override
addons: *gcc-7
# macOS builds
@@ -196,7 +198,9 @@ matrix:
env: PYTHON=python2 PIP=pip2 COMPILER=clang++ BACKEND=ninja
- os: osx
env: PYTHON=python2 PIP=pip2 COMPILER=clang++ BACKEND=ninja EXTRAFLAGS=-DMETTLE_NO_STDLIB_EXTS
env: >
PYTHON=python2 PIP=pip2 COMPILER=clang++ BACKEND=ninja
EXTRAFLAGS=-DMETTLE_NO_STDLIB_EXTS
before_install:
- |
@@ -210,8 +214,8 @@ before_install:
fi
- ${PIP} install bfg9000
script:
- ${PYTHON} scripts/vendorize_bencode.py
- |
CXX=${COMPILER} CPPFLAGS="${COMMONFLAGS} ${EXTRAFLAGS}" 9k build --backend=${BACKEND}
cd build
${BACKEND} test ${BUILD_ARGS}
- >
CXX=${COMPILER} CPPFLAGS="${COMMONFLAGS} ${EXTRAFLAGS}"
9k build --vendorize --backend=${BACKEND}
- cd build
- ${BACKEND} test ${BUILD_ARGS}
View
@@ -1,25 +1,27 @@
build: false
version: "{branch}-{build}"
image:
- Visual Studio 2015
environment:
BOOST_INCLUDEDIR: C:\Libraries\boost_1_59_0
BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib32-msvc-14.0
PYTHON: C:\Python27
VS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
BOOST_INCLUDEDIR: C:\Libraries\boost_1_67_0
BOOST_LIBRARYDIR: C:\Libraries\boost_1_67_0\lib32-msvc-14.0
PYTHON_PATH: C:\Python27
matrix:
- VS: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat
BOOST_INCLUDEDIR: C:\Libraries\boost_1_59_0
BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib32-msvc-14.0
cache:
- C:\ProgramData\chocolatey\bin -> appveyor.yml
- C:\ProgramData\chocolatey\lib -> appveyor.yml
install:
- cinst ninja
- call "%VS%" x86
- cl.exe
- set PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
- set PATH=%PYTHON_PATH%;%PYTHON_PATH%\Scripts;%PATH%
- pip install bfg9000
- cinst ninja
- python scripts\vendorize_bencode.py
test_script:
- set CPPFLAGS=/WX
- 9k build --backend=ninja
- 9k build --vendorize --backend=ninja
- cd build
- ninja test
View
@@ -2,39 +2,47 @@
from os.path import splitext
bfg9000_required_version('>=0.2.0')
bfg9000_required_version('>=0.3.0')
project('mettle', version='1.0pre')
if env.builder('c++').flavor == 'msvc':
global_options(['/EHsc'], lang='c++')
else:
global_options(['-pthread', '-std=c++14'], lang='c++')
if env.platform.name != 'darwin':
global_link_options(['-pthread'])
global_options(['-std=c++14'], lang='c++')
includes = header_directory('include', include='*.hpp')
boost = boost_package(version='>=1.55')
pthread = [package('pthread')] if env.platform.flavor == 'posix' else []
if find_files('include', 'bencode.hpp', flat=True):
bencode = []
elif argv.vendorize:
bencode = []
env.run(source_file('scripts/vendorize_bencode.py'))
else:
bencode = [package('bencode', headers='bencode.hpp', libs=None)]
boost_hdrs = boost_package(version='>=1.55')
iostreams = boost_package('iostreams', version='>=1.55')
prog_opts = boost_package('program_options', version='>=1.55')
libmettle = shared_library(
'mettle',
files=find_files('src/libmettle', '*.cpp', extra='*.hpp'),
include=includes,
packages=[iostreams, prog_opts],
includes=includes,
packages=pthread + bencode + [iostreams, prog_opts],
)
mettle_objs = object_files(
files=find_files('src/mettle', '*.cpp', extra='*.hpp'),
include=includes,
packages=boost,
includes=includes,
packages=bencode + [iostreams, prog_opts],
)
mettle = executable(
'mettle',
files=mettle_objs,
libs=[libmettle],
packages=[iostreams, prog_opts],
packages=bencode + [iostreams, prog_opts],
)
install(mettle, libmettle, includes)
@@ -49,34 +57,34 @@ extra_pkgs = {
'test/driver/test_cmd_line.cpp': [prog_opts],
'test/driver/test_test_file.cpp': [prog_opts],
'test/driver/test_run_test_files.cpp': [iostreams, prog_opts],
'test/posix/test_subprocess.cpp': pthread,
}
driver = test_driver(
mettle,
options=['--output=verbose'],
[mettle, '--output=verbose'],
environment={'TEST_DATA': 'test_data'},
)
for src in find_files('test', '*.cpp', extra='*.hpp'):
test(executable(
splitext(src)[0],
files=[src] + [mettle_objs[i] for i in extra_files.get(src, [])],
include=includes,
includes=includes,
libs=libmettle,
packages=[boost] + extra_pkgs.get(src, []),
packages=bencode + [boost_hdrs] + extra_pkgs.get(src, []),
), driver=driver)
test_data = alias('test-data', [
executable(splitext(src)[0], files=src, include=includes, libs=libmettle,
packages=boost)
executable(splitext(src)[0], files=src, includes=includes, libs=libmettle,
packages=boost_hdrs)
for src in find_files('test_data', '*.cpp', extra='*.hpp')
])
test_deps(test_data)
header_only_examples = ['examples/test_02_header_only.cpp']
alias('examples', [
executable(splitext(src)[0], files=src, include=includes,
executable(splitext(src)[0], files=src, includes=includes,
libs=None if src in header_only_examples else libmettle,
packages=boost)
packages=boost_hdrs)
for src in find_files('examples', '*.cpp', extra='*.hpp')
])
View
@@ -12,14 +12,17 @@ already have Boost and a C++14 compiler (we'll discuss all of these parts in
more detail below):
```sh
cd path/to/mettle
scripts/vendorize_bencode.py
pip install bfg9000
9k build/
cd path/to/mettle
9k build/ --vendorize
cd build/
ninja install
```
!!! note
If you already have [bencode.hpp](https://github.com/jimporter/bencode.hpp)
installed, you can remove `--vendorize` from the above commands.
## Dependencies
Before you get started with mettle, you'll need to install its dependencies:
@@ -69,10 +72,10 @@ can replace this with any other build system bfg supports.
Building with bfg9000 is straightforward. Just run the following:
```sh
$ cd path/to/mettle/
$ 9k build/
$ cd build/
$ ninja install
cd path/to/mettle/
9k build/
cd build/
ninja install
```
You can specify the compiler to use and its options with the usual (Unix-style)
@@ -87,7 +90,7 @@ test framework otherwise!) To build and run all the tests, just call the
following from the build directory:
```sh
$ ninja test
ninja test
```
If you'd rather build the tests *without* running them, you can call
View
@@ -0,0 +1,4 @@
# -*- python -*-
argument('vendorize', action='store_true',
help='vendorize the bencode library')
@@ -14,7 +14,7 @@
except ImportError:
from urllib import urlopen
srcdir = os.path.realpath(os.path.join(__file__, '..', '..'))
srcdir = os.path.normpath(os.path.join(__file__, '..', '..'))
bencode_version = '0.1'
bencode_name = 'bencode_hpp-{}'.format(bencode_version)
@@ -23,8 +23,15 @@
name=bencode_name)
if __name__ == '__main__':
print('Fetching {}'.format(bencode_url))
f = urlopen(bencode_url)
with tarfile.open(mode='r:gz', fileobj=BytesIO(f.read())) as tar:
src = tar.extractfile('{}/include/bencode.hpp'.format(bencode_name))
with open(os.path.join(srcdir, 'include', 'bencode.hpp'), 'wb') as dst:
src_name = '{}/include/bencode.hpp'.format(bencode_name)
print('Extracting {}'.format(src_name))
src = tar.extractfile(src_name)
dst_name = os.path.join(srcdir, 'include', 'bencode.hpp')
with open(dst_name, 'wb') as dst:
print('Copying to {}'.format(dst_name))
shutil.copyfileobj(src, dst)

0 comments on commit 949cd34

Please sign in to comment.