<commit_before># Build with
# docker build -t domos-env .

## # Run with
## # user$ docker run -it --rm --privileged --cap-add=ALL -v /lib/modules:/lib/modules buildroot
## # `--rm --privileged --cap-add=ALL` is to modprobe nfs and nfsd

FROM ubuntu:xenial

# For the proxy

# Create user
RUN useradd jedi --create-home --password jedi && echo "jedi:jedi" | chpasswd && adduser jedi sudo

RUN apt-get update
# Some utilities
RUN apt-get install -y build-essential \
	sudo \
	nano \
	vim \
	unzip \
	curl \
	wget \
	git \
  tig \
	lsb-release \
	minicom \
	silversearcher-ag \
  gdb \
# Python
	python \
	python-dev \
	python-setuptools \
# to avoid urllib warning, we need pyopenssl which needs libssl-dev + libffi-dev
	libffi-dev \
	libssl-dev \
# C++
	clang \
	cmake \
	google-mock \
# For X11 application (i.e. Clion)
  libxrender1 \
  libxtst6 \
  libxi6 \
  libfreetype6 \
  libfontconfig1

# pip
RUN easy_install pip
RUN pip install pyopenssl ndg-httpsclient pyasn1

# To use the RPi cross-compilation toolchain,
# which are composed of 32bits executables
RUN dpkg --add-architecture i386
RUN apt-get update
RUN apt-get install -y libz1:i386 libncurses5:i386 libbz2-1.0:i386 libc6:i386 libstdc++6:i386

# Install platformio
RUN pip install platformio

USER jedi
#
# RPi tool chain
#
RUN cd /home/jedi && \
	git clone https://github.com/raspberrypi/tools.git && \
	mv tools rpi-toolchain && \
	cd rpi-toolchain && \
	git checkout b65595ffb74e5853ba61916f49bdbccfc54f1300 && \
	echo "export PI_TOOLS_HOME=$HOME/rpi-toolchain" >> ~/.bashrc
ENV PI_TOOLS_HOME /home/jedi/rpi-toolchain/
ENV PI_TOOL arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64
# Retrieve the CMake toolchain configuration file
ADD https://raw.githubusercontent.com/jdmichaud/domos/master/rpi/cmaketc/Toolchain-raspberrypi-arm.cmake /home/jedi/Toolchain-raspberrypi-arm.cmake
# Give ownership of ADDED files to the user. ADD always create the user as owned by root...
USER root
RUN chown jedi /home/jedi/Toolchain-raspberrypi-arm.cmake
USER jedi
# Set cross compiler environment
ENV CROSS=/home/jedi/rpi-toolchain/${PI_TOOL}/bin/arm-linux-gnueabihf
ENV CC=$CROSS-gcc
ENV CXX=$CROSS-g++
ENV LD=$CROSS-ld
ENV AR=$CROSS-ar
ENV RANLIB=$CROSS-ranlib

#
# Google Test/Mock
#
### ARM
# Download google test/mock and compile it
RUN cd /home/jedi && wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz
USER root
RUN chown jedi /home/jedi/release-1.8.0.tar.gz
USER jedi
RUN cd /home/jedi && tar zxf release-1.8.0.tar.gz && \
  cd /home/jedi/googletest-release-1.8.0 && \
  cmake -DCMAKE_TOOLCHAIN_FILE=/home/jedi/Toolchain-raspberrypi-arm.cmake && \
  make DESTDIR=${PI_TOOLS_HOME}/${PI_TOOL} install && \
  echo '' | cat >> /home/jedi/Toolchain-raspberrypi-arm.cmake && \
  echo 'SET (ENV{GTEST_ROOT} $ENV{PI_TOOLS_HOME}/$ENV{PI_TOOL}/)' | cat >> /home/jedi/Toolchain-raspberrypi-arm.cmake
### amd64
# Google Test/Mock to compile with x86 as target
RUN cd /usr/src/gmock && cmake CMakeLists.txt && make

#<commit_msg>Run google mock X86 compilation before the configuration of the ARM toolchain.<commit_after># Build with
# docker build -t domos-env .

