Skip to content

Commit f2df40b

Browse files
committed
Merge 14-add-minilibx into main
2 parents f97b5fe + 8a30d27 commit f2df40b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+8391
-7
lines changed

Makefile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# By: ebeiline <[email protected]> +#+ +:+ +#+ #
77
# +#+#+#+#+#+ +#+ #
88
# Created: 2022/03/30 17:16:39 by pstengl #+# #+# #
9-
# Updated: 2022/04/02 15:12:47 by pstengl ### ########.fr #
9+
# Updated: 2022/04/05 10:17:12 by pstengl ### ########.fr #
1010
# #
1111
# **************************************************************************** #
1212

@@ -26,8 +26,9 @@ TESTS:= ./tests
2626
# Other Variables:
2727
COMPILER:= gcc
2828
COMPFLAGS:= -Wall -Werror -Wextra
29-
STDLIBS:= m
30-
NONSTDLIBS:= libft gnl
29+
LIBPATHS:= /usr/X11
30+
STDLIBS:= m X11 Xext z
31+
NONSTDLIBS:= libft gnl mlx
3132
NORMFLAGS:=
3233

3334
# Source Files:
@@ -47,10 +48,12 @@ CFLAGS:=\
4748
$(COMPFLAGS)\
4849
$(addprefix -I ,$(INCLUDE))\
4950
$(addprefix -I $(LIBRARIES)/,$(NONSTDLIBS))\
50-
$(addprefix -I $(LIBRARIES)/,$(addsuffix /include,$(NONSTDLIBS)))
51+
$(addprefix -I $(LIBRARIES)/,$(addsuffix /include,$(NONSTDLIBS)))\
52+
$(addprefix -I ,$(addsuffix /include,$(LIBPATHS)))
5153
LDFLAGS:=\
5254
$(addprefix -L $(LIBRARIES)/,$(NONSTDLIBS))\
53-
$(addprefix -L $(LIBRARIES)/,$(addsuffix /binaries,$(NONSTDLIBS)))
55+
$(addprefix -L $(LIBRARIES)/,$(addsuffix /binaries,$(NONSTDLIBS)))\
56+
$(addprefix -L ,$(addsuffix /lib,$(LIBPATHS)))
5457
LDLIBS:=\
5558
$(addprefix -l,$(subst lib,,$(NONSTDLIBS)))\
5659
$(addprefix -l,$(STDLIBS))
@@ -79,6 +82,11 @@ $(OBJS): $(BUILD)%.o : $(SOURCE)%.c
7982
$(BINARIES)/$(NAME): $(OBJS)
8083
@for lib in $(NONSTDLIBS); do\
8184
echo "Compiling $$lib";\
85+
if [ -f $(LIBRARIES)/$$lib/configure ]; then\
86+
cd $(LIBRARIES)/$$lib;\
87+
./configure;\
88+
cd ../../;\
89+
fi;\
8290
$(MAKE) -j $(nprocs) -C $(LIBRARIES)/$$lib;\
8391
done
8492
mkdir -p $(BINARIES)
@@ -103,7 +111,7 @@ clean:
103111
fclean: clean
104112
@for lib in $(NONSTDLIBS); do \
105113
echo "Force Cleaning $$lib";\
106-
$(MAKE) -C $(LIBRARIES)/$$lib fclean;\
114+
$(MAKE) -C $(LIBRARIES)/$$lib fclean || true;\
107115
done
108116
@echo "Force Cleaning $(NAME)"
109117
$(RM) -r $(BINARIES)

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
# Cub3D
22
![norminette](https://github.com/Eduard953/Cub3D/workflows/Norm-Check/badge.svg) ![build](https://github.com/Eduard953/Cub3D/workflows/Build/badge.svg)
33

4+
## Requirements:
5+
6+
#### Linux:
7+
```bash
8+
sudo apt update && sudo apt install xorg libxext-dev zlib1g-dev libbsd-dev
9+
```
10+
#### MacOS:
11+
```bash
12+
brew install Xquartz
13+
reboot
14+
```
15+
#### School IMacs:
16+
- Go to 'Managed Software Center'
17+
- Search for 'Xquartz'
18+
- Install 'Xquartz'
19+
- Reboot the IMac (or at least click on the Button and log in again)
20+
21+
422
## Todo:
523

624
1. input validation
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ${{ matrix.os }}
13+
env:
14+
DISPLAY: ":99"
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, macos-latest]
19+
20+
timeout-minutes: 20
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Install mlx dependencies
24+
run: |
25+
set -x
26+
if [ "$RUNNER_OS" == "Linux" ]; then
27+
sudo apt-get update -qq
28+
sudo apt-get install -y -qq gcc make xorg libxext-dev libbsd-dev
29+
elif [ "$RUNNER_OS" == "macOS" ]; then
30+
brew install xquartz
31+
echo "/usr/X11/bin" >> $GITHUB_PATH
32+
else
33+
echo "$RUNNER_OS not supported"
34+
exit 1
35+
fi
36+
- name: Setup x11 headless testing environment
37+
run: |
38+
set -x
39+
if [ "$RUNNER_OS" == "Linux" ]; then
40+
sudo apt-get install xvfb xdotool valgrind
41+
Xvfb $DISPLAY -screen 0 1280x1024x24 &
42+
elif [ "$RUNNER_OS" == "macOS" ]; then
43+
brew install xdotool
44+
defaults write org.x.X11 enable_test_extensions -boolean true
45+
sudo Xvfb $DISPLAY -screen 0 1280x1024x24 &
46+
else
47+
echo "$RUNNER_OS not supported"
48+
exit 1
49+
fi
50+
- name: Run ./configure
51+
run: ./configure
52+
53+
- name: make check Linux
54+
if: matrix.os == 'ubuntu-latest'
55+
run: make -f Makefile.gen check
56+
- name: make check MacOS
57+
continue-on-error: true
58+
if: matrix.os == 'macos-latest'
59+
run: make -f Makefile.gen check
60+
# Didn't find a way to simulate inputs on Macos. libxdo seem to no longer work on macos.
61+
# It can be partially fixed writing proper unit-tests, thus avoiding the need of libxdo.
62+
63+
- name: Check leaks from binary "test/mlx-test"
64+
run: |
65+
cd test
66+
if [ "$RUNNER_OS" == "Linux" ]; then
67+
echo "Info: Still reachable doesn't matter. Valgrind will return success on thoses reports.
68+
It is fine, we searching for lost pointers. Valgrind will return exit status 42 if any block is lost."
69+
valgrind --leak-check=full --show-leak-kinds=definite,indirect,possible --errors-for-leak-kinds=definite,indirect,possible --error-exitcode=42 ./mlx-test > /dev/null &
70+
PID=$!
71+
sleep 30
72+
xdotool search --name Title3 windowfocus key Escape
73+
xdotool search --name Title2 windowfocus key Escape
74+
wait $PID
75+
elif [ "$RUNNER_OS" == "macOS" ]; then
76+
MallocStackLoggingNoCompact=1
77+
./mlx-test &
78+
sleep 30
79+
leaks mlx-test
80+
pkill mlx-test
81+
fi
82+
83+
- name: Norminette, just for fun
84+
continue-on-error: true
85+
run: |
86+
pip3 install Norminette
87+
norminette *.c *.h
88+
norminette --version

