Replace the MIT license with the GNU General Public License, version 3 (LICENSE), mirroring KintaroModding/uemodmanager. Add NOTICE.md (the copyright line, the section 7 credit/marking/name terms, and the library notices, folding in the former THIRD_PARTY_NOTICES.md), CONTRIBUTING.md and CONTRIBUTORS.md. Update the README license and contributing sections and the build and package file lists.
62 lines
3.2 KiB
Python
62 lines
3.2 KiB
Python
"""Build with this project's portable MSVC; never changes global environment."""
|
|
from pathlib import Path
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
os.chdir(ROOT)
|
|
msvc = max((ROOT/'msvc/VC/Tools/MSVC').iterdir())
|
|
sdk = ROOT/'msvc/Windows Kits/10'
|
|
version = max(p.name for p in (sdk/'Include').iterdir())
|
|
compiler = msvc/'bin/Hostx64/x64'
|
|
env = dict(os.environ)
|
|
env['PATH'] = str(compiler) + os.pathsep + env['PATH']
|
|
env['INCLUDE'] = ';'.join(str(p) for p in [msvc/'include', sdk/'Include'/version/'ucrt',
|
|
sdk/'Include'/version/'shared',sdk/'Include'/version/'um'])
|
|
env['LIB'] = ';'.join(str(p) for p in [msvc/'lib/x64',sdk/'Lib'/version/'ucrt/x64',sdk/'Lib'/version/'um/x64'])
|
|
env['TEMP'] = env['TMP'] = str(ROOT/'build')
|
|
(ROOT/'research').mkdir(exist_ok=True)
|
|
(ROOT/'research/build.log').write_text('',encoding='utf-8')
|
|
|
|
def run(args):
|
|
print('RUN',args[0],flush=True)
|
|
result = subprocess.run([str(a) for a in args], env=env,
|
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
output = result.stdout.decode('utf-8',errors='replace')
|
|
with (ROOT/'research/build.log').open('a',encoding='utf-8') as log: log.write(output)
|
|
print(output, end='', flush=True)
|
|
result.check_returncode()
|
|
|
|
build = ROOT/'build'
|
|
build.mkdir(exist_ok=True)
|
|
vendor = ROOT/'tools/vendor/minhook-1.3.4'
|
|
objects = []
|
|
for source in ['buffer.c','hook.c','trampoline.c','hde/hde64.c']:
|
|
obj = build/(Path(source).stem+'.obj')
|
|
run([compiler/'cl.exe','/nologo','/c','/O2','/MD','/W3',f'/Fo{obj}',vendor/'src'/source])
|
|
objects.append(obj)
|
|
includes = [f'/I{ROOT/"src"}',f'/I{vendor/"include"}',
|
|
f'/external:I{ROOT/"tools/vendor/ue4ss-sdk"}', '/external:W0']
|
|
flags = ['/nologo','/c','/std:c++20','/O2','/MD','/EHsc','/W4','/WX','/permissive-',*includes]
|
|
for source in ['dllmain','compatibility']:
|
|
run([compiler/'cl.exe',*flags,f'/Fo{build/source}.obj',ROOT/'src'/f'{source}.cpp'])
|
|
run([compiler/'lib.exe','/nologo',f'/def:{ROOT/"tools/vendor/ue4ss-sdk/UE4SS.def"}','/machine:x64',f'/out:{build/"UE4SS.lib"}'])
|
|
out = ROOT/'dist/ue4ss/Mods/phantombladezero_scriptcompat/dlls'
|
|
out.mkdir(parents=True,exist_ok=True)
|
|
run([compiler/'link.exe','/nologo','/DLL','/INCREMENTAL:NO','/OPT:REF','/OPT:ICF',
|
|
f'/OUT:{out/"main.dll"}',f'/IMPLIB:{build/"scriptcompat.lib"}',
|
|
build/'dllmain.obj',build/'compatibility.obj',*objects,build/'UE4SS.lib','kernel32.lib','bcrypt.lib'])
|
|
run([compiler/'cl.exe',*flags,'/DCOMPAT_TESTING',f'/Fo{build/"compatibility-test.obj"}',ROOT/'src/compatibility.cpp'])
|
|
run([compiler/'cl.exe',*flags,f'/Fo{build/"native_hooks.obj"}',ROOT/'tests/native_hooks.cpp'])
|
|
run([compiler/'link.exe','/nologo',f'/OUT:{build/"native_hooks.exe"}',
|
|
build/'native_hooks.obj',build/'compatibility-test.obj',*objects,'kernel32.lib','bcrypt.lib'])
|
|
run([build/'native_hooks.exe'])
|
|
(out.parent/'enabled.txt').write_bytes(b'')
|
|
for name in ['README.md','LICENSE','NOTICE.md','CONTRIBUTORS.md']:
|
|
if (ROOT/name).exists():shutil.copyfile(ROOT/name,ROOT/'dist'/name)
|
|
shutil.copyfile(vendor/'LICENSE.txt',ROOT/'dist/MINHOOK-LICENSE.txt')
|
|
shutil.copyfile(ROOT/'tools/vendor/ue4ss-sdk/LICENSE',ROOT/'dist/UE4SS-SDK-LICENSE.txt')
|
|
print('Built experimental DLL; game test still required.')
|