Skip to content

Commit ef52275

Browse files
authored
Merge pull request #12 from aymnms/dev
Dev
2 parents f8f3b1e + dd5637b commit ef52275

Some content is hidden

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

106 files changed

+281
-194
lines changed

.github/workflows/build-macos.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@ jobs:
1414
- uses: actions/checkout@v4
1515

1616
- name: Install dependencies
17-
run: brew install sdl2 sdl2_image sdl2_mixer
17+
run: brew install cmake ninja sdl2 sdl2_image sdl2_mixer
1818

19-
- name: Configure CMake
20-
run: cmake -B build-arm -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64"
21-
22-
- name: Build
23-
run: cmake --build build-arm --config Release
19+
- name: Configure CMake and Build
20+
run: make prod-arm
2421

2522
- name: Remove quarantine attribute
2623
run: xattr -rd com.apple.quarantine build-arm/mario_isn.app

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ dkms.conf
102102

103103
# CMake
104104
cmake-build-*/
105+
build/
106+
build-arm/
107+
build-intel/
108+
build-macos/
105109

106110
# Mongo Explorer plugin
107111
.idea/**/mongoSettings.xml
@@ -176,7 +180,6 @@ CMakeCache.txt
176180
CMakeFiles
177181
CMakeScripts
178182
Testing
179-
Makefile
180183
cmake_install.cmake
181184
install_manifest.txt
182185
compile_commands.json
@@ -268,3 +271,7 @@ $RECYCLE.BIN/
268271
*.lnk
269272

270273
# End of https://www.toptal.com/developers/gitignore/api/macos,windows,linux,c,cmake,ninja,clion
274+
275+
.vscode/
276+
SNAPSHOT.txt
277+
Makefile.local

CMakeLists.txt

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
cmake_minimum_required(VERSION 3.31)
1+
cmake_minimum_required(VERSION 3.20)
22
project(mario_isn C)
33

4+
# Langage & bundle macOS
45
set(CMAKE_C_STANDARD 99)
56
set(CMAKE_MACOSX_BUNDLE TRUE)
67
set(MACOSX_BUNDLE_BUNDLE_NAME "MarioISN")
7-
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.aymnms.marioisn")
8+
set(MACOSX_BUNDLE_GUI_IDENTIFIER "fr.aymnms.marioisn")
89
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "1.0")
910
set(MACOSX_BUNDLE_LONG_VERSION_STRING "1.0")
1011
set(MACOSX_BUNDLE_BUNDLE_VERSION "1.0")
1112
set(MACOSX_BUNDLE_ICON_FILE MyIcon.icns)
1213

13-
# headers
14-
include_directories(
15-
/opt/homebrew/include
16-
include
17-
)
14+
# Pour VS Code / IntelliSense
15+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
16+
17+
# Trouver SDL2 via les packages CMake fournis par Homebrew
18+
find_package(SDL2 REQUIRED CONFIG)
19+
find_package(SDL2_image REQUIRED CONFIG)
20+
find_package(SDL2_mixer REQUIRED CONFIG)
1821

