Skip to content
airone01Public

About

Monorepo of all my projects related to 42

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

643 Commits

Folders and files

Repository files navigation

ft

When was the last commit This repo is licensed under MIT How many projects are in this repo Repo size in bytes Zig workflow status

ft is a monorepo of all my projects related to 42. It's mainly meant for personal archiving, but I also share some cool stuff.


Foreword

This is a monorepository, meaning these projects are tightly coupled and share dependencies to work properly.

Why CMake? The 42 curriculum relies heavily on GNU Make to teach students the fundamentals of compilation. However, maintaining 30+ nearly identical makefiles in a monorepo quickly becomes tedious. Because I enjoy DevOps and reproducibility, I migrated this repository to the CMake build system1. I now only make a standard makefile and clean the repo right before pushing a project for grading.

Note

There are no subject PDFs here, hit the road, traveler!

Caution

A natural side effect of this monorepo setup is that it makes it harder to blindly copy-paste my projects and submit them as your own, as some projects are heavily tied together. While deterring cheating wasn't my primary technical goal, I support the result. Copying defeats the core principles of 42 and goes against what I personally believe in. This repository is meant to serve as an example of what you can build at this school, not as a shortcut. It's called a school for a reason. Learn; Write your own tests; and "By Odin! By Thor! Use your brain!".

Projects

To see my grades, unwrap the following table.

Common Core project grades
Milestone Project Finished Grade
0 Libft ✅
(with bonuses)
125
1 Born2beroot ✅
(with bonuses)
125
ft_printf ✅ 100
get_next_line ✅ 100
2 pipex ✅
(with bonuses)
125
push_swap ✅ 100
FdF ✅
(with bonuses)
125
3 minishell
with @maximart
✅ 101
Philosophers ✅ 100
4 cub3d
with @maximart
✅
(with bonuses)
125
CPP 00-04 ✅ (various grades)
NetPractice ✅ 100
5 ft_irc
with @maximart & @nahamida
✅ 125
Inception ✅ 90
CPP 05-09 ✅ (various grades)
6 ft_transcendence
with @vblanc, @enpassel & @scottene
✅ 125

To see all the projects in this repo and the skills learned, unwrap the following table. Head to the end of the section for the best projects.

All projects
Name Description Note I learned
libft Standard library Used for many other 42 projects. Library packaging, low-level good practices
Born2beroot Basic Linux VM I had a background in VMs before 42, so this project wasn't hard. Linux and VM usage
ft_printf printf(3) implementation String manipulation, some ABI features
get_next_line readline(3) implementation String manipulation, memory
fdf Heightmap visualizer Some math calculations, optimization, GUI UX
pipex Output redirection/pipes exercise UNIX pipes, UNIX usage
push_swap Sorting algorithm, its checker, and visualizer FIFO/stacks, multi-target build systems, Rust programming and ECS
philosophers The classic dining philosophers problem Concurrent algorithms, deadlocks, and racing prevention
minishell A POSIX-compliant shell More piping, processes and threads, lexers and parsers, team organization
CPP 00 to 09 C++ exercises C++, OOP, more standards
cub3d A Wolfenstein 3D-style game in 2.5D 2.5D, ray casting, more math, project management, assets and textures, optimization, conditional and multi-platform building and bundling
net_practice Basic networking exercises in a Cisco Packet Tracer-like interface Basic networking
Inception (More) advanced VM and Docker (Compose) usage see Born2beroot Docker, Docker Compose, kernel features
ft_transcendence Full-stack webapp social media and game Project organization and management, Typescript, Bun, Svelte, ORMs (Drizzle), DBs (Postgres), crunches, Agile mindset
B An assembly compiler for the B language Advanced lexers and parsers, Bison, Flex, terminology and inner workings of compilers, assembly, i386 processors
ft_linux A Linux From Scratch (and BLFS) system Distro maintainer skills, package compilation, bootstrapping, SystemD, Init, many build systems like CMake, Ninja, ...
ft_ls A clone of GNU BinUtils' ls(1) C project architecture, FS operations, some kernel ABI and features
libasm Standard library in assembly x86_64, assembly
malloc malloc(3) implementation (with mmap(2) only, without brk(2)) Linux ABI, memory allocation, defragmentation algorithms
nm A clone of GNU BinUtils' nm(1) ELFs, Linux ABI, packaging and sectors, C project organization
snow-crash A CTF ELFs, cybersecurity, Linux protection and exploitation, permission systems

