Skip to content

Commit

Permalink
Merge pull request #53 from simelo/stdevMac_t51_skyapi_make_targets
Browse files Browse the repository at this point in the history
fixes #51 Skyapi make targets
  • Loading branch information
olemis authored May 25, 2019
2 parents 61c743a + 8f7873f commit 03040c8
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 107 deletions.
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ install:
- go get github.com/gz-c/gox
- go get -t ./...
- make install-linters
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
sudo apt-get install cmake ;
fi
- make install-deps-libc
- make install-lib-curl
- make install-deps-skyapi
script:
- make check
- make build-skyapi
- make lint
- make test-libc
- make lint-libc
- make test-skyapi

before_deploy:
- export VERSION="$(git describe --tags --exact-match HEAD 2> /dev/null)"
- export ARCH="$(uname -m)"
Expand Down
10 changes: 0 additions & 10 deletions .travis/install_lib_curl.sh

This file was deleted.

64 changes: 46 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DEFAULT_GOAL := help
.PHONY: test-libc test-lint build-libc check
.PHONY: test-libc test-lint build-libc check build build-skyapi test-skyapi
.PHONY: install-linters format clean-libc format-libc lint-libc docs

COIN ?= skycoin
Expand All @@ -23,6 +23,9 @@ SKYVENDOR_REL_PATH = $(SKYSRC_REL_PATH)/vendor
# Compilation output for libskycoin
BUILD_DIR = build
BUILDLIB_DIR = $(BUILD_DIR)/libskycoin
BUILDLIBSKYAPI_DIR = $(BUILD_DIR)/libskyapi
LIBNAME_Linux = libskyapi.so
LIBNAME_Darwin = libskyapi.dylib
LIB_DIR = lib
BIN_DIR = bin
DOC_DIR = docs
Expand Down Expand Up @@ -99,7 +102,12 @@ build-libc-shared: $(BUILDLIB_DIR)/libskycoin.so ## Build libskycoin C shared li

build-libc: configure-build build-libc-static build-libc-shared ## Build libskycoin C client libraries

build: build-libc ## Build all C libraries
build-skyapi: ## Build skyapi(libcurl based) library
(cd lib/curl && bash ./install_lib_curl.sh)
mkdir -p ./build/libskyapi
cp lib/curl/build/$(LIBNAME_$(UNAME_S)) ./build/libskyapi

build: build-libc build-skyapi ## Build libraries

## Build libskycoin C client library and executable C test suites
## with debug symbols. Use this target to debug the source code
Expand All @@ -115,6 +123,10 @@ test-libc: build-libc ## Run tests for libskycoin C client library
$(LDPATHVAR)="$(LDPATH):$(BUILD_DIR)/usr/lib:$(BUILDLIB_DIR)" $(BIN_DIR)/test_libskycoin_shared
$(LDPATHVAR)="$(LDPATH):$(BUILD_DIR)/usr/lib" $(BIN_DIR)/test_libskycoin_static

test-skyapi: build-skyapi ## Run test for skyapi(libcurl based) library

test: test-libc test-skyapi ## Run all test for libskycoin

docs-skyapi: ## Generate SkyApi (libcurl) documentation
openapi-generator generate -g html2 -i lib/swagger/skycoin.v0.25.1.openapi.v2.yml -o $(LIBCURLDOC_DIR)

