forked from pinumbernumber/SetGPU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
119 lines (83 loc) · 3.02 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#! /bin/bash
set -e
# Set architecture as env var e.g.
# BUILDCPU=X64 ./build.sh
# Need bash and related tools (e.g. Git Bash provides this), MinGW, and PHP(!) in your PATH
############################################
# echo Generating definitions...
# node gen_decs.js
# echo Generated.
# echo Compiling+Linking...
if [ -z $NOWIPEBIN ]
then
rm -rf bin
else
echo "Not wiping"
fi
mkdir -p bin/dx11/x64
mkdir -p bin/dxgi/x64
mkdir -p bin/setgpu/x64
mkdir -p bin/dx11/x32
mkdir -p bin/dxgi/x32
mkdir -p bin/setgpu/x32
if [ $BUILDCPU = "X64" ]
then
GCC='gcc'
CPUFLAGS='-DCPU64 -m64'
X32_or_X64=x64
WINDRESFLAGS='--target=pe-x86-64'
elif [ $BUILDCPU = "X32" ]
then
#-Wl,--kill-at --no-leading-underscore
GCC='C:\mingw\mingw32\bin\gcc.exe'
# GCC='tcc -I"C:/Code/winapi-full-for-0.9.27/include" -I"C:/Code/winapi-full-for-0.9.27/include/winapi"'
CPUFLAGS='-DCPU32 -m32'
X32_or_X64=x32
WINDRESFLAGS='--target=pe-i386'
else
echo "Error: Specify CPU"
exit 1
fi
# rm -rf bin/dx11/${X32_or_X64}/*.dll
# rm -rf bin/dx11/${X32_or_X64}/*.dll
# rm -rf _obj/dx11/${X32_or_X64}/*
CFLAGS="-Wall -g ${CPUFLAGS} -Isrc -Isrc/common -Isrc/setgpu/include"
# -fPIC
# rm -f bin/dx11/${X32_or_X64}/setgpu.dll
rm -f src/setgpu/gui/_generated/SetGPU_Resources.o
windres ${WINDRESFLAGS} src/setgpu/gui/SetGPU_Resources.rc src/setgpu/gui/_generated/SetGPU_Resources.o
${GCC} ${CFLAGS} -Isrc/setgpu -DSETGPU_BUILDING_DLL -shared \
-o bin/setgpu/${X32_or_X64}/setgpu.dll \
src/setgpu/setgpu.c src/setgpu/gui/gui.c src/setgpu/gui/_generated/SetGPU_Resources.o
# cp bin/setgpu/${X32_or_X64}/setgpu.dll bin/dx11/${X32_or_X64}/setgpu.dll
echo Built setgpu.dll
SETGPULFLAGS="-Lbin/setgpu/${X32_or_X64}/ -lsetgpu"
### DX11 ###
rm -f src/dx11/_generated/_d3d11_proxy.S
REAL_DLL_FIXED_PATH=C:\\\\Windows\\\\System32\\\\d3d11.dll \
FAKE_FUNCS=D3D11CreateDevice,D3D11CreateDeviceAndSwapChain \
PATH_TO_DEF=`realpath src/dx11/d3d11.def` \
php src/common/dll_proxy_template.php.S > src/dx11/_generated/_d3d11_proxy.S
${GCC} ${CFLAGS} -Isrc/dx11 -shared ${SETGPULFLAGS} \
-o bin/dx11/${X32_or_X64}/d3d11.dll \
src/dx11/_generated/_d3d11_proxy.S \
src/dx11/dx11.c \
src/dx11/d3d11.def \
-ldxgi
rm -f src/dx11/_generated/_dxgi_proxy.S
# CreateDXGIFactory,CreateDXGIFactory1,CreateDXGIFactory2
REAL_DLL_FIXED_PATH=C:\\\\Windows\\\\System32\\\\dxgi.dll \
FAKE_FUNCS=CreateDXGIFactory,CreateDXGIFactory1,CreateDXGIFactory2 \
PATH_TO_DEF=`realpath src/dxgi/dxgi.def` \
php src/common/dll_proxy_template.php.S > src/dxgi/_generated/_dxgi_proxy.S
echo generated dxgi
${GCC} ${CFLAGS} -Isrc/dxgi -shared ${SETGPULFLAGS} \
-o bin/dxgi/${X32_or_X64}/dxgi.dll \
src/dxgi/_generated/_dxgi_proxy.S \
src/dxgi/dxgi_basic.c \
src/dxgi/dxgi.def
echo Built
# cp bin/dx11/${X32_or_X64}/d3d11.dll "D:\do_not_backup\SteamLibrary\steamapps\common\Dishonored2\d3d11.dll"
# cp bin/dx11/${X32_or_X64}/dxgi.dll "D:\do_not_backup\SteamLibrary\steamapps\common\Dishonored2\dxgi.dll"
# cp bin/dx11/${X32_or_X64}/setgpu.dll "D:\do_not_backup\SteamLibrary\steamapps\common\Dishonored2\setgpu.dll"
### END DX11 ###