Notable projects

fdf
cub3d (and its 3DS port)
ft_linux
ft_transcendence

Extra tools/projects

During a boring weekend, I set up a Bazel1 target to cross-compile a 3DS home-brew app. If you have a modded 3DS on hand, you can compile it and try yourself. It's very limited, laggy, and crashes on quit though. You have been warned. The level packaged is also very basic.

A program to flex on your friends by visualizing your push_swap algorithm in Minecraft. It uses Valence to control the game packets and visualize the sorting algorithm on your 1.20.1 client.

In-game screenshot Minecraft push_swap visualizer in-game screenshot

A simple script to convert a BMP2 image into a fdf file. It currently only works for bitmap images smaller than 255 * 255, because I don't really know how to reliably get the width of the image in the header.

Building and packaging

CMake

You can build all3 the projects in this monorepo using CMake.

# Example usage
cmake -B build -G Ninja
ninja -C build

3DS

The build instructions for the 3DS port of cub3d are detailed in a dedicated file;

Nix

This project's dev dependencies are packaged using Nix in a devShell that I personally use with nix-direnv. There is a central flake.nix that loads all nix files using import-tree.

I might eventually package the projects of this repo into this flake when I find the time.

Additional notes

LSPs and compile_commands.json

If you use an IDE or LSP server and the constant clangd type errors appearing when browsing this repo hurt your eyes, I might have a solution for you. The compile_commands.json file! It instructs your LSP server on where to locate the headers, and in which order, and how your build system (CMake in this case) manages your compilation.

To generate this file, just generate the CMake project once. CMake should make sure the file exists, and your LSP should be smart enough to find it. If not the latter, it'll be in BUILD_DIR/compile_commands.json, where "BUILD_DIR" is the directory you instructed CMake to build to with the -B argument.

Bear4 is not necessary anymore.

Number of projects

To get the number of projects in this repo, you can run a quick jq command.

jq '.packages | keys | map(select(startswith("tools") | not)) | length' -- release-please-config.json

License

This project is licensed under the MIT License. See the LICENSE file for details.

Footnotes

  1. I used to use Bazel to build my projects, but it's somewhat incompatible with Nix5, so I moved to the Zig build system. The I moved away from Zig to CMake, because Zig wasn't really adapted to a monorepo architecture. Or more accurately, I didn't have the skills or time to make it suit my needs. CMake comes built-in with a bunch of features (like compile_commands4, or automatic target discovery) that are a plus for this repo. ↩ ↩2

  2. You can convert PNG images to BMP using convert from ImageMagick, or online with EzGIF. ↩

  3. I haven't bothered to make everything compile using CMake. At the time of writing, ft_transcendence (Typescript/NodeJS) and the Minecraft push_swap visualizer (Rust) must be compiled with their respective toolings (pnpm and cargo). I don't update the README as often as I update projects though, so take a look around and see for yourself! ↩

  4. From https://github.com/rizsotto/Bear: "Bear generates a compilation database for Clang tooling". Bear is not needed anymore, now that I've moved the build system to CMake. ↩ ↩2

  5. Here are good talks that detail the issues I came across: https://www.youtube.com/watch?v=6qOoOsjmyZ0 https://www.youtube.com/watch?v=s801fgQOGnw https://www.youtube.com/watch?v=HI7LwgyOQO4 ↩

About

Monorepo of all my projects related to 42

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages