- moved "tests" to its own folder

- remove the src/theo folder contents just into src
- added some cmkr shit so that tests only build on windows
- added compile options for mcmodel=large in the demolibs
- changed how we get a ptr to the element from an interator
master
IDontCode 3 years ago
parent 1adcbab0b9
commit f1f808081b

@ -39,14 +39,14 @@ endif()
add_subdirectory(dependencies)
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})
# src
# tests
set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER})
if(CMAKE_FOLDER)
set(CMAKE_FOLDER "${CMAKE_FOLDER}/src")
set(CMAKE_FOLDER "${CMAKE_FOLDER}/tests")
else()
set(CMAKE_FOLDER src)
set(CMAKE_FOLDER tests)
endif()
add_subdirectory(src)
add_subdirectory(tests)
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})
# Target Theodosius
@ -74,16 +74,16 @@ list(APPEND Theodosius_SOURCES
"include/recomp/reloc.hpp"
"include/recomp/symbol_table.hpp"
"include/theo.hpp"
"src/theo/decomp/decomp.cpp"
"src/theo/decomp/routine.cpp"
"src/theo/decomp/symbol.cpp"
"src/theo/obf/engine.cpp"
"src/theo/obf/passes/jcc_rewrite_pass.cpp"
"src/theo/obf/passes/next_inst_pass.cpp"
"src/theo/obf/passes/reloc_transform_pass.cpp"
"src/theo/recomp/recomp.cpp"
"src/theo/recomp/symbol_table.cpp"
"src/theo/theo.cpp"
"src/decomp/decomp.cpp"
"src/decomp/routine.cpp"
"src/decomp/symbol.cpp"
"src/obf/engine.cpp"
"src/obf/passes/jcc_rewrite_pass.cpp"
"src/obf/passes/next_inst_pass.cpp"
"src/obf/passes/reloc_transform_pass.cpp"
"src/recomp/recomp.cpp"
"src/recomp/symbol_table.cpp"
"src/theo.cpp"
)
list(APPEND Theodosius_SOURCES

@ -2,11 +2,11 @@
name = "Theodosius"
[subdir.dependencies]
[subdir.src]
[subdir.tests]
[target.Theodosius]
type = "static"
sources = ["include/**.hpp", "src/theo/**.cpp"]
sources = ["include/**.hpp", "src/**.cpp"]
include-directories = ["include"]
compile-features = ["cxx_std_20"]

@ -3,6 +3,8 @@
#include <functional>
#include <map>
#include <random>
#include <bit>
#include <bitset>
#define XED_ENCODER
extern "C" {

@ -6,7 +6,7 @@ class rol_op_t : public operation_t {
explicit rol_op_t()
: operation_t(
[&](std::size_t val, std::uint32_t imm) -> std::size_t {
return _rotl64(val, (std::uint8_t)imm);
return std::rotl(val, (std::uint8_t)imm);
},
XED_ICLASS_ROL) {}

@ -6,7 +6,7 @@ class ror_op_t : public operation_t {
explicit ror_op_t()
: operation_t(
[&](std::size_t val, std::uint32_t imm) -> std::size_t {
return _rotr64(val, (std::uint8_t)imm);
return std::rotr(val, (std::uint8_t)imm);
},
XED_ICLASS_ROR) {}

@ -1,18 +0,0 @@
# This file is automatically generated from cmake.toml - DO NOT EDIT
# See https://github.com/build-cpp/cmkr for more information
# Create a configure-time dependency on cmake.toml to improve IDE support
if(CMKR_ROOT_PROJECT)
configure_file(cmake.toml cmake.toml COPYONLY)
endif()
# tests
set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER})
if(CMAKE_FOLDER)
set(CMAKE_FOLDER "${CMAKE_FOLDER}/tests")
else()
set(CMAKE_FOLDER tests)
endif()
add_subdirectory(tests)
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})

@ -1 +0,0 @@
[subdir.tests]

@ -67,7 +67,7 @@ std::optional<recomp::reloc_t*> next_inst_pass_t::has_next_inst_reloc(
sym->relocs().begin(), sym->relocs().end(),
[&](recomp::reloc_t& reloc) -> bool { return !reloc.offset(); });
return res != sym->relocs().end() ? res._Ptr
return res != sym->relocs().end() ? &(*res)
: std::optional<recomp::reloc_t*>();
}
} // namespace theo::obf