Expand All @@ -136,7 +148,7 @@ lint-libc: format-libc
clang-tidy lib/cgo/tests/*.c -- $(LIBC_FLAGS) -Wincompatible-pointer-types


check: lint test-libc lint-libc ## Run tests and linters
check: lint test-libc lint-libc test-skyapi ## Run tests and linters

install-linters-Linux: ## Install linters on GNU/Linux
sudo apt-get update
Expand All @@ -155,40 +167,56 @@ install-deps-Linux: ## Install deps on GNU/Linux
install-deps-Darwin: ## Install deps on Mac OSX
brew install $(PKG_LIB_TEST)

install-libraries-deps: ## Install deps for lib\curl wrapper of Skycoin REST API
if [[ "$(UNAME_S)" == "Linux" ]]; then (cd build && wget --no-check-certificate https://cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz && echo "f3546812c11ce7f5d64dc132a566b749 *cmake-3.3.2-Linux-x86_64.tar.gz" > cmake_md5.txt && md5sum -c cmake_md5.txt && tar -xvf cmake-3.3.2-Linux-x86_64.tar.gz > /dev/null && mv cmake-3.3.2-Linux-x86_64 cmake-install && PATH=$(pwd)/build/cmake-install:$(pwd)/build/cmake-install/bin:$PATH ) ; fi
(cd build && wget http://curl.haxx.se/download/curl-7.58.0.tar.gz && tar -xvf curl-7.58.0.tar.gz && cd curl-7.58.0/ && bash ./configure && make && sudo make install)
if [[ "$(UNAME_S)" == "Darwin" ]]; then brew install curl ; fi
# install uncrustify
(cd build && git clone https://github.com/uncrustify/uncrustify.git)
(cd build/uncrustify && mkdir build && cd build && cmake .. && make && sudo make install)

install-linters: install-linters-$(UNAME_S) ## Install linters
go get -u github.com/FiloSottile/vendorcheck
cat ./ci-scripts/install-golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.10.2

install-deps-libc: install-deps-libc-$(OSNAME) install-libraries-deps
install-deps-skyapi-Linux:
mkdir -p deps
sudo add-apt-repository ppa:george-edison55/cmake-3.x -y
sudo apt-get update
sudo apt-get install cmake
sudo apt-get install libcurl3-gnutls
sudo apt remove curl
(cd deps && wget http://curl.haxx.se/download/curl-7.58.0.tar.gz && tar -xvf curl-7.58.0.tar.gz && cd curl-7.58.0/ && ./configure && make && sudo make install)
(cd deps && git clone https://github.com/uncrustify/uncrustify.git && cd uncrustify && mkdir build && cd build && cmake .. && make && sudo make install)

install-deps-skyapi-Darwin:
export LDFLAGS="-L/usr/local/opt/curl/lib"
export CPPFLAGS="-I/usr/local/opt/curl/include"
mkdir -p deps
brew update
brew install openssl curl uncrustify || true
(cd deps && wget http://curl.haxx.se/download/curl-7.58.0.tar.gz && tar -xf curl-7.58.0.tar.gz && cd curl-7.58.0/ && mkdir build && cd build && cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .. && make && sudo make install)

install-deps-libc-linux: configure-build ## Install locally dependencies for testing libskycoin
install-deps-libc: install-deps-libc-$(UNAME_S) ## Install deps for libc

install-deps-skyapi: install-deps-skyapi-$(UNAME_S) ## Install skyapi(libcurl based) library.

install-deps-libc-Linux: configure-build ## Install locally dependencies for testing libskycoin
wget -c https://github.com/libcheck/check/releases/download/0.12.0/check-0.12.0.tar.gz
tar -xzf check-0.12.0.tar.gz
cd check-0.12.0 && ./configure --prefix=/usr --disable-static && make && sudo make install

install-lib-curl: ## Install Sky Api curl based rest wrapper
bash .travis/install_lib_curl.sh

install-deps-libc-osx: configure-build ## Install locally dependencies for testing libskycoin
install-deps-libc-Darwin: configure-build ## Install locally dependencies for testing libskycoin
brew install check

install-deps: install-deps-libc install-deps-skyapi ## Install deps for libc and skyapi

format: ## Formats the code. Must have goimports installed (use make install-linters).
goimports -w -local github.com/skycoin/skycoin ./lib

clean-libc: ## Clean files generate by library
clean-libc: ## Clean files generated by libc
rm -rfv $(BUILDLIB_DIR)
rm -rfv bin
rm -rfv qemu_test_libskycoin*
rm -rfv include/libskycoin.h

clean-skyapi: ## Clean files generated by skyapi
rm -rfv $(BUILDLIBSKYAPI_DIR)

clean: clean-libc clean-skyapi ## Clean all files generated by libraries

format-libc:
$(PKG_CLANG_FORMAT) -sort-includes -i -assume-filename=.clang-format lib/cgo/tests/*.c
$(PKG_CLANG_FORMAT) -sort-includes -i -assume-filename=.clang-format include/*.h
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,26 @@ All these make rules require skycoin to be a git submodule of libskycoin
| :------------- | :----------: |
|build-libc-static |Build libskycoin C static library|
|build-libc-shared |Build libskycoin C shared library|
|build-libc |Build libskycoin C client libraries|
|build |Build all C libraries
|build-libc |Build libskycoin C client libraries|
|build-skyapi |Build skyapi(libcurl based) library|
|test |Run all test for libskycoin|
|test-libc |Run tests for libskycoin C client library|
|test-skyapi |Run test for skyapi(libcurl based) library|
|docs |Generate documentation for all libraries|
|docs-libc |Generate libskycoin documentation|
|docs-skyapi |Generate SkyApi (libcurl) documentation|
|lint |Run linters. Use make install-linters first.|
|check |Run tests and linters|
|install-libraries-deps |Install deps for `lib\curl` wrapper of Skycoin REST API|
|install-deps |Install deps for libc and skyapi|
|install-deps-libc |Install deps for libc|
|install-deps-skyapi |Install skyapi(libcurl based) library.|
|install-linters |Install linters|
|format |Formats the code. Must have goimports installed (use make install-linters).|
|clean-libc |Clean files generate by library|

|clean |Clean all files generated by libraries(libcurl based and libc)|
|clean-libc |Clean files generated by libc|
|clean-skyapi |Clean files generated by skyapi|

## Development setup

### Running tests
Expand Down Expand Up @@ -148,3 +155,4 @@ This code example can be found at `include/cipher.bitcoin.go.h`.
Inside `/* */` we found struct documentation, meanwhile `//<` symbol is used to describe fields of the struct.

