diff --git a/.gitignore b/.gitignore index f39fad9224d0e6798939108d01ec5a2a665acadc..9ff8414ab6e29b400d1e3e862892f5e813f82064 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,9 @@ /platforms/* !/platforms/desktop !/platforms/android +/resources/android/build/local.properties +/resources/android/build/Cesium.keystore +/resources/android/build/release-signing.properties /plugins/ .idea/ /*.iml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f6f5b8cd44e7769a37b7363cd88e692c2a0e9cd7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,85 @@ +FROM ubuntu:16.04 +LABEL maintainer="benoit [dot] lavenier [at] e-is [dot] pro" + +ENV DEBIAN_FRONTEND=noninteractive \ + ANDROID_HOME=/opt/android-sdk-linux \ + NODE_VERSION=5.12.0 \ + NPM_VERSION=3.8.6 \ + IONIC_VERSION=1.7.16 \ + BOWER_VERSION=1.8.0 \ + CORDOVA_VERSION=6.5.0 \ + GRADLE_VERSION=4.1 \ + NDK_VERSION=r10e + +# Install basics +RUN apt-get update && \ + apt-get install -y git wget curl unzip build-essential ruby ruby-dev ruby-ffi gcc make && \ + curl --retry 3 -SLO "http://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.gz" && \ + tar -xzf "node-v$NODE_VERSION-linux-x64.tar.gz" -C /usr/local --strip-components=1 && \ + rm "node-v$NODE_VERSION-linux-x64.tar.gz" && \ + npm install -g npm@"$NPM_VERSION" && \ + npm install -g bower@"$BOWER_VERSION" cordova@"$CORDOVA_VERSION" ionic@"$IONIC_VERSION" && \ + npm cache clear --force + +# install python-software-properties (so you can do add-apt-repository) +RUN apt-get update && apt-get install -y -q python-software-properties software-properties-common && \ + add-apt-repository ppa:webupd8team/java -y && \ + echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \ + apt-get update && apt-get -y install oracle-java8-installer + +#ANDROID STUFF +RUN echo ANDROID_HOME="${ANDROID_HOME}" >> /etc/environment && \ + dpkg --add-architecture i386 && \ + apt-get update && \ + apt-get install -y --force-yes expect ant wget zipalign libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1 qemu-kvm kmod && \ + apt-get clean && \ + apt-get autoclean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Install Android SDK +RUN cd /opt && \ + wget --output-document=android-sdk.tgz --quiet http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz && \ + tar xzf android-sdk.tgz && \ + rm -f android-sdk.tgz && \ + chown -R root. /opt + +RUN cd /opt/ && \ + wget --output-document=android-ndk.zip --quiet https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux-x86_64.zip && \ + unzip android-ndk.zip && \ + rm android-ndk.zip && \ + chown -R root. /opt + +# Install Gradle +RUN wget https://services.gradle.org/distributions/gradle-"$GRADLE_VERSION"-bin.zip && \ + mkdir /opt/gradle && \ + unzip -d /opt/gradle gradle-"$GRADLE_VERSION"-bin.zip && \ + rm -rf gradle-"$GRADLE_VERSION"-bin.zip + +# Setup environment + +ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:/opt/tools:/opt/gradle/gradle-"$GRADLE_VERSION"/bin + +# Install sdk elements +COPY resources/android/build/tools /opt/tools +RUN chmod u+x /opt/tools/*.sh +RUN ["/opt/tools/android-accept-licenses.sh", "android update sdk --all --no-ui --filter platform-tools,tools,build-tools-26.0.0,android-26,build-tools-25.0.0,android-25,extra-android-support,extra-android-m2repository,extra-google-m2repository"] +RUN unzip ${ANDROID_HOME}/temp/*.zip -d ${ANDROID_HOME} + + +# Install source code +#RUN git config --global user.email "user.name@domain.com" && \ +# git config --global user.name "User Name" && \ +RUN git clone git@git.duniter.org:clients/cesium-grp/cesium.git && \ + cd cesium && \ + npm install + +# Restore cordova platforms +RUN cd cesium && \ + ionic state restore + +# TODO: Test First Build so that it will be faster later +## ionic cordova build android --prod --no-interactive --release + +WORKDIR cesium +EXPOSE 8100 35729 +CMD ["ionic", "serve"] diff --git a/doc/build_android.md b/doc/build_android.md index 6e6d5793dd16502339c5c6ac32a673ae895de806..a091842f1c6851dc8dfd4732fab3176197a9b017 100644 --- a/doc/build_android.md +++ b/doc/build_android.md @@ -73,6 +73,12 @@ Install the version that it proposes to you. - Fill in the installation path of the NDK. +### Install Gradle + +- Download [Gradle 4.1](wget https://services.gradle.org/distributions/gradle-4.1-bin.zip) + +- Uncompress the archive (e.g in `/opt/gradle`). + ## Android configuration Android need some configuration, to be able to build Cesium. @@ -102,6 +108,7 @@ storePassword=YourStorePassword keyPassword=YourKeyPassword ``` +- Open Android Studio, then open the menu `File > Settings...`. Set `Gradle Home` to your fresh Gradle installation directory (e.g. `/opt/gradle`). ## Generate APK file @@ -123,11 +130,11 @@ Generated APK files should be in the directory `platforms/android/build/outputs/ If you get this error: - ``` - Cannot run program "/opt/android-sdk/build-tools/21.1.2/aapt": error=2, No such file or folder - ``` +``` +Cannot run program "/opt/android-sdk/build-tools/21.1.2/aapt": error=2, No such file or folder +``` -Install two additional compatibility libraries (workaround found in [this post](http://stackoverflow.com/questions/22701405/aapt-ioexception-error-2-no-such-file-or-directory-why-cant-i-build-my-grad)): +Then install two additional compatibility libraries (workaround found in [this post](http://stackoverflow.com/questions/22701405/aapt-ioexception-error-2-no-such-file-or-directory-why-cant-i-build-my-grad)): ```bash sudo apt-get install lib32stdc++6 lib32z1 ``` diff --git a/doc/build_docker.md b/doc/build_docker.md new file mode 100644 index 0000000000000000000000000000000000000000..cc293414d46ae4f26b2735a8b8f752cd127001d1 --- /dev/null +++ b/doc/build_docker.md @@ -0,0 +1,20 @@ +# Cesium docker image + +## Build + +```bash + cd cesium + sudo docker build . -t cesium/release +``` + +or with interactive bash + +```bash + sudo docker build . -ti cesium/release bash +``` + +## Run + +```bash + sudo docker run -ti --net host -p 8100:8100 -p 35729:35729 -v ~/.gradle:/root/.gradle -v \$PWD:/cesium:rw --privileged cesium/release +``` \ No newline at end of file diff --git a/hooks/after_prepare/061_copy_build_extras.js b/hooks/after_prepare/061_copy_build_extras.js index 5639789121407196b51e6cf5f6c350f93c49a0e7..93f3c23af75c83a2048b2f838b2df239c7ab092a 100755 --- a/hooks/after_prepare/061_copy_build_extras.js +++ b/hooks/after_prepare/061_copy_build_extras.js @@ -23,10 +23,22 @@ if (rootdir) { console.log('-----------------------------------------'); if (fs.existsSync(android_dir) && fs.existsSync(build_dir)) { + + var mkdirp = function(dir) { + var parent = path.dirname(dir); + if (!fs.existsSync(parent)){ + mkdirp(parent); + } + if (!fs.existsSync(dir)){ + fs.mkdirSync(dir); + } + }; + glob(build_files, null, function(er, files) { files.forEach(function(file) { console.log(' Copy ' + file + ' to ' + android_dir); var dest_file = file.replace(build_dir, android_dir); + mkdirp(path.dirname(dest_file)); fs.createReadStream(file).pipe(fs.createWriteStream(dest_file)); }); }); diff --git a/ionic.project b/ionic.project index cf31b5ea331904ced0285b353a71b3f235f6acf0..ae80b1fee7bdc41e451725f7d69263b47dccf065 100644 --- a/ionic.project +++ b/ionic.project @@ -19,4 +19,4 @@ "version": "12.41.296.5" } ] -} \ No newline at end of file +} diff --git a/package.json b/package.json index 6d0f8faaa8246dccc59950ad69e05e6ec7c02968..c906defc9f04e615d5074b80b7e6b507a09e5d12 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,10 @@ "scripts": { "postinstall": "bower install --allow-root", "install-platforms": "ionic state restore", - "start": "ionic serve" + "start": "ionic serve", + "docker:build": "sudo docker build . -t cesium/release", + "docker:run": "sudo docker run -ti --rm -p 8100:8100 -p 35729:35729 -v .:/cesium:rw cesium/release", + "build:web": "config --env default && gulp build:web --release" }, "keywords": [ "duniter", diff --git a/resources/android/build/tools/android-accept-licenses.sh b/resources/android/build/tools/android-accept-licenses.sh new file mode 100644 index 0000000000000000000000000000000000000000..776adf6f4231463e4b7c19f237847873396fdbdf --- /dev/null +++ b/resources/android/build/tools/android-accept-licenses.sh @@ -0,0 +1,14 @@ +#!/usr/bin/expect -f + +set timeout 1800 +set cmd [lindex $argv 0] +set licenses [lindex $argv 1] + +spawn {*}$cmd +expect { + "Do you accept the license '*'*" { + exp_send "y\r" + exp_continue + } + eof +}