Skip to content

Commit

Permalink
Merge pull request #7 from steinwurf/add-cmake
Browse files Browse the repository at this point in the history
add cmake
  • Loading branch information
jpihl committed Nov 20, 2019
2 parents dfdfdbc + 2fd98bd commit 091775e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,9 @@
cmake_minimum_required (VERSION 3.10)
project(aybabtu)

file(GLOB_RECURSE aybabtu_sources ./src/*.cpp)

add_library(aybabtu STATIC ${aybabtu_sources})
add_library(steinwurf::aybabtu ALIAS aybabtu)

target_include_directories(aybabtu INTERFACE src/)
2 changes: 1 addition & 1 deletion NEWS.rst
Expand Up @@ -6,7 +6,7 @@ every change, see the Git log.

Latest
------
* tbd
* Minor: Added cmake build file.

2.0.0
-----
Expand Down
15 changes: 14 additions & 1 deletion README.rst
Expand Up @@ -4,7 +4,7 @@ aybabtu

.. image:: https://travis-ci.org/steinwurf/aybabtu.svg?branch=master
:target: https://travis-ci.org/steinwurf/aybabtu
|

.. image:: http://www.allyourbasearebelongtous.com/gif/allyourbase.gif
:target: https://en.wikipedia.org/wiki/All_your_base_are_belong_to_us

Expand All @@ -19,3 +19,16 @@ Usage
=====

See the ``example.cpp`` for an example on how to use the library.

Use as Dependency in CMake
==========================

To depend on this project when using the CMake build system, add the following
in your CMake build script:

::

add_subdirectory("/path/to/aybabtu" aybabtu)
target_link_libraries(<my_target> steinwurf::aybabtu)

Where ``<my_target>`` is replaced by your target.
22 changes: 20 additions & 2 deletions buildbot.py
Expand Up @@ -3,15 +3,17 @@

import sys
import json
import os
import shutil
import subprocess

project_name = 'aybabtu'


def run_command(args):
def run_command(args, env_ext={}):
print("Running: {}".format(args))
sys.stdout.flush()
subprocess.check_call(args)
subprocess.check_call(args, env=dict(os.environ.copy(), **env_ext))


def get_tool_options(properties):
Expand Down Expand Up @@ -80,6 +82,20 @@ def install(properties):
run_command(command)


def cmake(properties):
build_path = 'build'
if os.path.exists(build_path):
print("Path '{}' already exists - removing".format(build_path))
shutil.rmtree(build_path)
os.mkdir(build_path)

old_cwd = os.getcwd()
os.chdir(build_path)
run_command(['cmake', '../'], env_ext={'VERBOSE': '1'})
run_command(['cmake', '--build', '.'], env_ext={'VERBOSE': '1'})
os.chdir(old_cwd)


def coverage_settings(options):
options['required_line_coverage'] = 100.0

Expand All @@ -102,6 +118,8 @@ def main():
run_tests(properties)
elif cmd == 'install':
install(properties)
elif cmd == 'cmake':
cmake(properties)
else:
print("Unknown command: {}".format(cmd))

Expand Down
8 changes: 4 additions & 4 deletions src/aybabtu/base64.cpp
Expand Up @@ -65,10 +65,10 @@ std::vector<uint8_t> base64::decode(const std::string& encoded_data)
uint8_t b[4];
for (uint32_t i = 0U; i < encoded_data.length(); i += 4)
{
b[0] = base64_chars.find(encoded_data[i]);
b[1] = base64_chars.find(encoded_data[i + 1]);
b[2] = base64_chars.find(encoded_data[i + 2]);
b[3] = base64_chars.find(encoded_data[i + 3]);
b[0] = (uint8_t)base64_chars.find(encoded_data[i]);
b[1] = (uint8_t)base64_chars.find(encoded_data[i + 1]);
b[2] = (uint8_t)base64_chars.find(encoded_data[i + 2]);
b[3] = (uint8_t)base64_chars.find(encoded_data[i + 3]);
result.push_back((b[0] << 2) | (b[1] >> 4));
if (b[2] < 64)
{
Expand Down

0 comments on commit 091775e

Please sign in to comment.