Skip to content

Commit

Permalink
Replace Make with CMake (#21)
Browse files Browse the repository at this point in the history
* Remove libHana submodule
* Add CMakeLists and sources for glad
* Rename glad/ -> imgui/glad/
* Add CMakeLists for imgui
* Add CMakeLists for ruby
* Remove bin directory
* Add HANA CMake option to configure GDB support
* Remove Makefiles
* Update Visual Studio Code launch configuration with CMake target
* Update .gitignore with CMake paths
* Update README.md with CMake instructions
* Add libHana to linguist-vendored in .gitattributes
  • Loading branch information
UnsafePointer authored Jul 29, 2019
1 parent 256fe76 commit f8ca741
Show file tree
Hide file tree
Showing 22 changed files with 8,259 additions and 170 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
imgui/* linguist-vendored
hana/* linguist-vendored
44 changes: 24 additions & 20 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

# Created by https://www.gitignore.io/api/c++,linux,visualstudiocode
# Edit at https://www.gitignore.io/?templates=c++,linux,visualstudiocode
# Created by https://www.gitignore.io/api/c++,linux,visualstudiocode,cmake
# Edit at https://www.gitignore.io/?templates=c++,linux,visualstudiocode,cmake

### C++ ###
# Prerequisites
Expand Down Expand Up @@ -36,6 +35,23 @@
*.out
*.app

### CMake ###
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps

### CMake Patch ###
# External projects
*-prefix/

### Linux ###
*~

Expand All @@ -62,29 +78,14 @@
# Ignore all local history of files
.history

# End of https://www.gitignore.io/api/c++,linux,visualstudiocode
# End of https://www.gitignore.io/api/c++,linux,visualstudiocode,cmake

# PlayStation BIOS (MD5: 924e392ed05558ffdb115408c263dccf)
SCPH1001.BIN

# Hopper Disassembler project
SCPH1001.hop

# Binary
bin/

# Valgrind
valgrind-out.txt

# glad
glad/

# hana
include/libHana.h
lib/libHana

# CPU tests
tests.exe

# RAM dump
ram.bin

Expand All @@ -93,3 +94,6 @@ ruby.log

## Dear ImGui Ini files
imgui.ini

# build dir
build/
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "libHana"]
path = libHana
url = [email protected]:Ruenzuo/libHana.git
7 changes: 2 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
"version": "0.2.0",
"configurations": [
{
"name": "C++ Debug (gdb)",
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/ruby",
"preLaunchTask": "Build C++ project",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
Expand Down
55 changes: 0 additions & 55 deletions .vscode/settings.json

This file was deleted.

14 changes: 0 additions & 14 deletions .vscode/tasks.json

This file was deleted.

22 changes: 22 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.10.2)
project(ruby)

option(HANA "Compile with GDB support")

file(GLOB_RECURSE RUBY_INCLUDE inlude/*.hpp inlude/*.tcc)
file(GLOB_RECURSE RUBY_SOURCES src/*.cpp)

include_directories(include)

add_subdirectory(imgui)

add_executable(ruby ${RUBY_INCLUDE} ${RUBY_SOURCES})
target_link_libraries(ruby imgui)
if (HANA)
find_package(Threads)
include_directories(hana/include)
add_definitions(-DHANA)
target_link_libraries(ruby ${CMAKE_CURRENT_SOURCE_DIR}/hana/libHana.a)
target_link_libraries(ruby ${CMAKE_THREAD_LIBS_INIT})
endif(HANA)
set_property(TARGET ruby PROPERTY CXX_STANDARD 17)
1 change: 0 additions & 1 deletion Makefile

This file was deleted.

32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,26 @@ ruby (ルビィ) is a [PlayStation](https://en.wikipedia.org/wiki/PlayStation_(c
#### Prerequisites

- PlayStation BIOS: SCPH1001 (SHA1: 10155d8d6e6e832d6ea66db9bc098321fb5e8ebf)
- Python 2.7
- [glad](https://github.com/Dav1dde/glad)
- C++17
- OpenGL 4.5
- SDL2
- Go 1.12 (only for GDB support)

#### Compiling

```
$ make
$ mkdir build
$ cd build
$ cmake ..
$ make -j8
```

#### Compiling with GDB support

```
$ git submodule update --init --recursive
$ make -f x86_64_with_debugger.mk install_hana
$ make -f x86_64_with_debugger.mk
$ mkdir build
$ cd build
$ cmake -DHANA=ON ..
$ make -j8
```

#### GDB support
Expand All @@ -71,12 +72,27 @@ $ (gdb) info registers

For a comprehensive list of supported GDB features, see [libHana](https://github.com/Ruenzuo/libHana).

#### Compiling release build

```
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make -j8
```

### Running

```
$ ./build/ruby # with SCPH1001.BIN in $PWD
```

### Tests

#### Running

```
./bin/ruby --exe TESTNAME.exe
$ ./build/ruby --exe TESTNAME.exe
```

#### CPU Tests
Expand Down
Empty file removed bin/.keep
Empty file.
119 changes: 119 additions & 0 deletions hana/include/libHana.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/* Code generated by cmd/cgo; DO NOT EDIT. */

/* package _/home/ruenzuo/GitHub/UnsafePointer/ruby/libHana */


#line 1 "cgo-builtin-export-prolog"

#include <stddef.h> /* for ptrdiff_t below */

#ifndef GO_CGO_EXPORT_PROLOGUE_H
#define GO_CGO_EXPORT_PROLOGUE_H

#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
#endif

#endif

/* Start of preamble from import "C" comments. */


#line 4 "DebugServer.go"


typedef unsigned int* (*GlobalRegistersCallbackType)();
unsigned int* callGlobalRegistersCallback(GlobalRegistersCallbackType callback);
typedef unsigned char* (*MemoryReadCallbackType)(unsigned int address, unsigned int length);
unsigned char* callMemoryReadCallback(MemoryReadCallbackType callback, unsigned int address, unsigned int length);
typedef void (*AddBreakpointCallbackType)(unsigned int address);
void callAddBreakpointCallback(AddBreakpointCallbackType callback, unsigned int address);
typedef void (*ContinueCallbackType)();
void callContinueCallback(ContinueCallbackType callback);
typedef void (*AddLoadWatchpointCallbackType)(unsigned int address);
void callAddLoadWatchpointCallback(AddLoadWatchpointCallbackType callback, unsigned int address);
typedef void (*AddStoreWatchpointCallbackType)(unsigned int address);
void callAddStoreWatchpointCallback(AddStoreWatchpointCallbackType callback, unsigned int address);
typedef void (*RemoveBreakpointCallbackType)(unsigned int address);
void callRemoveBreakpointCallback(RemoveBreakpointCallbackType callback, unsigned int address);
typedef void (*RemoveLoadWatchpointCallbackType)(unsigned int address);
void callRemoveLoadWatchpointCallback(RemoveLoadWatchpointCallbackType callback, unsigned int address);
typedef void (*RemoveStoreWatchpointCallbackType)(unsigned int address);
void callRemoveStoreWatchpointCallback(RemoveStoreWatchpointCallbackType callback, unsigned int address);

#line 1 "cgo-generated-wrapper"


/* End of preamble from import "C" comments. */


/* Start of boilerplate cgo prologue. */
#line 1 "cgo-gcc-export-header-prolog"

#ifndef GO_CGO_PROLOGUE_H
#define GO_CGO_PROLOGUE_H

typedef signed char GoInt8;
typedef unsigned char GoUint8;
typedef short GoInt16;
typedef unsigned short GoUint16;
typedef int GoInt32;
typedef unsigned int GoUint32;
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef GoInt64 GoInt;
typedef GoUint64 GoUint;
typedef __SIZE_TYPE__ GoUintptr;
typedef float GoFloat32;
typedef double GoFloat64;
typedef float _Complex GoComplex64;
typedef double _Complex GoComplex128;

/*
static assertion to make sure the file is being used on architecture
at least with matching size of GoInt.
*/
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];