1922
# Exécutable (cible)
2023
add_executable(mario_isn MACOSX_BUNDLE
2124
src/main.c
2225
src/display.c
26+
src/path.c
2327
src/menu/init_menu.c
2428
src/menu/menu.c
2529
src/game/init_game.c
@@ -35,42 +39,29 @@ add_executable(mario_isn MACOSX_BUNDLE
3539
src/game/joueur/music.c
3640
src/game/joueur/niveau.c
3741
src/game/joueur/saut_joueur.c
42+
${CMAKE_SOURCE_DIR}/ressources/MyIcon.icns
3843
)
3944

40-
add_custom_command(TARGET mario_isn POST_BUILD
41-
COMMAND ${CMAKE_COMMAND} -E make_directory
42-
$<TARGET_BUNDLE_CONTENT_DIR:mario_isn>/Resources
43-
)
44-
add_custom_command(TARGET mario_isn POST_BUILD
45-
COMMAND ${CMAKE_COMMAND} -E copy
46-
${CMAKE_SOURCE_DIR}/img/MyIcon.icns
47-
$<TARGET_BUNDLE_CONTENT_DIR:mario_isn>/Resources/MyIcon.icns
48-
)
49-
45+
# Indique où la placer dans le bundle
5046
set_source_files_properties(${CMAKE_SOURCE_DIR}/img/MyIcon.icns
51-
PROPERTIES
52-
MACOSX_PACKAGE_LOCATION "Resources"
53-
)
47+
PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
5448

55-
# Bibliothèques
56-
target_link_libraries(mario_isn
57-
/opt/homebrew/lib/libSDL2.dylib
58-
/opt/homebrew/lib/libSDL2_image.dylib
59-
/opt/homebrew/lib/libSDL2_mixer.dylib
49+
# Portée des includes du projet (headers locaux)
50+
target_include_directories(mario_isn PRIVATE
51+
${CMAKE_SOURCE_DIR}/include
6052
)
6153

62-
# Ressources
63-
set(ASSETS
64-
${CMAKE_SOURCE_DIR}/bin
65-
${CMAKE_SOURCE_DIR}/img
66-
${CMAKE_SOURCE_DIR}/musique
54+
# Lien contre SDL2 (targets importées = include + libs + defines gérés)
55+
target_link_libraries(mario_isn PRIVATE
56+
SDL2::SDL2
57+
SDL2_image::SDL2_image
58+
SDL2_mixer::SDL2_mixer
6759
)
6860

69-
foreach(asset IN LISTS ASSETS)
70-
get_filename_component(asset_name ${asset} NAME)
71-
add_custom_command(TARGET mario_isn POST_BUILD
72-
COMMAND ${CMAKE_COMMAND} -E copy_directory
73-
${asset}
74-
$<TARGET_BUNDLE_CONTENT_DIR:mario_isn>/${asset_name}
75-
)
76-
endforeach()
61+
# Copie des assets dans le bundle .app (Resources)
62+
add_custom_command(TARGET mario_isn POST_BUILD
63+
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_BUNDLE_CONTENT_DIR:mario_isn>/Resources
64+
COMMAND ${CMAKE_COMMAND} -E copy_directory
65+
${CMAKE_SOURCE_DIR}/ressources
66+
$<TARGET_BUNDLE_CONTENT_DIR:mario_isn>/Resources
67+
)

Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Inclusion optionnelle du Makefile.local pour commande make privé
2+
-include Makefile.local
3+
4+
# Variables
5+
BUILD_DIR = build
6+
CMAKE = cmake
7+
GENERATOR = Ninja
8+
BUILD_TYPE = Debug
9+
10+
.PHONY: all configure build run clean
11+
12+
# Commande par défaut
13+
all: build
14+
15+
configure:
16+
@$(CMAKE) -S . -B $(BUILD_DIR) -G $(GENERATOR) \
17+
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE) \
18+
$(if $(ARCH),-DCMAKE_OSX_ARCHITECTURES="$(ARCH)") \
19+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
20+
21+
build: configure
22+
@$(CMAKE) --build $(BUILD_DIR)
23+
24+
run: build
25+
@./$(BUILD_DIR)/mario_isn.app/Contents/MacOS/mario_isn
26+
27+
clean:
28+
@rm -rf $(BUILD_DIR)
29+
30+
prod-arm:
31+
$(MAKE) BUILD_DIR=build-arm BUILD_TYPE=Release ARCH="arm64" configure build
32+
33+
# # Ne fonctionne pas encore
34+
# prod-intel:
35+
# $(MAKE) BUILD_DIR=build-intel BUILD_TYPE=Release ARCH="x86_64" configure build
36+
37+
# # Ne fonctionne pas encore
38+
# prod-macos:
39+
# $(MAKE) BUILD_DIR=build-macos BUILD_TYPE=Release ARCH="universal" configure build

README.md

Lines changed: 23 additions & 58 deletions

include/MARIO_variables.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <SDL2/SDL.h>
1+
#include <SDL.h>
22
//-------------------------------------------------Variable-générale-------------------------------------------------//
33
int run = 1, run_game = 1;
44
int niveau = 1;

include/display.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef DISPLAY_H
22
#define DISPLAY_H
33

4-
#include <SDL2/SDL.h>
4+
#include <SDL.h>
55

66
extern SDL_Window *window;
77
extern SDL_Renderer *renderer;

include/path.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
// Renvoie un chemin ABSOLU pour "img/xxx.png", "musique/xxx.mp3", "bin/xxx.lvl", etc.
4+
// Résolution basée sur l'emplacement de l'exécutable (SDL_GetBasePath),
5+
// gère aussi le bundle macOS (.app/Contents/Resources) et le layout de dev.
6+
char* asset_path(const char *subpath);
7+
8+
// Raccourcis
9+
char* path_img(const char *filename);
10+
char* path_music(const char *filename);
11+
char* path_bin(const char *filename);
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)