## # Run with
## # user$ docker run -it --rm --privileged --cap-add=ALL -v /lib/modules:/lib/modules buildroot
## # `--rm --privileged --cap-add=ALL` is to modprobe nfs and nfsd

FROM ubuntu:xenial

# For the proxy

# Create user
RUN useradd jedi --create-home --password jedi && echo "jedi:j<PASSWORD>" | chpasswd && adduser jedi sudo

RUN apt-get update
# Some utilities
RUN apt-get install -y build-essential \
	sudo \
	nano \
	vim \
	unzip \
	curl \
	wget \
	git \
  tig \
	lsb-release \
	minicom \
	silversearcher-ag \
  gdb \
# Python
	python \
	python-dev \
	python-setuptools \
# to avoid urllib warning, we need pyopenssl which needs libssl-dev + libffi-dev
	libffi-dev \
	libssl-dev \
# C++
	clang \
	cmake \
	google-mock \
# For X11 application (i.e. Clion)
  libxrender1 \
  libxtst6 \
  libxi6 \
  libfreetype6 \
  libfontconfig1

# pip
RUN easy_install pip
RUN pip install pyopenssl ndg-httpsclient pyasn1

# To use the RPi cross-compilation toolchain,
# which are composed of 32bits executables
RUN dpkg --add-architecture i386
RUN apt-get update
RUN apt-get install -y libz1:i386 libncurses5:i386 libbz2-1.0:i386 libc6:i386 libstdc++6:i386

### amd64
# Google Test/Mock to compile with x86 as target
# It will compiled for ARM later on
RUN cd /usr/src/gmock && cmake CMakeLists.txt && make

# Install platformio
RUN pip install platformio

USER jedi
#
# RPi tool chain
#
RUN cd /home/jedi && \
	git clone https://github.com/raspberrypi/tools.git && \
	mv tools rpi-toolchain && \
	cd rpi-toolchain && \
	git checkout b65595ffb74e5853ba61916f49bdbccfc54f1300 && \
	echo "export PI_TOOLS_HOME=$HOME/rpi-toolchain" >> ~/.bashrc
ENV PI_TOOLS_HOME /home/jedi/rpi-toolchain/
ENV PI_TOOL arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64
# Retrieve the CMake toolchain configuration file
ADD https://raw.githubusercontent.com/jdmichaud/domos/master/rpi/cmaketc/Toolchain-raspberrypi-arm.cmake /home/jedi/Toolchain-raspberrypi-arm.cmake
# Give ownership of ADDED files to the user. ADD always create the user as owned by root...
USER root
RUN chown jedi /home/jedi/Toolchain-raspberrypi-arm.cmake
USER jedi
# Set cross compiler environment
ENV CROSS=/home/jedi/rpi-toolchain/${PI_TOOL}/bin/arm-linux-gnueabihf
ENV CC=$CROSS-gcc
ENV CXX=$CROSS-g++
ENV LD=$CROSS-ld
ENV AR=$CROSS-ar
ENV RANLIB=$CROSS-ranlib

#
# Google Test/Mock
#
### ARM
# Download google test/mock and compile it
RUN cd /home/jedi && wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz
USER root
RUN chown jedi /home/jedi/release-1.8.0.tar.gz
USER jedi
RUN cd /home/jedi && tar zxf release-1.8.0.tar.gz && \
  cd /home/jedi/googletest-release-1.8.0 && \
  cmake -DCMAKE_TOOLCHAIN_FILE=/home/jedi/Toolchain-raspberrypi-arm.cmake && \
  make DESTDIR=${PI_TOOLS_HOME}/${PI_TOOL} install && \
  echo '' | cat >> /home/jedi/Toolchain-raspberrypi-arm.cmake && \
  echo 'SET (ENV{GTEST_ROOT} $ENV{PI_TOOLS_HOME}/$ENV{PI_TOOL}/)' | cat >> /home/jedi/Toolchain-raspberrypi-arm.cmake

#
{'fraction_non_alphanumeric': 0.12391695275461828, 'fraction_numerical': 0.026810528036619256, 'mean_word_length': 3.6, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 16, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5260224', 'n_tokens_mistral': 2513, 'n_tokens_neox': 2349, 'n_words': 582}