Update build system
This commit is contained in:
parent
5d3c02e077
commit
1053351da6
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
build/current
|
||||
build/gba
|
||||
build/sdl
|
||||
build/sdl_debug
|
||||
build/*-release
|
||||
build/*-debug
|
||||
|
@ -6,10 +6,13 @@ set(WOMBAT_BUILD_TYPE "Native" CACHE STRING "The type of build to produce(Native
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||
include(address_sanitizer)
|
||||
include(GBA)
|
||||
|
||||
if (WOMBAT_BUILD_TYPE STREQUAL "GBA")
|
||||
include(GBA)
|
||||
endif()
|
||||
|
||||
add_definitions(
|
||||
-std=c++14
|
||||
-std=c++11
|
||||
-Wall
|
||||
-Wsign-compare
|
||||
-nostdlib
|
||||
|
55
Makefile
55
Makefile
@ -1,21 +1,25 @@
|
||||
OS=$(shell uname | tr [:upper:] [:lower:])
|
||||
TARGET=${OS}-$(shell uname -m)
|
||||
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
||||
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${DEVENV} 2>&1),running)
|
||||
ENV_RUN=docker exec --user $(shell id -u ${USER}) ${DEVENV}
|
||||
endif
|
||||
|
||||
make:
|
||||
${ENV_RUN} make -j -C build
|
||||
${ENV_RUN} make -j -C build TARGET=${TARGET}
|
||||
preinstall:
|
||||
${ENV_RUN} make -j -C build ARGS="preinstall"
|
||||
${ENV_RUN} make -j -C build ARGS="preinstall" TARGET=${TARGET}
|
||||
install:
|
||||
${ENV_RUN} make -j -C build ARGS="install"
|
||||
${ENV_RUN} make -j -C build ARGS="install" TARGET=${TARGET}
|
||||
clean:
|
||||
${ENV_RUN} make -j -C build ARGS="clean"
|
||||
${ENV_RUN} make -j -C build ARGS="clean" TARGET=${TARGET}
|
||||
purge:
|
||||
${ENV_RUN} rm -rf $(shell find build -mindepth 1 -maxdepth 1 -type d)
|
||||
test:
|
||||
${ENV_RUN} make -j -C build ARGS="test"
|
||||
${ENV_RUN} make -j -C build ARGS="test" TARGET=${TARGET}
|
||||
run: make
|
||||
./build/current/src/wombat/wombat -debug
|
||||
debug: make
|
||||
gdb: make
|
||||
gdb ./build/current/src/wombat/wombat
|
||||
devenv:
|
||||
docker pull wombatant/devenv
|
||||
@ -24,18 +28,35 @@ devenv:
|
||||
--name ${DEVENV} -t wombatant/devenv bash
|
||||
devenv-destroy:
|
||||
docker rm -f ${DEVENV}
|
||||
devenv-shell:
|
||||
docker exec -i --user $(shell id -u ${USER}) ${DEVENV} ls /usr/bin/x86_64-w64-mingw32-g++
|
||||
|
||||
sdl:
|
||||
${ENV_RUN} ./scripts/setup_build
|
||||
rm -f build/current
|
||||
ln -s sdl build/current
|
||||
release:
|
||||
${ENV_RUN} rm -rf build/${TARGET}-release
|
||||
${ENV_RUN} ./scripts/setup_build ${TARGET}
|
||||
${ENV_RUN} rm -f build/current
|
||||
${ENV_RUN} ln -s ${TARGET}-release build/current
|
||||
|
||||
sdl_debug:
|
||||
${ENV_RUN} ./scripts/setup_build_debug
|
||||
rm -f build/current
|
||||
ln -s sdl_debug build/current
|
||||
debug:
|
||||
${ENV_RUN} rm -rf build/${TARGET}-debug
|
||||
${ENV_RUN} ./scripts/setup_build ${TARGET} debug
|
||||
${ENV_RUN} rm -f build/current
|
||||
${ENV_RUN} ln -s ${TARGET}-debug build/current
|
||||
|
||||
windows:
|
||||
${ENV_RUN} rm -rf build/windows
|
||||
${ENV_RUN} ./scripts/setup_build windows
|
||||
${ENV_RUN} rm -f build/current
|
||||
${ENV_RUN} ln -s windows build/current
|
||||
|
||||
windows-debug:
|
||||
${ENV_RUN} rm -rf build/windows
|
||||
${ENV_RUN} ./scripts/setup_build windows debug
|
||||
${ENV_RUN} rm -f build/current
|
||||
${ENV_RUN} ln -s windows build/current
|
||||
|
||||
gba:
|
||||
${ENV_RUN} ./scripts/setup_build_gba
|
||||
rm -f build/current
|
||||
ln -s gba build/current
|
||||
${ENV_RUN} rm -rf build/gba-release
|
||||
${ENV_RUN} ./scripts/setup_build gba
|
||||
${ENV_RUN} rm -f build/current
|
||||
${ENV_RUN} ln -s gba-release build/current
|
||||
|
@ -1,16 +1,28 @@
|
||||
all: gba_build sdl_build sdl_debug_build
|
||||
all: gba_build native_build native_debug_build windows_release windows_debug
|
||||
|
||||
MAKE=make -j
|
||||
|
||||
gba_build:
|
||||
@if [ -d gba ]; then \
|
||||
make -C gba ${ARGS}; \
|
||||
@if [ -d gba-release ]; then \
|
||||
${MAKE} -C gba-release ${ARGS}; \
|
||||
fi
|
||||
|
||||
sdl_build:
|
||||
@if [ -d sdl ]; then \
|
||||
make -C sdl ${ARGS}; \
|
||||
native_build:
|
||||
@if [ -d ${TARGET}-release ]; then \
|
||||
${MAKE} -C ${TARGET}-release ${ARGS}; \
|
||||
fi
|
||||
|
||||
sdl_debug_build:
|
||||
@if [ -d sdl_debug ]; then \
|
||||
make -C sdl_debug ${ARGS}; \
|
||||
native_debug_build:
|
||||
@if [ -d ${TARGET}-debug ]; then \
|
||||
${MAKE} -C ${TARGET}-debug ${ARGS}; \
|
||||
fi
|
||||
|
||||
windows_release:
|
||||
@if [ -d windows-release ]; then \
|
||||
${MAKE} -C windows-release ${ARGS}; \
|
||||
fi
|
||||
|
||||
windows_debug:
|
||||
@if [ -d windows-debug ]; then \
|
||||
${MAKE} -C windows-debug ${ARGS}; \
|
||||
fi
|
||||
|
18
cmake/Modules/Mingw.cmake
Normal file
18
cmake/Modules/Mingw.cmake
Normal file
@ -0,0 +1,18 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
|
||||
|
||||
# cross compilers to use for C and C++
|
||||
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
|
||||
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
||||
|
||||
# target environment on the build host system
|
||||
# set 1st to dir with the cross compiler's C/C++ headers/libs
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
# modify default behavior of FIND_XXX() commands to
|
||||
# search for headers/libs in the target environment and
|
||||
# search for programs in the build host environment
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
@ -1,8 +1,30 @@
|
||||
#! /usr/bin/env bash
|
||||
project=`pwd`/
|
||||
buildDir="build/sdl"
|
||||
|
||||
set -e
|
||||
|
||||
project=$(pwd)/
|
||||
|
||||
TARGET=$1
|
||||
BUILD_TYPE=$2
|
||||
|
||||
if [[ $TARGET == windows ]]; then
|
||||
toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/Mingw.cmake"
|
||||
elif [[ $TARGET == gba ]]; then
|
||||
toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/GBA.cmake -DWOMBAT_BUILD_TYPE=GBA"
|
||||
fi
|
||||
|
||||
if [[ $BUILD_TYPE == debug ]]; then
|
||||
buildTypeArgs="-DUSE_ASAN=ON -DCMAKE_BUILD_TYPE=Debug"
|
||||
buildDir="build/${TARGET}-debug"
|
||||
else
|
||||
buildTypeArgs="-DCMAKE_BUILD_TYPE=Release"
|
||||
buildDir="build/${TARGET}-release"
|
||||
fi
|
||||
|
||||
mkdir -p $buildDir
|
||||
pushd $buildDir
|
||||
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release $project
|
||||
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
$buildTypeArgs \
|
||||
$toolchain \
|
||||
$project
|
||||
popd
|
||||
|
@ -1,8 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
project=`pwd`
|
||||
buildDir="build/sdl_debug"
|
||||
|
||||
mkdir -p $buildDir
|
||||
pushd $buildDir
|
||||
cmake -DUSE_ASAN=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug $project
|
||||
popd
|
@ -1,8 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
project=`pwd`
|
||||
buildDir="build/gba"
|
||||
|
||||
mkdir -p $buildDir
|
||||
pushd $buildDir
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_TOOLCHAIN_FILE=cmake/Modules/GBA.cmake -DWOMBAT_BUILD_TYPE=GBA $project
|
||||
popd
|
@ -11,13 +11,13 @@ if(WOMBAT_BUILD_TYPE STREQUAL "Native")
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
set(LIBS ${LIBS} ${OPENGL_LIBRARY})
|
||||
|
||||
find_package(SDL_IMAGE REQUIRED)
|
||||
include_directories(${SDL_IMAGE_INCLUDE_DIR})
|
||||
set(LIBS ${LIBS} ${SDL_IMAGE_LIBRARY})
|
||||
#find_package(SDL_IMAGE REQUIRED)
|
||||
#include_directories(${SDL_IMAGE_INCLUDE_DIR})
|
||||
#set(LIBS ${LIBS} ${SDL_IMAGE_LIBRARY})
|
||||
|
||||
find_package(SDL_ttf REQUIRED)
|
||||
include_directories(${SDL_TTF_INCLUDE_DIR})
|
||||
set(LIBS ${LIBS} ${SDL_TTF_LIBRARY})
|
||||
#find_package(SDL_ttf REQUIRED)
|
||||
#include_directories(${SDL_TTF_INCLUDE_DIR})
|
||||
#set(LIBS ${LIBS} ${SDL_TTF_LIBRARY})
|
||||
elseif(WOMBAT_BUILD_TYPE STREQUAL "GBA")
|
||||
endif()
|
||||
|
||||
|
@ -1,16 +1,18 @@
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
|
||||
if(WOMBAT_BUILD_TYPE STREQUAL "GBA")
|
||||
enable_language(C ASM)
|
||||
set(
|
||||
CPP
|
||||
gba/core.cpp
|
||||
gba/gfx.cpp
|
||||
)
|
||||
include_directories("gba")
|
||||
elseif(WOMBAT_BUILD_TYPE STREQUAL "Native")
|
||||
endif()
|
||||
|
||||
add_library(NostalgiaCore OBJECT ${CPP})
|
||||
add_library(NostalgiaCore
|
||||
${CPP}
|
||||
core.cpp
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
|
@ -5,14 +5,15 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#include "../types.hpp"
|
||||
#include "registers.hpp"
|
||||
#include "gfx.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace core {
|
||||
|
||||
int init() {
|
||||
return 0;
|
||||
Error init() {
|
||||
auto err = initGfx();
|
||||
return err;
|
||||
}
|
||||
|
||||
}
|
@ -6,14 +6,12 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
int main() {
|
||||
*(unsigned int*)0x04000000 = 0x0403;
|
||||
#include "gfx.hpp"
|
||||
|
||||
((unsigned short*)0x06000000)[120+80*240] = 0x001F;
|
||||
((unsigned short*)0x06000000)[136+80*240] = 0x03E0;
|
||||
((unsigned short*)0x06000000)[120+96*240] = 0x7C00;
|
||||
namespace nostalgia {
|
||||
namespace core {
|
||||
|
||||
while(1);
|
||||
Error init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -5,4 +5,23 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "registers.hpp"
|
||||
#include "../types.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace core {
|
||||
|
||||
Error initGfx() {
|
||||
/* Sprite Mode ----\ */
|
||||
/* ---\| */
|
||||
/* Background 2 -\|| */
|
||||
/* Objects -----\||| */
|
||||
/* |||| */
|
||||
REG_DISPCNT = 0x1400;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
17
src/core/gfx.hpp
Normal file
17
src/core/gfx.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2016 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "types.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace core {
|
||||
|
||||
Error initGfx();
|
||||
|
||||
}
|
||||
}
|
@ -8,8 +8,6 @@
|
||||
#ifndef NOSTALGIA_CORE_TYPES_HPP
|
||||
#define NOSTALGIA_CORE_TYPES_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace nostalgia {
|
||||
namespace core {
|
||||
|
||||
@ -23,6 +21,8 @@ typedef unsigned uint_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
|
||||
typedef uint32_t Error;
|
||||
|
||||
#ifdef _LP64
|
||||
typedef uint64_t size_t;
|
||||
#elif _LP32
|
||||
|
@ -7,13 +7,16 @@ set(WOMBAT_BUILD_TYPE "Native" CACHE STRING "The type of build to produce(Native
|
||||
add_executable(
|
||||
nostalgia
|
||||
main.cpp
|
||||
${OBJS}
|
||||
)
|
||||
|
||||
#target_link_libraries(wombat ${LIBS})
|
||||
set_target_properties(nostalgia
|
||||
if(COMMAND objcopy_file)
|
||||
set_target_properties(nostalgia
|
||||
PROPERTIES
|
||||
LINK_FLAGS ${LINKER_FLAGS}
|
||||
COMPILER_FLAGS "-mthumb -mthumb-interwork"
|
||||
)
|
||||
objcopy_file(nostalgia)
|
||||
)
|
||||
|
||||
objcopy_file(nostalgia)
|
||||
endif()
|
||||
|
||||
target_link_libraries(nostalgia NostalgiaCore)
|
||||
|
@ -6,6 +6,16 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "core/core.hpp"
|
||||
|
||||
using namespace nostalgia;
|
||||
|
||||
int main() {
|
||||
core::init();
|
||||
|
||||
((unsigned short*)0x06000000)[120+80*240] = 0x001F;
|
||||
((unsigned short*)0x06000000)[136+80*240] = 0x03E0;
|
||||
((unsigned short*)0x06000000)[120+96*240] = 0x7C00;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user