diff --git a/.gitignore b/.gitignore index 4be4e40..fcbf5ed 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,4 @@ tdlib.iml /build-td /build-tdnatives __pycache__ +/src/tdnatives-java/it/tdlight/tdnatives/TdApi.java diff --git a/.travis.settings.xml b/.travis.settings.xml new file mode 100644 index 0000000..9bc015e --- /dev/null +++ b/.travis.settings.xml @@ -0,0 +1,41 @@ + + + + github + + + + + github + + + central + https://repo1.maven.org/maven2 + true + true + + + github + GitHub OWNER Apache Maven Packages + https://maven.pkg.github.com/tdlight-team/tdlight-java + + + + + + + + github + Cavallium + ${env.PACKAGECLOUD_TOKEN} + + + + + + + + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e46c497 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,62 @@ +language: shell + +os: + - linux + - windows +arch: + - amd64 + - arm64 +osx_image: xcode10.1 +dist: bionic +before_install: + - cp .travis.settings.xml $HOME/.m2/settings.xml +addons: + apt: + update: true + packages: + - make + - git + - zlib1g-dev + - libssl-dev + - gperf + - php + - cmake + - g++ + - ccache + - maven + - openjdk-11-jdk + - python3 +cache: + bundler: true + cocoapods: true + ccache: true + directories: + - ".autoconf" + - "$HOME/.m2" + - "$HOME/.ccache" + +deploy: + - provider: pages + skip-cleanup: true + github-token: $GITHUB_TOKEN + keep-history: true + local-dir: out/docs + repo: tdlight-team/tdlib-docs + target_branch: master + email: andrea@cavallium.it + name: "Andrea Cavalli" + verbose: true +# - provider: script +# skip-cleanup: true +# script: "mvn -B -V deploy" + +script: | + if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + bash -e travis/linux.sh && bash -e travis/deploy_master.sh + fi + + if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then + bash travis/win.sh; + bash travis/deploy_master.sh + fi + diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..0e39b18 --- /dev/null +++ b/build.sh @@ -0,0 +1,41 @@ +#!/bin/bash -e + +# ====== Variables +export TD_SRC_DIR=${PWD}/dependencies/tdlight +export TD_BIN_DIR=${PWD}/bin-td +export TDNATIVES_BIN_DIR=${PWD}/bin-tdnatives +export TDNATIVES_CPP_SRC_DIR=${PWD}/src/tdnatives-cpp +export TDNATIVES_DOCS_BIN_DIR=${PWD}/bin-docs +export TD_BUILD_DIR=${PWD}/build-td +export TDNATIVES_CPP_BUILD_DIR=${PWD}/build-tdnatives +export JAVA_SRC_DIR=${PWD}/src/tdnatives-java +export TDLIB_SERIALIZER_DIR=${PWD}/dependencies/tdlib-serializer + +# ====== Print variables +echo "TD_SRC_DIR=${TD_SRC_DIR}" +echo "TD_BIN_DIR=${TD_BIN_DIR}" +echo "JAVA_SRC_DIR=${JAVA_SRC_DIR}" + +# ====== Cleanup + +# ====== Environment setup +mkdir $TD_BUILD_DIR || true +mkdir $TDNATIVES_CPP_BUILD_DIR || true + +# ====== Build Td +cd $TD_BUILD_DIR +cmake -DCMAKE_BUILD_TYPE=Release -DTD_ENABLE_JNI=ON -DCMAKE_INSTALL_PREFIX:PATH=${TD_BIN_DIR} ${TD_SRC_DIR} +cmake --build $TD_BUILD_DIR --target install -- -j4 + +# ====== Build TdNatives +cd $TDNATIVES_CPP_BUILD_DIR +cmake -DCMAKE_BUILD_TYPE=Release -DTD_BIN_DIR=${TD_BIN_DIR} -DTDNATIVES_BIN_DIR=${TDNATIVES_BIN_DIR} -DTDNATIVES_DOCS_BIN_DIR=${TDNATIVES_DOCS_BIN_DIR} -DTd_DIR=${TD_BIN_DIR}/lib/cmake/Td -DJAVA_SRC_DIR=${JAVA_SRC_DIR} -DTDNATIVES_CPP_SRC_DIR:PATH=$TDNATIVES_CPP_SRC_DIR $TDNATIVES_CPP_SRC_DIR +cmake --build $TDNATIVES_CPP_BUILD_DIR --target install -- -j4 + +# ====== Patch generated java code +echo "Compilation done. Patching TdApi.java" +python3 $TDLIB_SERIALIZER_DIR $JAVA_SRC_DIR/it/tdlight/tdnatives/TdApi.java $JAVA_SRC_DIR/it/tdlight/tdnatives/new_TdApi.java $TDLIB_SERIALIZER_DIR/headers.txt +rm $JAVA_SRC_DIR/it/tdlight/tdnatives/TdApi.java +unexpand --tabs=2 $JAVA_SRC_DIR/it/tdlight/tdnatives/new_TdApi.java > $JAVA_SRC_DIR/it/tdlight/tdnatives/TdApi.java +rm $JAVA_SRC_DIR/it/tdlight/tdnatives/new_TdApi.java +