Skip to content

Commit

Permalink
ow_builder init
Browse files Browse the repository at this point in the history
  • Loading branch information
supragya committed Jun 19, 2021
1 parent 29ead14 commit f102c2b
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $ mkdir build && cd build # to create a build directory

$ cmake .. -DCMAKE_BUILD_TYPE=Release && make -j8 # to build
```
For builds in a containterized environments with compilation toolchain separate from host machines, see [ow_builder](tools/ow_builder/README.md).

## Notable binaries

Expand Down
34 changes: 34 additions & 0 deletions tools/ow_builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#we are using ubuntu base image
FROM ubuntu:18.04

# installing requirements to get and extract prebuilt binaries
RUN apt-get update && apt-get install -y \
xz-utils curl build-essential libtool sudo \
automake vim doxygen autoconf wget \
lsb-release software-properties-common \
&& rm -rf /var/lib/apt/lists/*

# setting up clang 12
RUN wget https://apt.llvm.org/llvm.sh
RUN chmod +x llvm.sh
RUN sudo ./llvm.sh 12

# setting up cmake (the bundled cmake with apt in 18.04 is too old)
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
RUN sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
RUN sudo apt update
RUN sudo apt-get install -y cmake

# set c++ and cc to clang 12
RUN sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-12 100
RUN sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-12 100

# set a distinct shell prompt
RUN echo 'export PS1="\[$(tput sgr0)\]\[$(tput bold)\][OW-BUILDER] $(tput sgr0)\]user:\u pwd:\w \\$\[$(tput sgr0)\] "' >> ~/.bashrc

# version testing script
COPY list_versions.sh .
RUN /bin/bash list_versions.sh

# start the container from bash
ENTRYPOINT [ “/bin/bash” ]
70 changes: 70 additions & 0 deletions tools/ow_builder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Intentions
To provide consistent build environment across dev machines for OpenWeaver (in Google's terms - [hermetic builds](https://sre.google/sre-book/release-engineering/)). This is done by providing the compilation toolchain under a containerized environment so that host environment toolchains do not affect the builds.

# Prerequisistes
Install docker using your package manager. For example in arch linux (using paru AUR helper):
```
paru -Sy docker
```
At the time of writing this, the following versions were found:
- containerd 1.5.2
- runc 1.0.0 rc95
- docker 20.10.7

Start the docker daemon using:
```
sudo systemctl start docker.service
```

## Build and run the container
Build the container (with pwd of shell at `Dockerfile`'s directory) using
```
sudo docker build -t ow_builder .
```
The build procedure will provide you with versions of components in one of the steps while building the container image. Verify correctness (good output should look close to the following):
```
BUILD ENVIRONMENT STATUS
Component Expected Actuals
--------- -------- -------
|- doxygen version 1.8.13 1.8.13
|- make version GNU Make 4.1 GNU Make 4.1
|- cmake version 3.20.4 cmake version 3.20.4
|- autoconf version 2.69 autoconf (GNU Autoconf) 2.69
|- glibcxx highest version <=3.4.25 GLIBCXX_3.4.25
|- c++ --version 12.0.1 Ubuntu clang version 12.0.1
|- cc --version 12.0.1 Ubuntu clang version 12.0.1
```
Remove intermediate build images using
```
sudo docker image prune -f
```
Export your Openweaver directory using:
```
export OWDIR=/home/supragya/Projects/OpenWeaver
```
Run the container using:
```
sudo docker run \
--privileged \
--interactive \
--tty \
--entrypoint /bin/bash \
--volume `echo $OWDIR`:/OpenWeaver \
--workdir /OpenWeaver \
ow_builder:latest
```
This will mount OpenWeaver onto container and start an interactive shell on the container with working directory set to OpenWeaver's dir.

**TIP**: alias the above command to some easy command with OWDIR set to a constant value to invoke the container on the go while dev.

The build commands such as
```
mkdir build && cd build
cmake .. & make -j8
```
should work now

**TIP**: The container has a distinct shell prompt of the following form to easily distinguish it from the host machine
```
[OW-BUILDER] user:root pwd:/OpenWeaver $ ...
```
10 changes: 10 additions & 0 deletions tools/ow_builder/list_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
echo "BUILD ENVIRONMENT STATUS"
echo "Component Expected Actuals"
echo "--------- -------- -------"
echo " |- doxygen version 1.8.13 $(doxygen --version)"
echo " |- make version GNU Make 4.1 $(make --version | head -1)"
echo " |- cmake version 3.20.4 $(cmake --version | head -1)"
echo " |- autoconf version 2.69 $(autoconf --version | head -1)"
echo " |- glibcxx highest version <=3.4.25 $(strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX | tail -2 | head -1)"
echo " |- c++ --version 12.0.1 $(c++ --version | head -1)"
echo " |- cc --version 12.0.1 $(cc --version | head -1)"

0 comments on commit f102c2b

Please sign in to comment.