Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 47c2367e authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

Add a notebook to explain how to set up TP, and update the README and Dockefile related to TP.

parent dd4b9189
Branches
Tags
No related merge requests found
...@@ -3,7 +3,7 @@ LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr" ...@@ -3,7 +3,7 @@ LABEL maintainer Sébastien Gilles "sebastien.gilles@inria.fr"
RUN (dnf update -y && dnf upgrade -y -q) RUN (dnf update -y && dnf upgrade -y -q)
RUN dnf install -y git cmake clang gcc gcc-c++ ninja-build wget which zsh hostname make && dnf clean packages RUN dnf install -y git cmake clang gcc gcc-c++ wget which zsh hostname make && dnf clean packages
COPY Config/zshrc /root/.zshrc COPY Config/zshrc /root/.zshrc
......
%% Cell type:markdown id: tags:
# [Getting started in C++](/) - [How to do the TP](/notebooks/TP/HowTo.ipynb)
%% Cell type:markdown id: tags:
## Introduction
TPs are interspeded throughout the lecture, and are really recommended as it is a way to check you truly assimilated what was explained in the notebooks (in programming rather often things seem easy... until you try to do them by yourself!)
There are basically three ways to do the exercices, but I will start with the one to avoid:
### Don't do the TP in Jupyter notebook!
Jupyter notebooks are a great tool to provide a decent and interactive support for lectures, and we can really thank the [guys behind Xeus-cling](https://github.com/QuantStack/xeus-cling/graphs/contributors) for their amazing work to port C++ into an interpreter-like environment.
However, it is clearly not an environment for direct development: the fact you need to restart the kernel and rerun all relevant cells each time you modify a function is extremely cumbersome during the trial-and-error that is often the implementation of code.
### Online compilers
[Coliru](https://coliru.stacked-crooked.com/) or [Wandbox](https://wandbox.org/) provides online compilers in which you may paste code, compile it and then run it.
They are clearly the easiest way to go that we recommend heavily! (except for the [TP related to file structure](/notebooks/6-InRealEnvironment/2-b-TP.ipynb) for which we will need to work locally).
### On your local machine
This implies a _recent_ compiler is already installed on your machine and ready to use.
I provide in the folder in which TPs are set a very basic and crude `CMakeLists.txt` that should provide compilation (at least on Unix systems).
### With Docker
I also provide a [Docker](https://www.docker.com/) image in which a very basic Fedora environment is displayed.
You may compile / run the code in a Docker container and edit your file in your computer environment with you favored editor / IDE.
For more informations about it please look the dedicated [README](https://gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/blob/master/TP/README.md).
%% Cell type:markdown id: tags:
© _CNRS 2016_ - _Inria 2018_
_This notebook is an adaptation of a lecture prepared and redacted by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_
_The present version has been redacted by Sébastien Gilles and Vincent Rouvreau (Inria)_
# How to use Docker for this example? # How to use Docker for TP?
First of all, make sure [Docker](https://www.docker.com/) is properly installed and running. First of all, make sure [Docker](https://www.docker.com/) is properly installed and running.
...@@ -8,10 +8,10 @@ Then to get the relevant image you may either: ...@@ -8,10 +8,10 @@ Then to get the relevant image you may either:
### Build the image from the provided Dockerfile ### Build the image from the provided Dockerfile
Type in a terminal: Type in a terminal (in the same folder this README is):
```` ````
docker build -t tp_cpp . docker build --no-cache -t tp .
```` ````
This may take few minutes. This may take few minutes.
...@@ -22,15 +22,15 @@ Type in a terminal (provided you have an account on the [Inria gitlab](https://g ...@@ -22,15 +22,15 @@ Type in a terminal (provided you have an account on the [Inria gitlab](https://g
```` ````
docker login registry.gitlab.inria.fr docker login registry.gitlab.inria.fr
docker pull registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/tp_cpp:latest docker pull registry.gitlab.inria.fr/formations/cpp/gettingstartedwithmoderncpp/tp:latest
```` ````
## Running the image ## Running the image
Go in the _Docker/ThirdPartyWarning_ folder and type: Go in the TP folder of the current TP considered (for instance `1-ProceduralProgramming/TP`) and type:
```` ````
docker run -v $PWD:/Codes/TP --cap-drop=all -it tp_cpp docker run -v $PWD:/Codes/TP --cap-drop=all -it tp
```` ````
For those of you not familiar with Docker: For those of you not familiar with Docker:
...@@ -39,5 +39,5 @@ For those of you not familiar with Docker: ...@@ -39,5 +39,5 @@ For those of you not familiar with Docker:
* `--cap-drop=all` is a safety when you're running a Docker image not built by yourself: you're essentially blocking the few remaining operations that might impact your own environment that Docker lets by default open with the run command. * `--cap-drop=all` is a safety when you're running a Docker image not built by yourself: you're essentially blocking the few remaining operations that might impact your own environment that Docker lets by default open with the run command.
* `-it` tells we want an interactive session: your terminal session will place you inside the container (here a Fedora environment). * `-it` tells we want an interactive session: your terminal session will place you inside the container (here a Fedora environment).
`tp_cpp` is a Docker **image**; the instantiation of this image obtained after the run command is a **container**. All the modifications you may do in the container won't be kept when you leave it, except the files that will have been written in your own filesystem thanks to the `-v` option. `tp` is a Docker **image**; the instantiation of this image obtained after the run command is a **container**. All the modifications you may do in the container won't be kept when you leave it, except for the files that will have been written in your own filesystem thanks to the `-v` option.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment