From 2224ef78793ac1e83510ccaab9214b7a9cb7a288 Mon Sep 17 00:00:00 2001 From: texhno Date: Wed, 14 Feb 2024 02:58:33 +0100 Subject: [PATCH 1/4] Add the base containerized c toolchain environment --- .gitignore | 0 README.md | 2 -- TOOLCHAIN.md | 18 ++++++++++++++++++ config/.vimrc | 7 +++++++ dmzOS/test/clang_test | Bin 0 -> 8224 bytes dmzOS/test/gcc_test | Bin 0 -> 8344 bytes dmzOS/test/test.c | 12 ++++++++++++ docker-compose.yml | 12 ++++++++++++ dockerfile.c_toolchain | 6 ++++++ 9 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 TOOLCHAIN.md create mode 100644 config/.vimrc create mode 100755 dmzOS/test/clang_test create mode 100755 dmzOS/test/gcc_test create mode 100644 dmzOS/test/test.c create mode 100644 docker-compose.yml create mode 100644 dockerfile.c_toolchain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index de0c87e..98b325b 100644 --- a/README.md +++ b/README.md @@ -20,5 +20,3 @@ Rules: * Please provide an adequate entry in the Wiki for each non-trivial code contribution. For additional information, please refer to the [Wiki](https://gitea.dmz.rs/sborovic/dmzOS/wiki). - -TEST \ No newline at end of file diff --git a/TOOLCHAIN.md b/TOOLCHAIN.md new file mode 100644 index 0000000..9970aaa --- /dev/null +++ b/TOOLCHAIN.md @@ -0,0 +1,18 @@ +# Instruction on running utilities + +## c_toolchain utility docker image + +Dockerfile: `dockerfile.c_toolchain` +Run the docker-compose command to get a `bash` shell that is bound to the `dmzOS` directory: +```bash +docker-compose run --rm c_toolchain +``` + +Any changes in the container shell will be reflected in the local `dmzOS` directory. + +The image contains `ident` abd `clang-format` as `C` code formatters. A .vimrc file is automatically part of the image, and it contains a rule to make vim run the following formatting command on buffer save: +```bash +ident -kr -ts4 % +``` + +This is using the Kernighan and Ritchie code styling, as well as identations with 4 spaces. diff --git a/config/.vimrc b/config/.vimrc new file mode 100644 index 0000000..7862ea2 --- /dev/null +++ b/config/.vimrc @@ -0,0 +1,7 @@ +set nobackup +set nowritebackup +set noswapfile +set autoread + +set number relativenumber +autocmd BufWritePost *.[ch] exec "!indent -kr -nut % && rm %~" diff --git a/dmzOS/test/clang_test b/dmzOS/test/clang_test new file mode 100755 index 0000000000000000000000000000000000000000..f4656718fd81d2e6b3c361031565fdbd89cd7b31 GIT binary patch literal 8224 zcmeHMU2Ggz6~4Rczx;T;Nt?tZ5t%}RHld!Z)7aUPmdx5-XAI6y6B`QD9k0D(d!_v` zyR%^pYH(#zSV3rCiu`~Ci04XqOkd)phNirrR6HO-kgSRb7aA~Xh^&faIp@wfyEC(E zgm^$a_^xKoJwM;M=l;yhxp%)EA0G7ke1eN#d|n_IY0{*~z6+szLb4=_iY-DD`^7%d z0+J@UG^s&q*O;!8Yo={v7XXU5sNWVu{hF*W-EWJb4ZCoJNSjG!6OA~VmRfC=DMT&> zh{ISzLCFFgmldXAiX%dlamXT0A)G=urnf0Drrba58(t&iZ^W+whrEV_qN-7}#d7Yh zm6YRxjY5gGXfFD!!5VH99Bt+`-)ZRwpvPS)5N~}1NPEGV4JCaUzrBm5r zsjC$2?dmCiZwx`aF%9e1xt3yjV)U!Wn^dH>N@6HBxdp3~wfLv){zik71 z0sWf9ZuAPXl(NKZK9#kmgkhlEC|HTSWn>bmtT;71)YoquRgbDYpqJJgW)-f(?ICswRS$D{B?6`D>#$^?kxpV9khn&|08tMxlw&~w* zZr`p5{qhaVU%9O>{Gx4H`oLSI#}BH?!6vwO9MGVK{0yo-SgAlc`0+O2v8fMk1KWLX zsQlhbdii~Q;g4(QMuu+PSZmgVe(UDEB)1eGm0dpq%>9l7144YXJf(IV_zwD${ztDx zAyWN0c`x6!_FO{^hSol|gu=>-#EmUaNqQY+qxvgb`gM_a0fh zsvfr0JP5|mKlePuB8q!P_43`-OVERNnooknH?~aiVXtd3qS@GA%FwtSGx9Ko%B}c6 zG0^hM>w3Akw(#=0zvId$G4iFR77aDxs#slmRH-cCP?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I)LXJyHpF`dp$B+^FG%H<12qF54>xy)?Z zw9KS>y!V-CVR2WNn#9`R;Ghi6Nx$Kg{82HMW*y*8uw?>}&fe6krjkr!8^nvrjI5m8>FE(tP9UQz6A2CK^ zeZz6|D$fch3q={RFwA7aO3+E7rnwIeJ;#b(H6rbEMR4mnWQ1`nsnvA&@$__7OiI$Km{5``I|Cg-vMwyBl3HIx*%7z1<= zY61aNn@w9nmHkjHvjlZq2cXNzVO7l;n)#U|V41TK_7boWTnERAOllHZ&4Dktsj>mv z8H|TeVKL&7m*Xk;@2i;q!lP1spK;#8|9f!$%PpX-vwRwuR=D_i=lq8MS5TbBQ0Mmx zi@Txn0CG&mm;9Pkl}NztGmi6FX#}?uaA8i(c+Qs=Nl+p~{7(jBXM88g`+;K4&3MkM zLX?OPkR20m|Gx+d%$XU_`PT^HIsfPQ*^cQ8fX5u1`SE}zn;Iv)A~}1X;f$ZeVj3#w zoAL96pC>%${oKB{|6eD3A35ZG#MK6P+^cx;-vSxN)k63cYJY|Bygwmz-TYtl;05O~ z6fnon_z+c?zT(02cP2vkw=p*%r^TAyF^>=N>%g!zG>&Pyc!T*e&K$m_yQZRr6;4zs+mU zJX6dEIvjY;uRGBx6t=Uu8qe}yf&xS3_Bjvd|1W}B~*Pufa#&f>DhCxAL zJDaO-|2Lp;;;VT*0mBR=%5gKjD NMGdSuokHD<{}(2V0|x*A literal 0 HcmV?d00001 diff --git a/dmzOS/test/gcc_test b/dmzOS/test/gcc_test new file mode 100755 index 0000000000000000000000000000000000000000..c246334f7735653849406240f66ea27399ea4ddf GIT binary patch literal 8344 zcmeHMYiwLc6`u9RiSzJ!>pbcth1`}zN&s)1m*dc;_4<`-a1u9lLMoD6*4}G-={~I8 zyTy(uwQyfcNt+)?gdeCv2%!`q48M#J)FD+#B!rSmh&Kd8ky8<2R2l_nyqq)leBQg) zYg!3@p^UZn%sKO&GiT1soqJ~dWM@xTRUn{Hg6cuV+<3JsX_bcK>!m`ZRkf()^n9PX zM=d3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q3{0$WTUc^>FAwQ=EXkjD;v zv4zd>=HV*PdW^XtDrGLDISX6E;O?Eg4-5kwa;4^|bZ z=G9033yS`sfOvv_(Wj3*85I6PA3W$+eEQ=OD9|7ICLI03-q(EkI6s5p90|OC{O3g< z^M^bEl=Dn)f!~mQhbrtM^!@)2d;mb9{{CO_=_B6fB!DA`F5p4`KvG_N=pW|{{2vzoZ^inA9_EqrY#t)?aUPjur>OM0 zWc~?#&^M{Yt3RJFN(bl%2A~IimMSbm|H!|>qUgu_rbE3=x-4s=pSM7Nn^#D6=zA&F wju+Yr$0cz5o#C7l{$T&)^$p+4^m((Ovc_i|{kpB38&}rvlMdzp6zbRiHz^D|^Z)<= literal 0 HcmV?d00001 diff --git a/dmzOS/test/test.c b/dmzOS/test/test.c new file mode 100644 index 0000000..4c8ec23 --- /dev/null +++ b/dmzOS/test/test.c @@ -0,0 +1,12 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + if (argc < 2) { + printf("Please provide at least one argument\n"); + exit(1); + }; + printf("Hello, C!\n"); + return 0; +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..6caf9e9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.8' + +services: + c_toolchain: + build: + context: ./ + dockerfile: dockerfile.c_toolchain + container_name: c_toolchain + tty: true + stdin_open: true + volumes: + - ./dmzOS:/dmzOS diff --git a/dockerfile.c_toolchain b/dockerfile.c_toolchain new file mode 100644 index 0000000..85002ff --- /dev/null +++ b/dockerfile.c_toolchain @@ -0,0 +1,6 @@ +FROM ubuntu:18.04 +RUN apt-get update && apt-get install -y vim gcc indent clang clang-format gdb binutils +WORKDIR /dmzOS +#Getting prebuilt binary from llvm +COPY ./config/* /root +ENTRYPOINT [ "bash" ] From 65af1b6765d1c0e837cdbe3a5eb0bb8dd7262696 Mon Sep 17 00:00:00 2001 From: texhno Date: Wed, 14 Feb 2024 03:40:58 +0100 Subject: [PATCH 2/4] [FMT] Remove redundant comment --- dockerfile.c_toolchain | 1 - 1 file changed, 1 deletion(-) diff --git a/dockerfile.c_toolchain b/dockerfile.c_toolchain index 85002ff..60da070 100644 --- a/dockerfile.c_toolchain +++ b/dockerfile.c_toolchain @@ -1,6 +1,5 @@ FROM ubuntu:18.04 RUN apt-get update && apt-get install -y vim gcc indent clang clang-format gdb binutils WORKDIR /dmzOS -#Getting prebuilt binary from llvm COPY ./config/* /root ENTRYPOINT [ "bash" ] From ab540f13ae3ebc57fb73c86be7cce8c5a5ac18c2 Mon Sep 17 00:00:00 2001 From: texhno Date: Wed, 14 Feb 2024 11:32:13 +0100 Subject: [PATCH 3/4] Move docker files to the Dockerfiles dir --- .../dockerfile.c_toolchain | 3 +-- README.md | 24 +++++++++++++++++++ TOOLCHAIN.md | 18 -------------- docker-compose.yml | 3 ++- 4 files changed, 27 insertions(+), 21 deletions(-) rename dockerfile.c_toolchain => Dockerfiles/dockerfile.c_toolchain (72%) delete mode 100644 TOOLCHAIN.md diff --git a/dockerfile.c_toolchain b/Dockerfiles/dockerfile.c_toolchain similarity index 72% rename from dockerfile.c_toolchain rename to Dockerfiles/dockerfile.c_toolchain index 60da070..331b0c9 100644 --- a/dockerfile.c_toolchain +++ b/Dockerfiles/dockerfile.c_toolchain @@ -1,5 +1,4 @@ FROM ubuntu:18.04 -RUN apt-get update && apt-get install -y vim gcc indent clang clang-format gdb binutils +RUN apt-get update && apt-get install -y vim gcc indent clang clang-format gdb binutils nasm xxd WORKDIR /dmzOS -COPY ./config/* /root ENTRYPOINT [ "bash" ] diff --git a/README.md b/README.md index 98b325b..a5d69d0 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,27 @@ Rules: * Please provide an adequate entry in the Wiki for each non-trivial code contribution. For additional information, please refer to the [Wiki](https://gitea.dmz.rs/sborovic/dmzOS/wiki). + +# Instructions for running the utilities + +## c_toolchain utility docker image + +This is the consistent C toolchain environment, containing all the tools needed to run and develop the project. + +Dockerfile: `dockerfile.c_toolchain` +Run the docker-compose command to get a `bash` shell that is bound to the `dmzOS` directory: +```docker +docker-compose run --rm c_toolchain +``` + +Any changes in the container `dmzOS` directory will be reflected in the local `dmzOS` directory. + +The image contains `indent` and `clang-format` as `C` code formatters. + +A .vimrc file is automatically part of the image, and it contains a rule to make vim run the following formatting command on buffer save: +```bash +indent -kr -ts4 % +``` +This is using the Kernighan and Ritchie code styling, as well as identations with 4 spaces. + +If you want to use your own `.vimrc`, please replace the existing `.vimrc` file inside the `config` directory with it. diff --git a/TOOLCHAIN.md b/TOOLCHAIN.md deleted file mode 100644 index 9970aaa..0000000 --- a/TOOLCHAIN.md +++ /dev/null @@ -1,18 +0,0 @@ -# Instruction on running utilities - -## c_toolchain utility docker image - -Dockerfile: `dockerfile.c_toolchain` -Run the docker-compose command to get a `bash` shell that is bound to the `dmzOS` directory: -```bash -docker-compose run --rm c_toolchain -``` - -Any changes in the container shell will be reflected in the local `dmzOS` directory. - -The image contains `ident` abd `clang-format` as `C` code formatters. A .vimrc file is automatically part of the image, and it contains a rule to make vim run the following formatting command on buffer save: -```bash -ident -kr -ts4 % -``` - -This is using the Kernighan and Ritchie code styling, as well as identations with 4 spaces. diff --git a/docker-compose.yml b/docker-compose.yml index 6caf9e9..26b2a89 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,10 +3,11 @@ version: '3.8' services: c_toolchain: build: - context: ./ + context: ./Dockerfiles dockerfile: dockerfile.c_toolchain container_name: c_toolchain tty: true stdin_open: true volumes: - ./dmzOS:/dmzOS + - ./config/.vimrc:/root/.vimrc From 9fcfc4a58d8cbbff228615aa408abd1798d4c4d8 Mon Sep 17 00:00:00 2001 From: texhno Date: Fri, 16 Feb 2024 19:49:25 +0100 Subject: [PATCH 4/4] Add LLVM and lld to the c_toolchain env --- Dockerfiles/dockerfile.c_toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfiles/dockerfile.c_toolchain b/Dockerfiles/dockerfile.c_toolchain index 331b0c9..7e1b8fb 100644 --- a/Dockerfiles/dockerfile.c_toolchain +++ b/Dockerfiles/dockerfile.c_toolchain @@ -1,4 +1,4 @@ FROM ubuntu:18.04 -RUN apt-get update && apt-get install -y vim gcc indent clang clang-format gdb binutils nasm xxd +RUN apt-get update && apt-get install -y vim gcc indent clang clang-format gdb binutils nasm xxd llvm lld WORKDIR /dmzOS ENTRYPOINT [ "bash" ]