Convert sameboy makefile into cmakelists, use clang-cl to build sameboy, update sameboy
This commit is contained in:
parent
601ab5205d
commit
5df8ce3b8e
Binary file not shown.
|
@ -1 +1 @@
|
|||
/obj
|
||||
build/
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#undef GB_INTERNAL // don't rely on GB_INTERNAL in interface
|
||||
#include <string.h>
|
||||
#include <gb.h>
|
||||
|
||||
#include "gb.h"
|
||||
#include "blip_buf.h"
|
||||
#include "stdio.h"
|
||||
|
||||
#define EXPORT __attribute__((visibility("default")))
|
||||
#ifdef _WIN32
|
||||
#define EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
typedef int8_t s8;
|
||||
typedef int16_t s16;
|
||||
|
@ -129,6 +132,11 @@ static void PrinterCallbackRelay(GB_gameboy_t* gb, u32* image, u8 height, u8 top
|
|||
((biz_t*)gb)->printer_cb(image, height, top_margin, bottom_margin, exposure);
|
||||
}
|
||||
|
||||
static void PrinterDoneCallbackRelay(GB_gameboy_t* gb)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
static void ScanlineCallbackRelay(GB_gameboy_t* gb, u8 line)
|
||||
{
|
||||
biz_t* biz = (biz_t*)gb;
|
||||
|
@ -503,7 +511,7 @@ EXPORT void sameboy_setprintercallback(biz_t* biz, printer_callback_t callback)
|
|||
biz->printer_cb = callback;
|
||||
if (callback)
|
||||
{
|
||||
GB_connect_printer(&biz->gb, PrinterCallbackRelay);
|
||||
GB_connect_printer(&biz->gb, PrinterCallbackRelay, PrinterDoneCallbackRelay);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
|
||||
|
||||
if(POLICY CMP0092)
|
||||
cmake_policy(SET CMP0092 NEW)
|
||||
endif()
|
||||
|
||||
project(sameboy C)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_C_EXTENSIONS ON)
|
||||
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
||||
|
||||
if(MSVC)
|
||||
# max warnings
|
||||
add_compile_options(/W4)
|
||||
|
||||
# ignore some warnings on clang
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-Wno-unused-parameter -Wno-sign-compare -Wno-missing-braces -Wno-missing-field-initializers)
|
||||
endif()
|
||||
|
||||
# all files are utf8
|
||||
add_compile_options(/utf-8)
|
||||
|
||||
# max conformance mode
|
||||
add_compile_options(/permissive-)
|
||||
add_compile_options(/volatile:iso)
|
||||
add_compile_options(/fp:precise)
|
||||
else()
|
||||
# max warnings
|
||||
add_compile_options(-Wall -Wextra)
|
||||
# ignore a few warnings
|
||||
add_compile_options(-Wno-unused-parameter -Wno-sign-compare -Wno-missing-braces -Wno-missing-field-initializers)
|
||||
|
||||
# strip in release, optimize for gdb usage in debug
|
||||
add_link_options($<$<CONFIG:RELEASE>:-s>)
|
||||
add_compile_options($<$<CONFIG:DEBUG>:-ggdb>)
|
||||
|
||||
# use lld for clang (needed if doing lto)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
add_link_options(-fuse-ld=lld)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# make sure we have a "lib" prefix (currently expected across all platforms)
|
||||
set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
||||
|
||||
set(CORE_DIR ${CMAKE_SOURCE_DIR}/libsameboy/Core)
|
||||
|
||||
add_library(
|
||||
core
|
||||
STATIC
|
||||
${CORE_DIR}/apu.c
|
||||
${CORE_DIR}/apu.h
|
||||
${CORE_DIR}/camera.c
|
||||
${CORE_DIR}/camera.h
|
||||
${CORE_DIR}/defs.h
|
||||
${CORE_DIR}/display.c
|
||||
${CORE_DIR}/display.h
|
||||
${CORE_DIR}/gb.c
|
||||
${CORE_DIR}/gb.h
|
||||
${CORE_DIR}/joypad.c
|
||||
${CORE_DIR}/joypad.h
|
||||
${CORE_DIR}/mbc.c
|
||||
${CORE_DIR}/mbc.h
|
||||
${CORE_DIR}/memory.c
|
||||
${CORE_DIR}/memory.h
|
||||
${CORE_DIR}/model.h
|
||||
${CORE_DIR}/printer.c
|
||||
${CORE_DIR}/printer.h
|
||||
${CORE_DIR}/random.c
|
||||
${CORE_DIR}/random.h
|
||||
${CORE_DIR}/rumble.c
|
||||
${CORE_DIR}/rumble.h
|
||||
${CORE_DIR}/save_state.c
|
||||
${CORE_DIR}/save_state.h
|
||||
${CORE_DIR}/sgb.c
|
||||
${CORE_DIR}/sgb.h
|
||||
${CORE_DIR}/sm83_cpu.c
|
||||
${CORE_DIR}/sm83_cpu.h
|
||||
${CORE_DIR}/timing.c
|
||||
${CORE_DIR}/timing.h
|
||||
)
|
||||
|
||||
target_compile_definitions(core PUBLIC _USE_MATH_DEFINES _CRT_SECURE_NO_WARNINGS)
|
||||
target_compile_definitions(core PUBLIC GB_DISABLE_DEBUGGER GB_DISABLE_CHEATS GB_DISABLE_TIMEKEEPING GB_DISABLE_REWIND GB_VERSION="BizHawk")
|
||||
target_compile_definitions(core PRIVATE GB_INTERNAL)
|
||||
target_include_directories(core PUBLIC ${CORE_DIR})
|
||||
|
||||
if(MSVC)
|
||||
target_include_directories(core PUBLIC ${CMAKE_SOURCE_DIR}/libsameboy/Windows)
|
||||
endif()
|
||||
|
||||
add_library(
|
||||
sameboy
|
||||
SHARED
|
||||
${CMAKE_SOURCE_DIR}/BizInterface.c
|
||||
${CMAKE_SOURCE_DIR}/blip_buf.c
|
||||
)
|
||||
|
||||
target_link_libraries(sameboy PRIVATE core)
|
||||
|
||||
add_custom_command(
|
||||
TARGET sameboy
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy $<TARGET_FILE:sameboy> ${CMAKE_SOURCE_DIR}/../../Assets/dll
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy $<TARGET_FILE:sameboy> ${CMAKE_SOURCE_DIR}/../../output/dll
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
set(PDB_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../../output/dll)
|
||||
endif()
|
|
@ -0,0 +1,6 @@
|
|||
rmdir /s /q build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang-cl -G Ninja
|
||||
ninja
|
||||
cd ..
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
if [ -z "$CC" ]; then export CC="clang"; fi
|
||||
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=$CC -G Ninja
|
||||
ninja
|
|
@ -0,0 +1,6 @@
|
|||
rmdir /s /q build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_C_COMPILER=clang-cl -G Ninja
|
||||
ninja
|
||||
cd ..
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
if [ -z "$CC" ]; then export CC="clang"; fi
|
||||
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_C_COMPILER=$CC -G Ninja
|
||||
ninja
|
|
@ -1 +1 @@
|
|||
Subproject commit 55507274d6efdf3a511eceabf9c89d7a096702b3
|
||||
Subproject commit bd31258725ff587f56536c6b31e9fa128e2f38ef
|
Loading…
Reference in New Issue