Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bearssl MacOS #1

Open
wants to merge 2 commits into
base: bearssl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ BUILD_CMD = LOG=$$($(CMD) 2>&1) ; if [ $$? -eq 1 ]; then $(PRINT_ERROR); elif [
BUILD_CMD_ = LOG=$$($(CMD) 2>&1) ; if [ $$? -eq 1 ]; then $(PRINT_ERROR_); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING_); else $(PRINT_OK_); fi;


UNAME=$(shell uname)

ifeq ($(UNAME),Darwin)
IS_MACOS := true
endif

define themisecho
@tput setaf 6
@echo $1
Expand All @@ -63,6 +69,12 @@ endif
#default engine
ifeq ($(PREFIX),)
PREFIX = /usr

# MacOS
ifdef IS_MACOS
PREFIX = /usr/local
endif

endif

#engine selection block
Expand All @@ -88,6 +100,25 @@ endif
endif
#end of engine selection block


# search for OpenSSL headers for MacOS
ifdef IS_MACOS
ifeq ($(CRYPTO_ENGINE_PATH),openssl)

# if brew is installed, if openssl is installed
PACKAGELIST = $(shell brew list | grep 'openssl')
ifeq ($(PACKAGELIST),openssl)

# path to openssl (usually "/usr/local/opt/openssl")
OPENSSL_PATH := $(shell brew --prefix openssl)
ifneq ($(OPENSSL_PATH),)
CRYPTO_ENGINE_INCLUDE_PATH = $(OPENSSL_PATH)/include
CRYPTO_ENGINE_LIB_PATH = $(OPENSSL_PATH)/lib
endif
endif
endif
endif

CRYPTO_ENGINE = $(SRC_PATH)/soter/$(CRYPTO_ENGINE_PATH)
CFLAGS += -D$(CRYPTO_ENGINE_DEF) -DCRYPTO_ENGINE_PATH=$(CRYPTO_ENGINE_PATH)

Expand Down Expand Up @@ -140,14 +171,12 @@ endif

SHARED_EXT = so

UNAME=$(shell uname)
IS_LINUX = $(shell $(CC) -dumpmachine 2>&1 | $(EGREP) -c "linux")
IS_MINGW = $(shell $(CC) -dumpmachine 2>&1 | $(EGREP) -c "mingw")
IS_CLANG_COMPILER = $(shell $(CC) --version 2>&1 | $(EGREP) -i -c "clang version")

ifeq ($(shell uname),Darwin)
SHARED_EXT = dylib
PREFIX = /usr/local
ifneq ($(SDK),)
SDK_PLATFORM_VERSION=$(shell xcrun --sdk $(SDK) --show-sdk-platform-version)
XCODE_BASE=$(shell xcode-select --print-path)
Expand Down Expand Up @@ -245,11 +274,11 @@ soter_shared: CMD = $(CC) -shared -o $(BIN_PATH)/lib$(SOTER_BIN).$(SHARED_EXT) $

soter_shared: $(SOTER_OBJ)
@echo -n "link "
ifeq ($(shell uname),Darwin)
@$(BUILD_CMD)
ifdef IS_MACOS
@install_name_tool -id "$(PREFIX)/lib/lib$(SOTER_BIN).$(SHARED_EXT)" $(BIN_PATH)/lib$(SOTER_BIN).$(SHARED_EXT)
@install_name_tool -change "$(BIN_PATH)/lib$(SOTER_BIN).$(SHARED_EXT)" "$(PREFIX)/lib/lib(SOTER_BIN).$(SHARED_EXT)" $(BIN_PATH)/lib$(SOTER_BIN).$(SHARED_EXT)
endif
@$(BUILD_CMD)

themis_static: CMD = $(AR) rcs $(BIN_PATH)/lib$(THEMIS_BIN).a $(THEMIS_OBJ)

Expand All @@ -261,11 +290,11 @@ themis_shared: CMD = $(CC) -shared -o $(BIN_PATH)/lib$(THEMIS_BIN).$(SHARED_EXT)

themis_shared: soter_shared $(THEMIS_OBJ)
@echo -n "link "
ifeq ($(shell uname),Darwin)
@$(BUILD_CMD)
ifdef IS_MACOS
@install_name_tool -id "$(PREFIX)/lib/lib$(THEMIS_BIN).$(SHARED_EXT)" $(BIN_PATH)/lib$(THEMIS_BIN).$(SHARED_EXT)
@install_name_tool -change "$(BIN_PATH)/lib$(THEMIS_BIN).$(SHARED_EXT)" "$(PREFIX)/lib/lib$(THEMIS_BIN).$(SHARED_EXT)" $(BIN_PATH)/lib$(THEMIS_BIN).$(SHARED_EXT)
endif
@$(BUILD_CMD)

themis_jni: CMD = $(CC) -shared -o $(BIN_PATH)/lib$(THEMIS_JNI_BIN).$(SHARED_EXT) $(THEMIS_JNI_OBJ) -L$(BIN_PATH) -l$(THEMIS_BIN) -l$(SOTER_BIN)

