Skip to content

Commit

Permalink
Setup AMBuild (#2)
Browse files Browse the repository at this point in the history
* Setup AMBuild

* remove amalgamated

---------

Co-authored-by: Kenzzer <[email protected]>
  • Loading branch information
Kenzzer and Kenzzer authored May 23, 2024
1 parent 849712d commit 1f31c51
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 2,941 deletions.
25 changes: 25 additions & 0 deletions AMBuildScript
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class SafetyHook(object):
def __init__(self):
self.all_targets = []
self.libsafetyhook = {}
def configure(self):
target_archs = []
if builder.options.targets:
target_archs = builder.options.targets.split(',')
else:
target_archs = ['x86', 'x86_64']

for arch in target_archs:
try:
cxx = builder.DetectCxx(target_arch = arch)
except Exception as e:
if builder.options.targets:
raise
print('Skipping target {}: {}'.format(arch, e))
continue
self.all_targets.append(cxx)

SH = SafetyHook()
SH.configure()

builder.Build('AMBuilder', {'SafetyHook': SH })
64 changes: 64 additions & 0 deletions AMBuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import os

def AddSourceFilesFromDir(path, files):
list = []
for file in files:
list.append(os.path.join(path, file))
return list

libsafetyhook = builder.StaticLibraryProject('libsafetyhook')
# SafetyHook sourcefiles
libsafetyhook.sources = AddSourceFilesFromDir(os.path.join(builder.currentSourcePath, 'src'),[
"allocator.cpp",
"easy.cpp",
"inline_hook.cpp",
"mid_hook.cpp",
"utility.cpp",
"vmt_hook.cpp",
])
# Safetyhook dependency Zydis
libsafetyhook.sources += AddSourceFilesFromDir(os.path.join(builder.currentSourcePath, 'zydis'),[
"Zydis.c"
])

for compiler in SafetyHook.all_targets:
binary = libsafetyhook.Configure(compiler, libsafetyhook.name, 'Release - {0}'.format(compiler.target.arch))
# Configure the binary's compiler
compiler = binary.compiler
# Reset all flags, safetyhook requires specific compilation flags
compiler.cxxflags = []
compiler.cflags = []
compiler.defines = []
compiler.includes = []
compiler.cxxincludes = []

if compiler.target.platform == 'windows':
compiler.cflags += [
"/W4",
]
compiler.cxxflags += [
"/EHsc",
"/permissive-",
"/w14640",
"/std:c++17"
]
binary.sources += [ os.path.join(builder.currentSourcePath, 'src', 'os.windows.cpp') ]
elif compiler.target.platform == 'linux':
compiler.cflags += [
"-Werror",
"-Wall",
"-Wextra",
"-pedantic",
"-Wshadow",
"-Wno-unused-const-variable",
"-Wno-unused-function"
]
compiler.cxxflags += [
"-Wnon-virtual-dtor",
"-std=c++17"
]
binary.sources += [ os.path.join(builder.currentSourcePath, 'src', 'os.linux.cpp') ]
compiler.includes += [os.path.join(builder.currentSourcePath, 'include'), os.path.join(builder.currentSourcePath, 'zydis')]

# Send back the binaries
SafetyHook.libsafetyhook = builder.Add(libsafetyhook)
Loading

0 comments on commit 1f31c51

Please sign in to comment.