After that, run `make docs` for a new docs generation. You can found the api documentation at `docs/libc` folder.

135 changes: 65 additions & 70 deletions lib/curl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,93 +1,88 @@
cmake_minimum_required (VERSION 2.6)
project (CGenerator)
cmake_minimum_required(VERSION 2.6)
project(CGenerator)

cmake_policy(SET CMP0063 NEW)
#cmake_policy(SET CMP0063 NEW)

set(CMAKE_C_VISIBILITY_PRESET default)
set(CMAKE_CXX_VISIBILITY_PRESET default)
set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF)
#set(CMAKE_C_VISIBILITY_PRESET default)
#set(CMAKE_CXX_VISIBILITY_PRESET default)
#set(CMAKE_VISIBILITY_INLINES_HIDDEN OFF)
set(CMAKE_BUILD_TYPE Debug)

set(pkgName "skyapi")

find_package(CURL 7.58.0 REQUIRED)
if(CURL_FOUND)
include_directories(${CURL_INCLUDE_DIR})
set(PLATFORM_LIBRARIES ${PLATFORM_LIBRARIES} ${CURL_LIBRARIES} )
else(CURL_FOUND)
message(FATAL_ERROR "Could not find the CURL library and development files.")
endif()
find_package(CURL 7.58.0 EXACT REQUIRED)

set(SRCS
src/list.c
src/apiKey.c
src/apiClient.c
external/cJSON.c
model/_api_v1_explorer_address_inputs.c
model/_api_v1_explorer_address_outputs.c
model/_api_v1_explorer_address_status.c
model/_api_v1_pending_txs_transaction.c
model/_api_v1_wallet_transaction_hours_selection.c
model/_api_v1_wallet_transaction_to.c
model/_api_v1_wallet_transaction_wallet.c
model/_api_v1_wallets_entries.c
model/_api_v1_wallets_meta.c
model/inline_object.c
model/inline_response_200.c
model/inline_response_200_1.c
model/inline_response_200_2.c
model/inline_response_200_3.c
model/inline_response_200_3_unconfirmed_verify_transaction.c
model/inline_response_200_4.c
model/inline_response_200_5.c
model/inline_response_200_6.c
model/inline_response_200_7.c
model/inline_response_200_7_data.c
model/inline_response_default.c
api/DefaultAPI.c

${CMAKE_CURRENT_SOURCE_DIR}/src/list.c
${CMAKE_CURRENT_SOURCE_DIR}/src/apiKey.c
${CMAKE_CURRENT_SOURCE_DIR}/src/apiClient.c
${CMAKE_CURRENT_SOURCE_DIR}/external/cJSON.c
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_explorer_address_inputs.c
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_explorer_address_outputs.c
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_explorer_address_status.c
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_pending_txs_transaction.c
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_wallet_transaction_hours_selection.c
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_wallet_transaction_to.c
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_wallet_transaction_wallet.c
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_wallets_entries.c
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_wallets_meta.c
${CMAKE_CURRENT_SOURCE_DIR}/model/object.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_object.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_1.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_2.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_3.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_3_unconfirmed_verify_transaction.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_4.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_5.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_6.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_7.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_7_data.c
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_default.c
${CMAKE_CURRENT_SOURCE_DIR}/api/DefaultAPI.c
)