Expand Down
80 changes: 1 addition & 79 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,95 +1,17 @@
machine:
environment:
ANDROID_NDK_ROOT: $ANDROID_NDK
GOTHEMIS_IMPORT: github.com/cossacklabs/themis/gothemis

## Customize dependencies
dependencies:
pre:
- sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get -y install php5 cmake libssl-dev python3 python3-setuptools ruby ninja-build lcov build-essential valgrind
- sudo ln -sf /usr/bin/gcov-4.9 /usr/bin/gcov
- cd $HOME && wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz && tar xf go1.6.2.linux-amd64.tar.gz
- gem install coveralls-lcov

override:
# - make
# - make JAVA_HOME=/usr/lib/jvm/default-java themis_jni
# - sudo make install
# - sudo make themispp_install
# - sudo make pythemis_install
# - sudo make rubythemis_install
# - sudo make phpthemis_install

#main (openssl)
- make test

#boringssl
# - cd $HOME && git clone https://boringssl.googlesource.com/boringssl && cd boringssl && git checkout chromium-stable && mkdir build && cd build && cmake .. && make && cp decrepit/libdecrepit.a crypto/
# - cd $HOME/boringssl && mkdir build-armeabi-v7a && cd build-armeabi-v7a && cmake -DANDROID_ABI=armeabi-v7a -DCMAKE_TOOLCHAIN_FILE=../third_party/android-cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=16 -GNinja .. && ninja
# - cd $HOME/boringssl && mkdir build-arm64-v8a && cd build-arm64-v8a && cmake -DANDROID_ABI=arm64-v8a -DCMAKE_TOOLCHAIN_FILE=../third_party/android-cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=16 -GNinja .. && ninja
# - cd $HOME/boringssl && mkdir build-x86 && cd build-x86 && cmake -DANDROID_ABI=x86 -DCMAKE_TOOLCHAIN_FILE=../third_party/android-cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=16 -GNinja .. && ninja
# - make ENGINE=boringssl ENGINE_INCLUDE_PATH=$HOME/boringssl/include ENGINE_LIB_PATH=$HOME/boringssl/build/crypto BUILD_PATH=build_with_boringssl test

#libsoduim
- cd $HOME && git clone https://github.com/jedisct1/libsodium --branch stable && cd libsodium && ./configure --enable-shared=no && make
- make ENGINE=libsodium ENGINE_INCLUDE_PATH=$HOME/libsodium/src/libsodium/include/ ENGINE_LIB_PATH=$HOME/libsodium/src/libsodium/.libs/ BUILD_PATH=build_with_libsodium test

#bearssl
- cd $HOME && git clone https://www.bearssl.org/git/BearSSL bearssl && cd bearssl && make lib
- make ENGINE=bearssl ENGINE_INCLUDE_PATH=$HOME/bearssl/inc/ ENGINE_LIB_PATH=$HOME/bearssl/build/ BUILD_PATH=build_with_bearssl test


#code coverage
# - make BUILD_PATH=cover_build COVERAGE=y test
# - make themispp_test
# - make test_all
# - mkdir -p $HOME/gopath/src/$GOTHEMIS_IMPORT
# - rsync -auv gothemis/ $HOME/gopath/src/$GOTHEMIS_IMPORT/
# - lcov --directory . --zerocounters

## Customize test commands
test:
override:

#main (openssl)
- build/tests/soter_test
- build/tests/themis_test
# - valgrind build/tests/soter_test 2>&1 | grep "ERROR SUMMARY\|definitely lost\|indirectly lost\|possibly lost" | awk '{sum += $4} END {exit sum}'
# - valgrind build/tests/themis_test 2>&1 | grep "ERROR SUMMARY\|definitely lost\|indirectly lost\|possibly lost" | awk '{sum += $4} END {exit sum}'

#code coverage
# - cover_build/tests/soter_test
# - cover_build/tests/themis_test
# - lcov --directory . --capture --output-file coverage.info
# - lcov --remove coverage.info 'tests/*' 'src/soter/openssl/*' '/usr/*' --output-file coverage.info
# - lcov --list coverage.info
# - coveralls-lcov -v --repo-token $COVERALLS_TOKEN coverage.info

#boringssl
# - build_with_boringssl/tests/soter_test
# - build_with_boringssl/tests/themis_test

#libsodium
- build_with_libsodium/tests/soter_test
- build_with_libsodium/tests/themis_test

#bearssl
- build_with_bearssl/tests/soter_test
- build_with_bearssl/tests/themis_test

# - build/tests/themispp_test
# - sudo /sbin/ldconfig
# - build/tests/pythemis_test.sh
# - sudo build/tests/rubythemis_test.sh
# - build/tests/phpthemis_test.sh
# - export GOROOT=$HOME/go && export GOPATH=$HOME/gopath && $GOROOT/bin/go test -v $GOTHEMIS_IMPORT/...
# - build/tests/node.sh
# - tests/check_ios_test.sh `tests/start_ios_test.sh`
# start Android emulator
# - emulator -avd circleci-android22 -no-audio -no-window:
# background: true
# wait for it to have booted
# - circle-android wait-for-boot
# run Android tests
# - ./gradlew --info -Pboringssl_path=$HOME/boringssl connectedAndroidTest

- build_with_bearssl/tests/themis_test