#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef _GoString_ GoString;
#endif
typedef void *GoMap;
typedef void *GoChan;
typedef struct { void *t; void *v; } GoInterface;
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;

#endif

/* End of boilerplate cgo prologue. */

#ifdef __cplusplus
extern "C" {
#endif


extern void SetGlobalRegistersCallback(GlobalRegistersCallbackType p0);

extern void SetReadMemoryCallback(MemoryReadCallbackType p0);

extern void SetAddBreakpointCallback(AddBreakpointCallbackType p0);

extern void SetContinueCallback(ContinueCallbackType p0);

extern void SetAddLoadWatchpointCallback(AddLoadWatchpointCallbackType p0);

extern void SetAddStoreWatchpointCallback(AddStoreWatchpointCallbackType p0);

extern void SetRemoveBreakpointCallback(RemoveBreakpointCallbackType p0);

extern void SetRemoveLoadWatchpointCallback(RemoveLoadWatchpointCallbackType p0);

extern void SetRemoveStoreWatchpointCallback(RemoveStoreWatchpointCallbackType p0);

extern void NotifyStopped();

extern void StartDebugServer(GoUint p0);

#ifdef __cplusplus
}
#endif
Binary file added hana/libHana.a
Binary file not shown.
16 changes: 16 additions & 0 deletions imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.10.2)
project(imgui)

file(GLOB_RECURSE IMGUI_INCLUDE inlude/*.h)
file(GLOB_RECURSE IMGUI_SOURCES src/*.cpp)

add_subdirectory(glad)

find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})

add_library(imgui ${IMGUI_INCLUDE} ${IMGUI_SOURCES})
add_definitions(-DIMGUI_IMPL_OPENGL_LOADER_GLAD)
target_include_directories(imgui PUBLIC include/)
target_link_libraries(imgui ${SDL2_LIBRARIES})
target_link_libraries(imgui glad)
Loading

0 comments on commit f8ca741

Please sign in to comment.