Skip to content

Commit

Permalink
Merge branch 'feature/serialio' (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
djungelorm committed Nov 2, 2017
2 parents ec6fcbb + 7638bd8 commit 9ea2a87
Show file tree
Hide file tree
Showing 182 changed files with 7,751 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -4,7 +4,7 @@ services:
- docker

install:
- docker pull krpc/buildenv:1.3.0
- docker pull krpc/buildenv:1.4.0

before_script:
- ./tools/travis-ci/set-version.py
Expand Down
15 changes: 11 additions & 4 deletions BUILD
Expand Up @@ -107,13 +107,15 @@ pkg_zip(
'//service/RemoteTech',
'//service/UI',
# Clients
'//client/python',
'//client/cnano',
'//client/cpp',
'//client/csharp',
'//client/lua',
'//client/java',
'//client/lua',
'//client/python',
# Schema
'//protobuf:krpc.proto',
'//protobuf:cnano',
'//protobuf:cpp',
'//protobuf:csharp',
'//protobuf:java',
Expand Down Expand Up @@ -145,8 +147,9 @@ pkg_zip(
'service/UI/': 'GameData/kRPC/',
'service/UI/CHANGES.txt': 'GameData/kRPC/CHANGES.UI.txt',
# Clients
'client/csharp/': 'client/',
'client/cnano/': 'client/',
'client/cpp/': 'client/',
'client/csharp/': 'client/',
'client/java/': 'client/',
'client/lua/': 'client/',
'client/python/': 'client/',
Expand All @@ -168,12 +171,14 @@ test_suite(
'//service/KerbalAlarmClock:test',
'//service/RemoteTech:test',
'//service/UI:test',
'//client/csharp:test',
'//client/cnano:test',
'//client/cpp:test',
'//client/csharp:test',
'//client/java:test',
'//client/lua:test',
'//client/python:test',
'//client/websockets:test',
'//client/serialio:test',
'//tools/krpctest:test',
'//tools/krpctools:test',
'//tools/ServiceDefinitions:test',
Expand All @@ -188,10 +193,12 @@ test_suite(
tests = [
'//server:ci-test',
'//client/csharp:ci-test',
'//client/cnano:ci-test',
'//client/cpp:ci-test',
'//client/java:ci-test',
'//client/lua:ci-test',
'//client/python:ci-test',
'//client/serialio:ci-test',
'//client/websockets:ci-test',
'//tools/krpctest:ci-test',
'//doc:ci-test'
Expand Down
52 changes: 52 additions & 0 deletions WORKSPACE
Expand Up @@ -28,6 +28,46 @@ new_http_archive(
sha256 = '7d8a42ae38fec3ca09833ea16f1d83a049f0580929c3b057042e006105ad864b'
)

new_http_archive(
name = 'protoc_nanopb',
build_file_content = """
filegroup(
name = 'plugin',
srcs = ['generator'],
visibility = ['//visibility:public']
)
""",
url = 'https://jpa.kapsi.fi/nanopb/download/nanopb-0.3.8-linux-x86.tar.gz',
sha256 = 'f4604648448987b3a469e0a1a217ec8a9defa77f5d59a34db2d5ce61c3a4e5d5',
strip_prefix = 'nanopb-0.3.8-linux-x86'
)

new_http_archive(
name = 'c_nanopb',
build_file_content = """
exports_files([
'LICENSE.txt', 'pb.h', 'pb_common.h', 'pb_common.c', 'pb_encode.h', 'pb_encode.c', 'pb_decode.h', 'pb_decode.c'
])
cc_library(
name = 'nanopb',
srcs = ['pb.h', 'pb_common.h', 'pb_common.c', 'pb_encode.h', 'pb_encode.c', 'pb_decode.h', 'pb_decode.c'],
hdrs = ['pb.h', 'pb_common.h', 'pb_encode.h', 'pb_decode.h'],
includes = ['./'],
visibility = ['//visibility:public']
)
filegroup(
name = 'srcs',
srcs = glob(['*.h', '*.c']),
visibility = ['//visibility:public']
)
""",
url = 'https://jpa.kapsi.fi/nanopb/download/nanopb-0.3.8.tar.gz',
sha256 = '2072d93c8b59cf3c89beb725589d0824766421745f5b81bde2fd784db0fd6aec',
strip_prefix = 'nanopb'
)

http_file(
name = 'csharp_nuget',
url = 'https://dist.nuget.org/win-x86-commandline/v3.4.4/NuGet.exe',
Expand All @@ -48,6 +88,12 @@ http_file(
sha256 = '496bf64ad9887c539cf7cc070d7e42edd4c8a8534286179431971ffa62ec3e4c'
)

http_file(
name = 'csharp_krpc_io_ports',
url = 'https://github.com/krpc/krpc-io-ports/releases/download/v1.0.0/KRPC.IO.Ports.dll',
sha256 = '558b0c1649fbc44b518d9de8957fe30e7c9c42d73c62d63d165f6f136fab3ec5'
)

new_http_archive(
name = 'csharp_nunit',
build_file_content = """
Expand Down Expand Up @@ -467,6 +513,12 @@ http_file(
sha256 = '9c443e7324ba5b85070c4a818ade28bfabedf16ea10206da1132edaa6dda237e'
)

http_file(
name = 'python_serialio',
url = 'https://pypi.python.org/packages/cc/74/11b04703ec416717b247d789103277269d567db575d2fd88f25d9767fe3d/pyserial-3.4.tar.gz',
sha256 = 'e17c4687fddd6d70a6604ac0ad25e33324cec71b5137267dd5c45e103c4b288a'
)

http_file(
name = 'python_setuptools',
url = 'https://pypi.python.org/packages/a4/c8/9a7a47f683d54d83f648d37c3e180317f80dc126a304c45dc6663246233a/setuptools-36.5.0.zip',
Expand Down
195 changes: 195 additions & 0 deletions client/cnano/BUILD
@@ -0,0 +1,195 @@
load('/tools/build/autotools', 'autotools_dist')
load('/tools/build/cpp', 'cpp_check_test', 'cpp_lint_test')
load('/tools/build/protobuf/nanopb', 'protobuf_nanopb')
load('/tools/build/client_test', 'client_test')
load('/tools/krpctools/clientgen', 'clientgen_cnano')
load('/tools/build/pkg', 'pkg_zip')
load('/config', 'version')

name = 'krpc-cnano-%s' % version

autotools_dist(
name = 'cnano',
out = '%s.zip' % name,
source_dir = name,
files = glob(['include/**/*.h', 'src/*.c', '**/Makefile.am']) + [
'//:readme', '//:version', 'CHANGES.txt', 'INSTALL.txt',
'LICENSE', '//:COPYING', '//:COPYING.LESSER',
':autotools',
':cmake',
':protobuf',
':services-krpc',
':services-spacecenter',
':services-drawing',
':services-infernalrobotics',
':services-kerbalalarmclock',
':services-remotetech',
':services-ui',
'@c_nanopb//:LICENSE.txt',
'@c_nanopb//:pb.h',
'@c_nanopb//:pb_common.h',
'@c_nanopb//:pb_common.c',
'@c_nanopb//:pb_encode.h',
'@c_nanopb//:pb_encode.c',
'@c_nanopb//:pb_decode.h',
'@c_nanopb//:pb_decode.c'
],
path_map = {
'../c_nanopb/LICENSE.txt': '%s/LICENSE.nanopb' % name,
'../c_nanopb/*.h': '%s/include/' % name,
'../c_nanopb/*.c': '%s/src/' % name,
'client/cnano/': '%s/' % name,
'COPYING': '%s/COPYING' % name,
'COPYING.LESSER': '%s/COPYING.LESSER' % name,
'README.txt': '%s/README.txt' % name,
'VERSION.txt': '%s/VERSION.txt' % name
},
visibility = ['//:__pkg__']
)

genrule(
name = 'autotools',
srcs = ['configure.ac.tmpl'],
outs = ['configure.ac'],
cmd = 'sed \'s/%VERSION%/'+version+'/g\' "$<" > "$@"'
)

genrule(
name = 'cmake',
srcs = ['CMakeLists.txt.tmpl'],
outs = ['CMakeLists.txt'],
cmd = 'sed \'s/%VERSION%/'+version+'/g\' "$<" > "$@"'
)

clientgen_cnano(
name = 'services-krpc',
service = 'KRPC',
defs = '//server:ServiceDefinitions',
out = 'include/krpc/services/krpc.h'
)

clientgen_cnano(
name = 'services-spacecenter',
service = 'SpaceCenter',
defs = '//service/SpaceCenter:ServiceDefinitions',
out = 'include/krpc/services/space_center.h'
)

clientgen_cnano(
name = 'services-drawing',
service = 'Drawing',
defs = '//service/Drawing:ServiceDefinitions',
out = 'include/krpc/services/drawing.h'
)

clientgen_cnano(
name = 'services-infernalrobotics',
service = 'InfernalRobotics',
defs = '//service/InfernalRobotics:ServiceDefinitions',
out = 'include/krpc/services/infernal_robotics.h'
)

clientgen_cnano(
name = 'services-kerbalalarmclock',
service = 'KerbalAlarmClock',
defs = '//service/KerbalAlarmClock:ServiceDefinitions',
out = 'include/krpc/services/kerbal_alarm_clock.h'
)

clientgen_cnano(
name = 'services-remotetech',
service = 'RemoteTech',
defs = '//service/RemoteTech:ServiceDefinitions',
out = 'include/krpc/services/remote_tech.h'
)

clientgen_cnano(
name = 'services-ui',
service = 'UI',
defs = '//service/UI:ServiceDefinitions',
out = 'include/krpc/services/ui.h'
)

clientgen_cnano(
name = 'services-test-service',
service = 'TestService',
defs = '//tools/TestServer:ServiceDefinitions',
out = 'test/services/test_service.h'
)

srcs = glob(['src/**/*.c'])
hdrs = glob(['include/**/*.h']) + [
':services-krpc',
':services-spacecenter',
':services-drawing',
':services-infernalrobotics',
':services-kerbalalarmclock',
':services-remotetech',
':services-ui'
]

cc_library(
name = 'krpc',
srcs = srcs + [':protobuf'],
hdrs = hdrs + [':protobuf'],
includes = ['include'],
deps = ['@c_nanopb//:nanopb'],
visibility = ['//visibility:public']
)

test_suite(
name = 'test',
tests = [':client', ':check', ':lint']
)

test_suite(
name = 'ci-test',
tests = [':client']
)

client_test(
name = 'client',
test_executable = ':cnanotest',
server_executable = '//tools/TestServer',
server_type = 'serialio',
tags = ['requires-network', 'local'],
size = 'small'
)

test_srcs = glob(['test/test_*.cpp', 'test/*.hpp']) + [':services-test-service']

cc_binary(
name = 'cnanotest',
srcs = test_srcs,
includes = ['test'],
deps = [':krpc', '@cpp_googletest//:gtest', '@cpp_googletest//:gmock']
)

cpp_check_test(
name = 'check',
srcs = srcs + test_srcs,
hdrs = hdrs,
includes = ['include'],
size = 'small'
)

cpp_lint_test(
name = 'lint',
srcs = srcs + test_srcs,
hdrs = hdrs,
includes = ['include'],
filters = ['+build/include_alpha', '-legal/copyright', '-readability/todo', '-readability/casting', '-build/header_guard'],
extra_files = ['include/krpc/services/CPPLINT.cfg', 'test/services/CPPLINT.cfg'],
size = 'small'
)

#TODO: use targets in //protobuf:... instead of the following
protobuf_nanopb(
name = 'protobuf',
header = 'include/krpc/krpc.pb.h',
source = 'src/krpc.pb.c',
include = 'krpc/krpc.pb.h',
src = '//protobuf:krpc.proto',
options = 'src/krpc.options'
)
exports_files(['src/krpc.options'])
2 changes: 2 additions & 0 deletions client/cnano/CHANGES.txt
@@ -0,0 +1,2 @@
v0.4.0
* Initial version
21 changes: 21 additions & 0 deletions client/cnano/CMakeLists.txt.tmpl
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 2.8.4)
project(kRPC-cnano)

set(VERSION_NUMBER %VERSION%)
set(CMAKE_BUILD_TYPE "Release")

include_directories(include include/krpc)

file(GLOB SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c")
add_library(krpc_cnano STATIC ${SRC})

set_target_properties(
krpc_cnano PROPERTIES VERSION ${VERSION_NUMBER}
SOVERSION ${VERSION_NUMBER}
INSTALL_NAME_DIR lib)

install(TARGETS krpc_cnano
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

install(DIRECTORY include DESTINATION . FILES_MATCHING PATTERN "*.h")

0 comments on commit 9ea2a87

Please sign in to comment.