set(HDRS
include/apiClient.h
include/list.h
include/keyValuePair.h
external/cJSON.h
model/_api_v1_explorer_address_inputs.h
model/_api_v1_explorer_address_outputs.h
model/_api_v1_explorer_address_status.h
model/_api_v1_pending_txs_transaction.h
model/_api_v1_wallet_transaction_hours_selection.h
model/_api_v1_wallet_transaction_to.h
model/_api_v1_wallet_transaction_wallet.h
model/_api_v1_wallets_entries.h
model/_api_v1_wallets_meta.h
model/inline_object.h
model/inline_response_200.h
model/inline_response_200_1.h
model/inline_response_200_2.h
model/inline_response_200_3.h
model/inline_response_200_3_unconfirmed_verify_transaction.h
model/inline_response_200_4.h
model/inline_response_200_5.h
model/inline_response_200_6.h
model/inline_response_200_7.h
model/inline_response_200_7_data.h
model/inline_response_default.h
api/DefaultAPI.h

${CMAKE_CURRENT_SOURCE_DIR}/include/apiClient.h
${CMAKE_CURRENT_SOURCE_DIR}/include/list.h
${CMAKE_CURRENT_SOURCE_DIR}/include/keyValuePair.h
${CMAKE_CURRENT_SOURCE_DIR}/external/cJSON.h
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_explorer_address_inputs.h
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_explorer_address_outputs.h
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_explorer_address_status.h
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_pending_txs_transaction.h
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_wallet_transaction_hours_selection.h
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_wallet_transaction_to.h
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_wallet_transaction_wallet.h
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_wallets_entries.h
${CMAKE_CURRENT_SOURCE_DIR}/model/_api_v1_wallets_meta.h
${CMAKE_CURRENT_SOURCE_DIR}/model/object.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_object.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_1.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_2.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_3.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_3_unconfirmed_verify_transaction.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_4.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_5.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_6.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_7.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_200_7_data.h
${CMAKE_CURRENT_SOURCE_DIR}/model/inline_response_default.h
${CMAKE_CURRENT_SOURCE_DIR}/api/DefaultAPI.h
)

include_directories(${CURL_INCLUDE_DIR})
# Add library with project file with projectname as library name
add_library(${pkgName} SHARED ${SRCS} ${HDRS})
# Link dependent libraries
target_link_libraries(${pkgName} ${CURL_LIBRARIES} )
target_link_libraries(${pkgName} ${CURL_LIBRARIES})
#install library to destination
install(TARGETS ${pkgName} DESTINATION ${CMAKE_INSTALL_PREFIX})

# Setting file variables to null
set(SRCS "")
set(HDRS "")
#set(SRCS "")
#set(HDRS "")


## This section shows how to use the above compiled libary to compile the source files
Expand Down
15 changes: 15 additions & 0 deletions lib/curl/install_lib_curl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

mkdir -p build
cd build
#echo "brew --prefix curl"
#brew --prefix curl
#echo "brew ls --verbose curl"
#brew ls --verbose curl
# for normal install use following command
cmake -DCMAKE_VERBOSE_MAKEFILE=ON ..
grep -R object_convertToJSON ../../
make
sudo make install

cd ../..

0 comments on commit 03040c8

Please sign in to comment.