From b78af7e66230fe81b9f9a375608cf012de51e191 Mon Sep 17 00:00:00 2001 From: LaserEyess Date: Mon, 29 May 2023 16:16:22 -0400 Subject: [PATCH 1/2] Switch build system to CMake This unifies the build system across platforms, including doing development inside Visual Studio. No change to other code. Some exceptions: - Switch port is still a Makefile - run_with_tcc.bat still exists --- .gitignore | 10 +- BUILDING.md | 97 ++++++------ CMakeLists.txt | 89 +++++++++++ CMakePresets.json | 20 +++ Makefile | 33 ----- README.md | 2 +- sm.sln | 31 ---- src/.gitignore | 1 - src/CMakeLists.txt | 95 ++++++++++++ src/packages.config | 5 - src/platform/switch/Makefile | 224 ---------------------------- src/sm.vcxproj | 276 ----------------------------------- src/sm.vcxproj.filters | 270 ---------------------------------- third_party/.gitignore | 3 - third_party/CMakeLists.txt | 3 + 15 files changed, 254 insertions(+), 905 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 CMakePresets.json delete mode 100644 Makefile delete mode 100644 sm.sln delete mode 100644 src/.gitignore create mode 100644 src/CMakeLists.txt delete mode 100644 src/packages.config delete mode 100644 src/platform/switch/Makefile delete mode 100644 src/sm.vcxproj delete mode 100644 src/sm.vcxproj.filters delete mode 100644 third_party/.gitignore create mode 100644 third_party/CMakeLists.txt diff --git a/.gitignore b/.gitignore index e8ef78d..e33d0f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,8 @@ .DS_Store *.dSYM /.vs/ -/packages/ /saves/ -*.o -/sm -/build/ +/build*/ /sm.smc -SDL2.dll -/sm.exe -/glsl-shaders/ \ No newline at end of file +/glsl-shaders/ +CMakeUserPresets.json \ No newline at end of file diff --git a/BUILDING.md b/BUILDING.md index e40b009..587dc3e 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -1,97 +1,86 @@ # Requirements - * A Super Metroid rom (Make sure to rename it to `sm.smc`) + * cmake (and also ninja, for better compiling speed) + * A Super Metroid rom (Make sure to rename it to `sm.smc`) which **must be in + the same folder as `sm`/`sm.exe`** * libsdl2-dev * Super Metroid repo `git clone --recursive https://github.com/snesrev/sm` For Linux/MacOS you must install these for your desired OS: - * Ubuntu/Debian: `sudo apt install libsdl2-dev` - * Fedora Linux: `sudo dnf in sdl2-devel` - * Arch Linux: `sudo pacman -S sdl2` - * macOS: `brew install sdl2` + * Ubuntu/Debian: `sudo apt install libsdl2-dev cmake ninja-build` + * Fedora Linux: `sudo dnf in sdl2-devel cmake ninja-build` + * Arch Linux: `sudo pacman -S sdl2 cmake ninja` + * macOS: `brew install sdl2 cmake ninja` # Windows - ## Building with MSYS2 - -Dependencies and requirements: - - * The `libsdl2-dev` library - * [MSYS2](https://www.msys2.org) +First, install [MSYS2](https://www.msys2.org/). After following the instructions, +install the following packages. Note: *Make sure you're using MINGW64 and you're in `sm` folder in the terminal.* -1. Install MSYS2 on your machine. -2. Place the copy of your rom in the main directory. -3. Install the necessary dependencies by inputting this command in the terminal. - ```sh -pacman -S mingw-w64-x86_64-SDL2 && pacman -S make && pacman -S mingw-w64-x86_64-gcc +pacman -S mingw-w64-x86_64-{gcc,cmake,SDL2,ninja} ``` -4. Type `sdl2-config --cflags`, it should output: -```sh --IC:/msys64/mingw64/include/SDL2 -Dmain=SDL_main -``` -5. After that type `sdl2-config --libs`, should output: + +Once installed, building can be done with: ```sh --LC:/msys64/mingw64/lib -lmingw32 -mwindows -lSDL2main -lSDL2 +cmake -B build -G Ninja && cmake --build build ``` - -After you've done installing everything, cd to `sm` folder. Type `make` -In order to speed up the compilation, type `make -j16` +`sm.exe` will be at `./build/sm.exe`. ## Building with Visual Studio - Dependencies and requirements: * The `libsdl2-dev` library, which is automatically installed with NuGet. * [Visual Studio Community 2022](https://visualstudio.microsoft.com) -Download VS installer. On installer prompt, make sure you're on "Workloads" and check `Desktop Development with C++` this will install the necessary deps for compilation. +Download VS installer. On installer prompt, make sure you're on "Workloads" +and check **both** `Desktop Development with C++` **and** `C++ CMake Tools for Windows`. +This will install the necessary deps for compilation. -1. Open `sm.sln` solution. -2. Change the build target from `Debug` to `Release` -3. Build the solution. +Visual Studio should automatically detect the CMake project and let you configure and build it. If not, +follow the [general instructions](https://learn.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=msvc-170) +from Microsoft. -## Building with Tiny C Compiler +Make sure to switch the build type from `Debug` to `Release`. +## Building with Tiny C Compiler Dependencies and requirements: - * You'll need [TCC](https://github.com/FitzRoyX/tinycc/releases/download/tcc_20221020/tcc_20221020.zip) and [SDL2](https://github.com/libsdl-org/SDL/releases/download/release-2.24.1/SDL2-devel-2.24.1-VC.zip) in order to compile using TCC. + * You'll need [TCC](https://github.com/FitzRoyX/tinycc/releases/download/tcc_20221020/tcc_20221020.zip) and + [SDL2](https://github.com/libsdl-org/SDL/releases/download/release-2.24.1/SDL2-devel-2.24.1-VC.zip) in order to compile using TCC. 1. Unzip both TCC and SDL and place them in `third_party` folder. 2. Double click `run_with_tcc.bat` 3. Wait for it to compile and the game will automatically boot-up. # Linux/MacOS - CD to your SM root folder and open the terminal and type: ```sh -make +cmake -B build && cmake --build build --parallel ``` -For more advanced usage: -```sh -make -j$(nproc) # run on all core -make clean all # clear gen+obj and rebuild -CC=clang make # specify compiler -``` +The resulting binary will be `build/sm`. # Nintendo Switch - -Dependencies and requirements: - - * The `switch-sdl2` library +## Getting Dependencies +You will need: * [DevKitPro](https://github.com/devkitPro/installer) * [Atmosphere](https://github.com/Atmosphere-NX/Atmosphere) -1. Make sure you've installed Atmosphere on your Switch. -2. Please download the DevKitPro version of MSYS2 through their installer, as the default MSYS2 causes issues with windows compiling. -3. Now that you've installed DevKitPro, open up the location you've installed DevKitPro to, then find `mingw64.exe` inside `msys2` located in `devkitPro` folder. -4. Type `pacman -S git switch-dev switch-sdl2 switch-tools` in the terminal to install the `switch-sdl2` library. -5. CD to `switch` folder by typing `cd src/platfrom/switch` in the terminal on the `sm` root folder. -6. type `make` to compile the Switch Port. -7. Transfer the `.ini`, `nro`, `ncap` and your rom file to the Switch. +First, follow the [installation instructions on devkitPro's website](https://devkitpro.org/wiki/Getting_Started). -**OPTIONAL STEP** +Second, once you have pacman set up and synced, do: +```shell +pacman -S switch-dev switch-tools switch-sdl2 +``` -```sh -make -j$(nproc) # To build using all cores +## Building +In the top level directory, you can use the cmake preset for running a build for the switch: +```shell +cmake --preset nintendo-switch +cmake --build build-switch --parallel ``` + +## Getting SM on to your Switch +First, make sure you've installed [Atmosphere](https://github.com/Atmosphere-NX/Atmosphere) on your Switch. +Next, go into the `build-switch` directory and copy `sm.ini`, `sm.nro`, and `sm.ncap` and the sm rom +file to your Switch. \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a8d6b9a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,89 @@ +cmake_minimum_required(VERSION 3.18 FATAL_ERROR) + +project(sm + VERSION 0.0.1 + DESCRIPTION "Super Metroid PC Port" + HOMEPAGE_URL "https://github.com/snesrev/sm" + LANGUAGES C) + +if (CMAKE_BINARY_DIR EQUAL CMAKE_SOURCE_DIR) + message(WARNING "You are compiling in the source tree, you probably don't want to do that. Use -B to set the build directory") +endif() + +include(GNUInstallDirs) + +# Compiler Warnings +list(APPEND c_warnings + "-Wall" + "-fno-strict-aliasing") + +list(APPEND msvc_warnings + "/W3" + "/wd4996") + +# For installation later +set(ini_name "${PROJECT_SOURCE_DIR}/sm.ini") + +# Dependencies +# ------------ +# SDL +if (NINTENDO_SWITCH) + # Force static on Switch, just because it's easier + find_package(SDL2 REQUIRED COMPONENTS SDL2-static) +else() + find_package(SDL2 REQUIRED COMPONENTS SDL2) +endif() + +# OpenGL +# TODO: This should likely be removed +add_library(gl STATIC "third_party/gl_core/gl_core_3_1.c") +target_include_directories(gl PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") + +# Main Executable +# --------------- +add_executable(sm) +add_subdirectory(src) + +# Math library +find_library(MATHLIB m) + +# Target properties +target_link_libraries(sm PRIVATE + $<$:m> + SDL2::SDL2 gl) + +set_target_properties(sm PROPERTIES C_STANDARD 11) + +target_compile_options(sm PRIVATE + $,${msvc_warnings},${c_warnings}>) + +target_compile_definitions(sm PRIVATE + $<$>:SYSTEM_VOLUME_MIXER_AVAILABLE=0> + $<$:__SWITCH__>) + +# Nintendo Switch extra setup +if (NINTENDO_SWITCH) + # needs to be linked with g++ for C++ stdlib + enable_language(CXX) + set_target_properties(sm PROPERTIES + CXX_STANDARD 11 + LINKER_LANGUAGE CXX) + + nx_generate_nacp(sm.nacp + NAME "Super Metroid" + AUTHOR "snesrev & Lywx" + VERSION "${PROJECT_VERSION}") + + nx_create_nro(sm + NACP sm.nacp + ICON "${PROJECT_SOURCE_DIR}/src/platform/switch/icon.jpg") + + set(ini_name "${PROJECT_SOURCE_DIR}/src/platform/switch/sm.ini") +endif() + +# Installation +# ------------ +install(TARGETS sm RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + +# TODO: should be in some config dir +install(FILES "${ini_name}" DESTINATION "${CMAKE_INSTALL_BINDIR}") \ No newline at end of file diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..97da501 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 21, + "patch": 0 + }, + "configurePresets": [ + { + "name": "nintendo-switch", + "binaryDir": "${sourceDir}/build-switch", + "toolchainFile": "$env{DEVKITPRO}/cmake/Switch.cmake", + "condition": { + "type": "notEquals", + "lhs": "$env{DEVKITPRO}", + "rhs": "" + } + } + ] +} \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 1fcc86b..0000000 --- a/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -TARGET_EXEC:=sm - -SRCS:=$(wildcard src/*.c src/snes/*.c) third_party/gl_core/gl_core_3_1.c -OBJS:=$(SRCS:%.c=%.o) - -PYTHON:=/usr/bin/env python3 -CFLAGS:=$(if $(CFLAGS),$(CFLAGS),-O2 -fno-strict-aliasing -Werror ) -CFLAGS:=${CFLAGS} $(shell sdl2-config --cflags) -DSYSTEM_VOLUME_MIXER_AVAILABLE=0 -I. - -ifeq (${OS},Windows_NT) - WINDRES:=windres -# RES:=sm.res - SDLFLAGS:=-Wl,-Bstatic $(shell sdl2-config --static-libs) -else - SDLFLAGS:=$(shell sdl2-config --libs) -lm -endif - -.PHONY: all clean clean_obj - -all: $(TARGET_EXEC) -$(TARGET_EXEC): $(OBJS) $(RES) - $(CC) $^ -o $@ $(LDFLAGS) $(SDLFLAGS) - -%.o : %.c - $(CC) -c $(CFLAGS) $< -o $@ - -#$(RES): src/platform/win32/sm.rc -# @echo "Generating Windows resources" -# @$(WINDRES) $< -O coff -o $@ - -clean: clean_obj -clean_obj: - @$(RM) $(OBJS) $(TARGET_EXEC) diff --git a/README.md b/README.md index 4e9dc03..b84a0ed 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Our discord server is: https://discord.gg/AJJbJAzNNJ Early version. It has bugs and the code is messy. -For building instructions, see: https://github.com/snesrev/sm/blob/main/BUILDING.md +For building instructions, see: [BUILDING](./BUILDING.md) Put sm.smc (sha1 hash da957f0d63d14cb441d215462904c4fa8519c613) in the root folder. When running, it will run both versions and compare frame by frame. If it detects a mismatch, it saves a snapshot in saves/ and displays a counter on screen counting down from 300. diff --git a/sm.sln b/sm.sln deleted file mode 100644 index 82a190e..0000000 --- a/sm.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.3.32825.248 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sm", "src/sm.vcxproj", "{1F8AB1B4-DAFB-4D6E-BF1E-F802FF5A52EE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1F8AB1B4-DAFB-4D6E-BF1E-F802FF5A52EE}.Debug|x64.ActiveCfg = Debug|x64 - {1F8AB1B4-DAFB-4D6E-BF1E-F802FF5A52EE}.Debug|x64.Build.0 = Debug|x64 - {1F8AB1B4-DAFB-4D6E-BF1E-F802FF5A52EE}.Debug|x86.ActiveCfg = Debug|Win32 - {1F8AB1B4-DAFB-4D6E-BF1E-F802FF5A52EE}.Debug|x86.Build.0 = Debug|Win32 - {1F8AB1B4-DAFB-4D6E-BF1E-F802FF5A52EE}.Release|x64.ActiveCfg = Release|x64 - {1F8AB1B4-DAFB-4D6E-BF1E-F802FF5A52EE}.Release|x64.Build.0 = Release|x64 - {1F8AB1B4-DAFB-4D6E-BF1E-F802FF5A52EE}.Release|x86.ActiveCfg = Release|Win32 - {1F8AB1B4-DAFB-4D6E-BF1E-F802FF5A52EE}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {8F47385F-600A-41BA-AEF8-C47A2C0D15E6} - EndGlobalSection -EndGlobal diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index cbc684b..0000000 --- a/src/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/sm.vcxproj.user diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..83aa4e0 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,95 @@ +target_sources(sm PRIVATE + "config.c" + "config.h" + "enemy_types.h" + "features.h" + "funcs.h" + "glsl_shader.c" + "glsl_shader.h" + "ida_types.h" + "main.c" + "opengl.c" + "sm_80.c" + "sm_81.c" + "sm_82.c" + "sm_84.c" + "sm_85.c" + "sm_86.c" + "sm_87.c" + "sm_88.c" + "sm_89.c" + "sm_8b.c" + "sm_8d.c" + "sm_8f.c" + "sm_90.c" + "sm_91.c" + "sm_92.c" + "sm_93.c" + "sm_94.c" + "sm_9b.c" + "sm_a0.c" + "sm_a2.c" + "sm_a3.c" + "sm_a4.c" + "sm_a5.c" + "sm_a6.c" + "sm_a7.c" + "sm_a8.c" + "sm_a9.c" + "sm_aa.c" + "sm_ad.c" + "sm_b2.c" + "sm_b3.c" + "sm_b4.c" + "sm_cpu_infra.c" + "sm_cpu_infra.h" + "sm_rtl.c" + "sm_rtl.h" + "spc_player.c" + "spc_player.h" + "spc_variables.h" + "tracing.c" + "tracing.h" + "types.h" + "util.c" + "util.h" + "variables_extra.h" + "variables.h" + + "snes/apu.c" + "snes/apu.h" + "snes/cart.c" + "snes/cart.h" + "snes/cpu.c" + "snes/cpu.h" + "snes/dma.c" + "snes/dma.h" + "snes/dsp.c" + "snes/dsp.h" + "snes/dsp_regs.h" + "snes/input.c" + "snes/input.h" + "snes/ppu.c" + "snes/ppu.h" + "snes/saveload.h" + "snes/snes.c" + "snes/snes.h" + "snes/snes_other.c" + "snes/spc.c" + "snes/spc.h" +) + +if (WIN32) + target_sources(sm PRIVATE + "platform/win32/volume_control.c" + "platform/win32/volume_control.h" + ) +endif() + +if (NINTENDO_SWITCH) + target_include_directories(sm PRIVATE "platform/switch/src") + target_sources(sm PRIVATE + "platform/switch/src/switch_impl.c" + "platform/switch/src/switch_impl.h" + ) +endif() \ No newline at end of file diff --git a/src/packages.config b/src/packages.config deleted file mode 100644 index 7ede8af..0000000 --- a/src/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/platform/switch/Makefile b/src/platform/switch/Makefile deleted file mode 100644 index d624f72..0000000 --- a/src/platform/switch/Makefile +++ /dev/null @@ -1,224 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") -endif - -TOPDIR ?= $(CURDIR) -include $(DEVKITPRO)/libnx/switch_rules - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional) -# -# NO_ICON: if set to anything, do not use icon. -# NO_NACP: if set to anything, no .nacp file is generated. -# APP_TITLE is the name of the app stored in the .nacp file (Optional) -# APP_AUTHOR is the author of the app stored in the .nacp file (Optional) -# APP_VERSION is the version of the app stored in the .nacp file (Optional) -# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional) -# ICON is the filename of the icon (.jpg), relative to the project folder. -# If not set, it attempts to use one of the following (in this order): -# - .jpg -# - icon.jpg -# - /default_icon.jpg -# -# CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder. -# If not set, it attempts to use one of the following (in this order): -# - .json -# - config.json -# If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead -# of a homebrew executable (.nro). This is intended to be used for sysmodules. -# NACP building is skipped as well. -#--------------------------------------------------------------------------------- -SRC_DIR := ../../ -TARGET := sm -BUILD := bin -SOURCES := $(SRC_DIR) $(SRC_DIR)/snes $(SRC_DIR)/platform/switch/src $(SRC_DIR)/../third_party/gl_core - -CFILES := $(wildcard $(SRC_DIR)/*.c $(SRC_DIR)/snes/*.c $(SRC_DIR)/platform/switch/src/*.c) $(SRC_DIR)/../third_party/gl_core/gl_core_3_1.c - -INCLUDES := include $(SRC_DIR)/../ ./src/ -APP_TITLE := Super Metroid -APP_AUTHOR := snesrev & Lywx -APP_VERSION := $(shell git rev-parse --short HEAD) $(shell git rev-parse --abbrev-ref HEAD) - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE - -CFLAGS := -g -Wall -O2 -ffunction-sections -Wno-parentheses \ - $(ARCH) $(DEFINES) - -CFLAGS += -D__SWITCH__ $(INCLUDE) -DSTBI_NO_THREAD_LOCALS `sdl2-config --cflags` - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -CFLAGS += -std=gnu11 - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -LIBS := `$(PREFIX)pkg-config --libs sdl2` -lnx -lm - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(LIBNX) - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/$(TARGET) -export TOPDIR := $(CURDIR) - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ - - -export DEPSDIR := $(CURDIR)/$(BUILD) - -#CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -#CFILES := $(wildcard ../../*.c ../../snes/*.c) ../../third_party/gl_core/gl_core_3_1.c ../../third_party/opus-1.3.1-stripped/opus_decoder_amalgam.c -#CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -#SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -export LD := $(CXX) -#--------------------------------------------------------------------------------- - -export OFILES_BIN := $(addsuffix .o,$(BINFILES)) -export OFILES_SRC := $(CPPFILES:.cpp=.o) $(notdir $(CFILES:.c=.o)) $(SFILES:.s=.o) -export OFILES := $(OFILES_BIN) $(OFILES_SRC) -export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) - -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) - -export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) - -$(info $(OFILES)) - -ifeq ($(strip $(CONFIG_JSON)),) - jsons := $(wildcard *.json) - ifneq (,$(findstring $(TARGET).json,$(jsons))) - export APP_JSON := $(TOPDIR)/$(TARGET).json - else - ifneq (,$(findstring config.json,$(jsons))) - export APP_JSON := $(TOPDIR)/config.json - endif - endif -else - export APP_JSON := $(TOPDIR)/$(CONFIG_JSON) -endif - -ifeq ($(strip $(ICON)),) - icons := $(wildcard *.jpg) - ifneq (,$(findstring $(TARGET).jpg,$(icons))) - export APP_ICON := $(TOPDIR)/$(TARGET).jpg - else - ifneq (,$(findstring icon.jpg,$(icons))) - export APP_ICON := $(TOPDIR)/icon.jpg - endif - endif -else - export APP_ICON := $(TOPDIR)/$(ICON) -endif - -ifeq ($(strip $(NO_ICON)),) - export NROFLAGS += --icon=$(APP_ICON) -endif - -ifeq ($(strip $(NO_NACP)),) - export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp -endif - -ifneq ($(APP_TITLEID),) - export NACPFLAGS += --titleid=$(APP_TITLEID) -endif - -ifneq ($(ROMFS),) - export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS) -endif - -.PHONY: $(BUILD) clean all - -#--------------------------------------------------------------------------------- -all: $(BUILD) - -$(BUILD): - @echo $(CFILES) ... - @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... -ifeq ($(strip $(APP_JSON)),) - @rm -fr $(BUILD) $(TARGET).nro $(TARGET).nacp $(TARGET).elf -else - @rm -fr $(BUILD) $(TARGET).nsp $(TARGET).nso $(TARGET).npdm $(TARGET).elf -endif - - -#--------------------------------------------------------------------------------- -else -.PHONY: all - -DEPENDS := $(OFILES:.o=.d) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -ifeq ($(strip $(APP_JSON)),) - -all : $(OUTPUT).nro - -ifeq ($(strip $(NO_NACP)),) -$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp -else -$(OUTPUT).nro : $(OUTPUT).elf -endif - -else - -all : $(OUTPUT).nsp - -$(OUTPUT).nsp : $(OUTPUT).nso $(OUTPUT).npdm - -$(OUTPUT).nso : $(OUTPUT).elf - -endif - -$(OUTPUT).elf : $(OFILES) - -$(OFILES_SRC) : $(HFILES_BIN) - -#--------------------------------------------------------------------------------- -# you need a rule like this for each extension you use as binary data -#--------------------------------------------------------------------------------- -%.bin.o %_bin.h : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - --include $(DEPENDS) - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/sm.vcxproj b/src/sm.vcxproj deleted file mode 100644 index c7355e7..0000000 --- a/src/sm.vcxproj +++ /dev/null @@ -1,276 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 17.0 - {1F8AB1B4-DAFB-4D6E-BF1E-F802FF5A52EE} - Win32Proj - 10.0 - - - - Application - true - v143 - - - Application - false - v143 - - - Application - true - v143 - - - Application - false - v143 - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)build\bin-$(Platform)-$(Configuration)\ - $(SolutionDir)build\obj-$(Platform)-$(Configuration)\ - - - true - $(SolutionDir)build\bin-$(Platform)-$(Configuration)\ - $(SolutionDir)build\obj-$(Platform)-$(Configuration)\ - - - $(SolutionDir)build\bin-$(Platform)-$(Configuration)\ - $(SolutionDir)build\obj-$(Platform)-$(Configuration)\ - - - $(SolutionDir)build\bin-$(Platform)-$(Configuration)\ - $(SolutionDir)build\obj-$(Platform)-$(Configuration)\ - - - - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS - MultiThreadedDebugDLL - Level3 - ProgramDatabase - Disabled - $(SolutionDir) - Default - 4996 - stdc11 - - - MachineX86 - true - Console - $(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS - MultiThreadedDLL - Level3 - ProgramDatabase - $(SolutionDir) - 4996 - stdc11 - - - MachineX86 - true - Console - true - true - $(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - $(SolutionDir) - Level3 - ;_CRT_SECURE_NO_WARNINGS - Default - 4996 - stdc11 - true - - - $(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - $(SolutionDir) - Level3 - ;_CRT_SECURE_NO_WARNINGS - 4996 - stdc11 - - - $(CoreLibraryDependencies);%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - stdc17 - stdc17 - stdc17 - stdc17 - - - - - - - - - - - - - - - - - - - - - - - - - - - Disabled - Disabled - - - MinSpace - MinSpace - - - Disabled - Disabled - - - Disabled - Disabled - - - Disabled - Disabled - - - MinSpace - MinSpace - - - Disabled - Disabled - - - - - MinSpace - MinSpace - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/src/sm.vcxproj.filters b/src/sm.vcxproj.filters deleted file mode 100644 index 08f7da9..0000000 --- a/src/sm.vcxproj.filters +++ /dev/null @@ -1,270 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - {e1763dbc-4fb3-417f-ad1a-8436411c3b7a} - - - {2b72ed96-9194-4c2c-b1e5-15445f0a9550} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Shader - - - Shader - - - Shader - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Snes - - - Shader - - - Shader - - - - - - \ No newline at end of file diff --git a/third_party/.gitignore b/third_party/.gitignore deleted file mode 100644 index 1fbecd9..0000000 --- a/third_party/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/tcc/ -/SDL2-2.24.1/ -/gl_core/*.o \ No newline at end of file diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt new file mode 100644 index 0000000..ea8f19b --- /dev/null +++ b/third_party/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(sm PRIVATE + "gl_core/gl_core_3_1.c" +) \ No newline at end of file From 3e57920da321f3f1f349dfd982aec10912a711b7 Mon Sep 17 00:00:00 2001 From: LaserEyess Date: Mon, 29 May 2023 16:16:22 -0400 Subject: [PATCH 2/2] Switch build system to CMake This unifies the build system across platforms, including doing development inside Visual Studio. No change to other code.