libraries/mlx/.gitignore

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
## Mlx related
2+
Makefile.gen
3+
/test/mlx-test
4+
5+
## Editor
6+
.vscode/*
7+
*~
8+
\#*\#
9+
10+
## Other
11+
.DS_STORE
12+
13+
14+
15+
## Template from https://github.com/github/gitignore
16+
# Prerequisites
17+
*.d
18+
19+
# Object files
20+
*.o
21+
*.ko
22+
*.obj
23+
*.elf
24+
25+
# Linker output
26+
*.ilk
27+
*.map
28+
*.exp
29+
30+
# Precompiled Headers
31+
*.gch
32+
*.pch
33+
34+
# Libraries
35+
*.lib
36+
*.a
37+
*.la
38+
*.lo
39+
40+
# Shared objects (inc. Windows DLLs)
41+
*.dll
42+
*.so
43+
*.so.*
44+
*.dylib
45+
46+
# Executables
47+
*.exe
48+
*.out
49+
*.app
50+
*.i*86
51+
*.x86_64
52+
*.hex
53+
54+
# Debug files
55+
*.dSYM/
56+
*.su
57+
*.idb
58+
*.pdb
59+
60+
# Kernel Module Compile Results
61+
*.mod*
62+
*.cmd
63+
.tmp_versions/
64+
modules.order
65+
Module.symvers
66+
Mkfile.old
67+
dkms.conf

libraries/mlx/LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
BSD 2-Clause License
2+
3+
Copyright (c) 2021, Ecole 42
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

libraries/mlx/Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
##
2+
## Makefile for MiniLibX in /home/boulon/work/c/raytraceur/minilibx
3+
##
4+
## Made by Olivier Crouzet
5+
6+
##
7+
## Started on Tue Oct 5 15:56:43 2004 Olivier Crouzet
8+
## Last update Tue May 15 15:44:41 2007 Olivier Crouzet
9+
##
10+
11+
## Please use configure script
12+
13+
14+
all : do_configure
15+
16+
do_configure :
17+
./configure
18+
19+
clean :
20+
./configure clean
21+
22+
re : clean all

libraries/mlx/Makefile.mk

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
##
2+
## Makefile for MiniLibX in /home/boulon/work/c/raytraceur/minilibx
3+
##
4+
## Made by Olivier Crouzet
5+
6+
##
7+
## Started on Tue Oct 5 15:56:43 2004 Olivier Crouzet
8+
## Last update Tue May 15 15:41:20 2007 Olivier Crouzet
9+
##
10+
11+
## Please use configure script
12+
13+
14+
INC =%%%%
15+
16+
UNAME = $(shell uname)
17+
CC = gcc
18+
ifeq ($(UNAME),FreeBSD)
19+
CC = clang
20+
endif
21+
22+
NAME = libmlx.a
23+
NAME_UNAME = libmlx_$(UNAME).a
24+
25+
SRC = mlx_init.c mlx_new_window.c mlx_pixel_put.c mlx_loop.c \
26+
mlx_mouse_hook.c mlx_key_hook.c mlx_expose_hook.c mlx_loop_hook.c \
27+
mlx_int_anti_resize_win.c mlx_int_do_nothing.c \
28+
mlx_int_wait_first_expose.c mlx_int_get_visual.c \
29+
mlx_flush_event.c mlx_string_put.c mlx_set_font.c \
30+
mlx_new_image.c mlx_get_data_addr.c \
31+
mlx_put_image_to_window.c mlx_get_color_value.c mlx_clear_window.c \
32+
mlx_xpm.c mlx_int_str_to_wordtab.c mlx_destroy_window.c \
33+
mlx_int_param_event.c mlx_int_set_win_event_mask.c mlx_hook.c \
34+
mlx_rgb.c mlx_destroy_image.c mlx_mouse.c mlx_screen_size.c \
35+
mlx_destroy_display.c
36+
37+
OBJ_DIR = obj
38+
OBJ = $(addprefix $(OBJ_DIR)/,$(SRC:%.c=%.o))
39+
CFLAGS = -O3 -I$(INC)
40+
41+
all : $(NAME)
42+
43+
$(OBJ_DIR)/%.o: %.c
44+
@mkdir -p $(OBJ_DIR)
45+
$(CC) $(CFLAGS) $(IFLAGS) -c $< -o $@
46+
47+
$(NAME) : $(OBJ)
48+
ar -r $(NAME) $(OBJ)
49+
ranlib $(NAME)
50+
cp $(NAME) $(NAME_UNAME)
51+
52+
check: all
53+
@test/run_tests.sh
54+
55+
show:
56+
@printf "NAME : $(NAME)\n"
57+
@printf "NAME_UNAME : $(NAME_UNAME)\n"
58+
@printf "CC : $(CC)\n"
59+
@printf "CFLAGS : $(CFLAGS)\n"
60+
@printf "SRC :\n $(SRC)\n"
61+
@printf "OBJ :\n $(OBJ)\n"
62+
63+
clean :
64+
rm -rf $(OBJ_DIR)/ $(NAME) $(NAME_UNAME) *~ core *.core
65+
66+
.PHONY: all check show clean

0 commit comments

Comments
 (0)