@ -41,7 +41,7 @@ std::optional<recomp::reloc_t*> reloc_transform_pass_t::has_legit_reloc(
sym->relocs().begin(), sym->relocs().end(),
[&](recomp::reloc_t& reloc) -> bool { return reloc.offset(); });
return res != sym->relocs().end() ? res._Ptr
return res != sym->relocs().end() ? &(*res)
: std::optional<recomp::reloc_t*>();
}
} // namespace theo::obf

@ -1,7 +0,0 @@
[project]
name = "demolib"
[target.demolib]
type = "static"
sources = ["*.cpp"]

@ -1,7 +0,0 @@
[project]
name = "demolib2"
[target.demolib2]
type = "static"
sources = ["*.cpp"]

@ -30,36 +30,38 @@ endif()
project(demo)
# Target demo
set(CMKR_TARGET demo)
set(demo_SOURCES "")
if(WIN32) # windows
set(CMKR_TARGET demo)
set(demo_SOURCES "")
list(APPEND demo_SOURCES
list(APPEND demo_SOURCES
main.cpp
)
)
list(APPEND demo_SOURCES
list(APPEND demo_SOURCES
cmake.toml
)
)
set(CMKR_SOURCES ${demo_SOURCES})
add_executable(demo)
set(CMKR_SOURCES ${demo_SOURCES})
add_executable(demo)
if(demo_SOURCES)
if(demo_SOURCES)
target_sources(demo PRIVATE ${demo_SOURCES})
endif()
endif()
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT demo)
endif()
endif()
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${demo_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${demo_SOURCES})
target_link_libraries(demo PRIVATE
target_link_libraries(demo PRIVATE
Theodosius
spdlog
)
)
unset(CMKR_TARGET)
unset(CMKR_SOURCES)
unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()

@ -2,7 +2,7 @@
name = "demo"
[target.demo]
condition = "windows"
type = "executable"
sources = ["*.cpp"]
link-libraries = ["Theodosius", "spdlog"]

@ -30,26 +30,32 @@ endif()
project(demolib)
# Target demolib
set(CMKR_TARGET demolib)
set(demolib_SOURCES "")
if(WIN32) # windows
set(CMKR_TARGET demolib)
set(demolib_SOURCES "")
list(APPEND demolib_SOURCES
list(APPEND demolib_SOURCES
main.cpp
)
)
list(APPEND demolib_SOURCES
list(APPEND demolib_SOURCES
cmake.toml
)
)
set(CMKR_SOURCES ${demolib_SOURCES})
add_library(demolib STATIC)
set(CMKR_SOURCES ${demolib_SOURCES})
add_library(demolib STATIC)
if(demolib_SOURCES)
if(demolib_SOURCES)
target_sources(demolib PRIVATE ${demolib_SOURCES})
endif()
endif()
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${demolib_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${demolib_SOURCES})
unset(CMKR_TARGET)
unset(CMKR_SOURCES)
target_compile_options(demolib PUBLIC
"-Xclang -mcmodel=large"
)
unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()

@ -0,0 +1,8 @@
[project]
name = "demolib"
[target.demolib]
condition = "windows"
type = "static"
sources = ["*.cpp"]
compile-options = ["-Xclang -mcmodel=large"]

@ -30,27 +30,33 @@ endif()
project(demolib2)
# Target demolib2
set(CMKR_TARGET demolib2)
set(demolib2_SOURCES "")
if(WIN32) # windows
set(CMKR_TARGET demolib2)
set(demolib2_SOURCES "")
list(APPEND demolib2_SOURCES
list(APPEND demolib2_SOURCES
obj1.cpp
obj2.cpp
)
)
list(APPEND demolib2_SOURCES
list(APPEND demolib2_SOURCES
cmake.toml
)
)
set(CMKR_SOURCES ${demolib2_SOURCES})
add_library(demolib2 STATIC)
set(CMKR_SOURCES ${demolib2_SOURCES})
add_library(demolib2 STATIC)
if(demolib2_SOURCES)
if(demolib2_SOURCES)
target_sources(demolib2 PRIVATE ${demolib2_SOURCES})
endif()
endif()
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${demolib2_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${demolib2_SOURCES})
unset(CMKR_TARGET)
unset(CMKR_SOURCES)
target_compile_options(demolib2 PUBLIC
"-Xclang -mcmodel=large"
)
unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()

@ -0,0 +1,8 @@
[project]
name = "demolib2"
[target.demolib2]
condition = "windows"
type = "static"
sources = ["*.cpp"]
compile-options = ["-Xclang -mcmodel=large"]
Loading…
Cancel
Save