forked from mlcommons/mobile_app_open
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add clang-format-10 to Docker image and format code scripts (mlcommon…
…s#13) * Add clang-format-10 to Docker image and format code scripts * Added format tools to docker image Added buildifier and google-java-format to docker image Reved the docker image version to 1.0 Added script (docker_run.sh) to Run formatters with Docker image Added script to format all code Update to java 11 to support google-java-format * Remove trailing spaces * Use consistent indenting in scripts Use 4 space indents * Add missing copyright * Fix URL for java formater download * Update CONTRIBUTING.md Co-authored-by: Mark Charlebois <[email protected]>
- Loading branch information
1 parent
b470586
commit 067b1d8
Showing
13 changed files
with
196 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
# Docker image name: mlcommons/mlperf_mobile:1.0 | ||
FROM ubuntu:bionic | ||
LABEL maintainer="[email protected]" | ||
|
||
# Update the apt configuration and set timezone first or image creation waits | ||
# for selection of timezone | ||
RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y && \ | ||
apt-get install -y --no-install-recommends tzdata | ||
apt-get install -y --no-install-recommends tzdata | ||
|
||
RUN apt-get update && apt-get upgrade -y && apt-get autoremove -y && \ | ||
apt-get install -y --no-install-recommends \ | ||
python3 python3-pip libpython3.6-dev python3.6-venv libgl1-mesa-glx libglib2.0 cython3 gcc make curl unzip libc++1-8 \ | ||
git locales openssh-client ca-certificates tar gzip parallel \ | ||
zip bzip2 gnupg wget python3-six python3-pip libncurses5 openjdk-8-jdk-headless | ||
zip bzip2 gnupg wget python3-six python3-pip libncurses5 openjdk-11-jdk-headless clang-format-10 golang-1.13-go | ||
|
||
RUN pip3 install pip==19.3.1 setuptools==31.0.1 | ||
RUN pip3 install tensorflow-cpu==1.15 | ||
|
@@ -45,15 +46,16 @@ ARG android_home=/opt/android/sdk | |
|
||
# Install Android SDK and NDK | ||
RUN mkdir -p ${android_home} && \ | ||
curl --silent --show-error --location --fail --retry 3 --output /tmp/sdk_tools.zip https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip && \ | ||
unzip -q /tmp/sdk_tools.zip -d ${android_home} && \ | ||
wget -O /tmp/sdk_tools.zip https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip && \ | ||
unzip -q /tmp/sdk_tools.zip -d ${android_home}/cmdline-tools/ && \ | ||
mv ${android_home}/cmdline-tools/cmdline-tools ${android_home}/cmdline-tools/tools && \ | ||
rm /tmp/sdk_tools.zip | ||
|
||
# Set environment variables | ||
ENV ANDROID_HOME ${android_home} | ||
ENV ANDROID_NDK_HOME ${android_ndk_home} | ||
ENV ADB_INSTALL_TIMEOUT 120 | ||
ENV PATH=${ANDROID_HOME}/emulator:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools:${PATH} | ||
ENV PATH=${ANDROID_HOME}/emulator:${ANDROID_HOME}/cmdline-tools/tools/bin:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/build-tools/29.0.3:${PATH} | ||
|
||
RUN mkdir ~/.android && echo '### User Sources for Android SDK Manager' > ~/.android/repositories.cfg | ||
|
||
|
@@ -81,6 +83,13 @@ RUN cd /tmp && wget -nv https://dl.google.com/android/repository/${ndk_version} | |
|
||
ENV ANDROID_NDK_HOME ${android_ndk_home} | ||
|
||
# Add Java format checker and buildifier | ||
ENV GOBIN /opt/formatters/bin | ||
RUN mkdir -p ${GOBIN} && curl --output `dirname ${GOBIN}`/google-java-format-1.9-all-deps.jar -L https://github.com/google/google-java-format/releases/download/google-java-format-1.9/google-java-format-1.9-all-deps.jar | ||
RUN /usr/lib/go-1.13/bin/go get github.com/bazelbuild/buildtools/buildifier | ||
ENV PATH=${PATH}:${GOBIN} | ||
|
||
RUN mkdir -p /home/mlperf && chmod 777 /home/mlperf | ||
ENV HOME /home/mlperf | ||
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# Copyright 2020-2021 The MLPerf Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
########################################################################## | ||
|
||
# This script formats all staged C++ and build files. | ||
|
||
# Formatting cpp files using clang-format. | ||
cpp_files=$(find android -name "*.h" && find android -name "*.cc") | ||
if [ "$cpp_files" ]; then | ||
clang-format-10 -i -style=google $cpp_files | ||
fi | ||
|
||
# Formatting build files using buildifier. | ||
buildifier_is_present=$(which buildifier) | ||
if [ ! -x "$buildifier_is_present" ] ; then | ||
echo "*" | ||
echo "* Bazel config files can't be formated because 'buildifier' is not in \$PATH" | ||
echo "*\n" | ||
else | ||
build_files=$(echo WORKSPACE && find android -name BUILD && find android -name BUILD.bazel && find android -name "*.bzl") | ||
if [ "$build_files" ]; then | ||
buildifier -v $build_files | ||
fi | ||
fi | ||
|
||
# Formatting Java files. | ||
java_is_present=$(which java) | ||
if [ ! -x "$java_is_present" ] ; then | ||
echo "*" | ||
echo "* Java files can't be formated because 'java' is not in \$PATH" | ||
echo "*\n" | ||
else | ||
java_files=$(find android -name "*.java") | ||
if [ "$java_files" ]; then | ||
java -jar /opt/formatters/google-java-format-1.9-all-deps.jar --replace $java_files | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.