Skip to content

Commit

Permalink
Fix compilation and use git submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGreatRambler committed Aug 18, 2024
1 parent 4ea69dc commit 09f2003
Show file tree
Hide file tree
Showing 63 changed files with 98 additions and 34,817 deletions.
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ IncludeBlocks: Preserve
NamespaceIndentation: All
PointerAlignment: Left
SortIncludes: "true"
AlwaysBreakAfterDefinitionReturnType: None
SpaceBeforeAssignmentOperators: "true"
SpaceBeforeParens: Never
SpaceInEmptyParentheses: "false"
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ imgui.ini
temp.bcd
test*
tilesheetFiles.txt
third_party
node_modules
package*.json
img/12621
Expand All @@ -23,4 +22,7 @@ img/cid
/*.bcd
/*.zip
*.deb
*.app
*.app

third_party/cairo-*
third_party/pixman-*
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN mkdir third_party && \
rm pixman-0.40.0.tar.gz

RUN apt update && \
apt install -y pkg-config libpng-dev libsdl2-dev libglew-dev libglfw3-dev libcairo-dev libfreetype-dev libcurl4-openssl-dev && \
apt install -y pkg-config libfmt-dev libpng-dev libsdl2-dev libglew-dev libglfw3-dev libcairo-dev libfreetype-dev libcurl4-openssl-dev && \
rm -rf /var/lib/apt/lists/*

RUN cd third_party/pixman-0.40.0 && \
Expand Down
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ else
endif

CFLAGS := -std=gnu11
CXXFLAGS := -std=gnu++2a -I./src
CPPFLAGS := -Wall -Wextra -Wno-missing-field-initializers -Wno-deprecated-enum-enum-conversion -Wno-narrowing
CXXFLAGS := -std=gnu++2a
CPPFLAGS := -Wall -Wextra -Wno-missing-field-initializers -Wno-deprecated-enum-enum-conversion -Wno-narrowing \
-I./src -I./third_party/fmt/include -I./third_party/rapidjson/include

ifeq ($(BUILD),release)
# "Release" build - optimization, and no debug symbols
Expand All @@ -34,12 +35,12 @@ ifeq ($(PLATFORM),web)
CPPFLAGS += -I./third_party/cairo-1.16.0/src -O3 $(EMS)
LDFLAGS += -s CASE_INSENSITIVE_FS=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s TOTAL_STACK=10000000 -s ASYNCIFY -s FETCH=1 -s FORCE_FILESYSTEM=1 -s USE_PTHREADS=0 -o bin/index.html --shell-file shell_minimal.html $(PRELOADED_FILES) $(EMS) -L./third_party/cairo-1.16.0/src/.libs -lcairo -L./third_party/pixman-0.42.2/pixman/.libs -lpixman-1
else
CPPFLAGS += $(shell pkg-config --cflags sdl2 glew glfw3 zlib cairo freetype2 libcurl) -Wno-cast-function-type
CPPFLAGS += $(shell pkg-config --cflags fmt sdl2 glew glfw3 zlib cairo freetype2 libcurl) -Wno-cast-function-type

ifeq ($(OS),Windows_NT)
LDFLAGS += $(shell pkg-config --libs --static sdl2 glew glfw3 zlib cairo freetype2 libcurl) -lpthread -lmingw32 -lopengl32 -lws2_32 -lwsock32 -mconsole -lunistring -liconv -lbrotlicommon -fPIC -static -static-libgcc -static-libstdc++
LDFLAGS += $(shell pkg-config --libs --static fmt sdl2 glew glfw3 zlib cairo freetype2 libcurl) -lpthread -lmingw32 -lopengl32 -lws2_32 -lwsock32 -mconsole -lunistring -liconv -lbrotlicommon -fPIC -static -static-libgcc -static-libstdc++
else
LDFLAGS += $(shell pkg-config --libs sdl2 glew glfw3 zlib cairo freetype2 libcurl) -ldl -lpthread
LDFLAGS += $(shell pkg-config --libs fmt sdl2 glew glfw3 zlib cairo freetype2 libcurl) -ldl -lpthread
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LDFLAGS += -lstdc++fs
Expand All @@ -51,7 +52,11 @@ else
endif


SRCS := ./src/main.cpp ./src/LevelParser.cpp ./src/LevelDrawer.cpp ./src/Helpers.cpp ./src/kaitai/kaitaistream.cpp ./src/MM2/level.cpp ./src/imgui/imgui.cpp ./src/imgui/imgui_widgets.cpp ./src/imgui/imgui_tables.cpp ./src/imgui/imgui_impl_sdl.cpp ./src/imgui/imgui_impl_opengl3.cpp ./src/imgui/imgui_draw.cpp ./src/SMM2CourseDecryptor/aes.cpp ./src/SMM2CourseDecryptor/decrypt.cpp ./src/fmt/format.cc ./src/fmt/fmt.cc ./src/fmt/os.cc
SRCS := ./src/main.cpp ./src/LevelParser.cpp ./src/LevelDrawer.cpp ./src/Helpers.cpp \
./src/kaitai/kaitaistream.cpp ./src/MM2/level.cpp ./src/imgui/imgui.cpp ./src/imgui/imgui_widgets.cpp \
./src/imgui/imgui_tables.cpp ./src/imgui/imgui_impl_sdl.cpp ./src/imgui/imgui_impl_opengl3.cpp \
./src/imgui/imgui_draw.cpp ./src/SMM2CourseDecryptor/aes.cpp ./src/SMM2CourseDecryptor/decrypt.cpp \
./third_party/fmt/src/format.cc ./third_party/fmt/src/os.cc

ifeq ($(OS)$(PLATFORM),Windows_NT)
SRCS += src/info.rc src/icon.rc
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Level viewer for Super Mario Maker 2, based on [JiXiaomai's work](https://github
To load a local level file, press `Load Level` and choose a level. Wait a few seconds and the level will be rendered for you, along with some info. To load a level from a course ID, type your course ID into the textbox and press `Download Level`. As before, wait a few seconds and the level will be rendered. The rendered levels can be dragged with your mouse. You can also download them with `Download Image`, export info in JSON with `Download JSON`, or close the window to free up space with the `x` in the top left or with `Close Level`. To render levels without the grid, check `Remove Grid` and to render objects over pipes check `Render Objects Over Pipes`. You may also change the size of the image with `Image Scale`.

# How to build
If building for desktop, obtain development files for `sdl2`, `glew`, `glfw3`, `zlib`, `cairo`, `freetype2`, and `libcurl`, as well as having an up to date GCC and pkg-config. Compilation on Windows should use MSYS2, on Mac should use homebrew and on linux should use standard GCC. Type `make` for a debug build and `make BUILD=release` for a release build.
If building for desktop, obtain development files for `sdl2`, `glew`, `glfw3`, `zlib`, `cairo`, `freetype2`, and `libcurl`, as well as having an up to date GCC and pkg-config. Make sure to include all submodules. Compilation on Windows should use MSYS2, on Mac should use homebrew and on linux should use standard GCC. Type `make` for a debug build and `make BUILD=release` for a release build.
If building for web, first obtain a working Emscripten build environment and put its binaries on the path, such as `emmake`, `emcc` and `em++`. Next, run `./prepare_web_deps.sh`. This only needs to be done once, as it downloads and compiles Cairo to prepare it for the web environment. Once that is done, you can run `make PLATFORM=web` for a debug build and `make PLATFORM=web BUILD=release` for a release build. To prepare a zip to distribute, run `./build_release.sh` for desktop and `./build_release.sh web` for web.

# Hosting the web build
Expand Down
Loading

0 comments on commit 09f2003

Please sign in to comment.