|
1 | 1 | SETLOCAL EnableDelayedExpansion
|
2 | 2 |
|
3 |
| -REM Libraries to link in |
4 |
| -SET libraries=-lc -lkernel |
| 3 | +SET TOOLCHAIN=%OO_PS4_TOOLCHAIN% |
5 | 4 |
|
6 |
| -REM Read the script arguments into local vars |
7 |
| -SET intdir=%1 |
8 |
| -SET targetname=%~2 |
9 |
| -SET outputPath=%~3 |
| 5 | +SET LIBS=-lc -lkernel |
10 | 6 |
|
11 |
| -SET outputElf=%intdir%%targetname%.elf |
12 |
| -SET outputOelf=%intdir%%targetname%.oelf |
13 |
| -SET outputPrx=%intdir%%targetname%.prx |
14 |
| -SET outputStub=%intdir%%targetname%_stub.so |
| 7 | +REM Compiler options. You likely won't need to touch these. |
| 8 | +SET CC=clang |
| 9 | +SET CXX=clang++ |
| 10 | +SET LD=ld.lld |
| 11 | + |
| 12 | +SET TARGET=%~2 |
| 13 | + |
| 14 | +SET ODIR=%1 |
| 15 | +SET SDIR=%~3 |
| 16 | + |
| 17 | +REM Trim trailing \'s |
| 18 | +IF %TOOLCHAIN:~-1%==\ SET TOOLCHAIN=%TOOLCHAIN:~0,-1% |
| 19 | +IF %ODIR:~-1%==\ SET ODIR=%ODIR:~0,-1% |
| 20 | +IF %SDIR:~-1%==\ SET SDIR=%SDIR:~0,-1% |
| 21 | + |
| 22 | +SET IDIRS="-I%TOOLCHAIN%\include" |
| 23 | +SET LDIRS="-L%TOOLCHAIN%\lib" |
| 24 | + |
| 25 | +SET CFLAGS=-cc1 -triple x86_64-scei-ps4-elf -munwind-tables %IDIRS% -emit-obj |
| 26 | +SET CXXFLAGS=%CFLAGS% |
| 27 | +SET LFLAGS=-m elf_x86_64 -pie --version-script="%SDIR%\%TARGET%.version" --script "%TOOLCHAIN%\link.x" --eh-frame-hdr %LDIRS% %LIBS% --verbose "%TOOLCHAIN%\lib\crtlib.o" |
| 28 | + |
| 29 | +SET STUBCFLAGS=-target x86_64-pc-linux-gnu -ffreestanding -nostdlib -fno-builtin -fPIC -c %IDIRS% |
| 30 | +SET STUBCXXFLAGS=%STUBCFLAGS% |
| 31 | +SET STUBLFLAGS=-target x86_64-pc-linux-gnu -shared -fuse-ld=lld -ffreestanding -nostdlib -fno-builtin %LDIRS% %LIBS% |
| 32 | + |
| 33 | +REM Make! |
15 | 34 |
|
16 |
| -REM Compile object files for all the source files |
17 | 35 | FOR %%f in (..\*.c) DO (
|
18 | 36 | ECHO Compiling %%~f...
|
19 |
| - clang -cc1 -triple x86_64-scei-ps4-elf -munwind-tables -I"%OO_PS4_TOOLCHAIN%\include" -emit-obj -o %intdir%\%%~nf.o "%%~f" |
| 37 | + %CC% %CFLAGS% -o %ODIR%\%%~nf.o "%%~f" |
20 | 38 | )
|
21 | 39 | FOR %%f in (..\*.cpp) DO (
|
22 | 40 | ECHO Compiling %%~f...
|
23 |
| - clang++ -cc1 -triple x86_64-scei-ps4-elf -munwind-tables -I"%OO_PS4_TOOLCHAIN%\include" -emit-obj -o %intdir%\%%~nf.o "%%~f" |
| 41 | + %CXX% %CXXFLAGS% -o %ODIR%\%%~nf.o "%%~f" |
24 | 42 | )
|
25 | 43 |
|
26 | 44 | REM Get a list of object files for linking
|
27 |
| -SET obj_files= |
28 |
| -FOR %%f IN (%intdir%\\*.o) DO SET obj_files=!obj_files! .\%%f |
| 45 | +SET OBJS= |
| 46 | +FOR %%f IN (%ODIR%\*.o) DO SET OBJS=!OBJS! %%f |
29 | 47 |
|
30 | 48 | REM Link the input ELF
|
31 | 49 | ECHO Linking...
|
32 |
| -ld.lld -m elf_x86_64 -pie --version-script="%targetname%.version" --script "%OO_PS4_TOOLCHAIN%\link.x" --eh-frame-hdr -o "%outputElf%" "-L%OO_PS4_TOOLCHAIN%\lib" -lc -lkernel --verbose "%OO_PS4_TOOLCHAIN%\lib\crtlib.o" %obj_files% |
| 50 | +%LD% %OBJS% -o "%ODIR%\%TARGET%.elf" %LFLAGS% |
33 | 51 |
|
34 | 52 | REM Create stub shared libraries
|
35 | 53 | FOR %%f in (..\*.c) DO (
|
36 |
| - clang -target x86_64-pc-linux-gnu -ffreestanding -nostdlib -fno-builtin -fPIC -c -I"%OO_PS4_TOOLCHAIN%\include" -o %intdir%\%%~nf.o.stub "%%~f" |
| 54 | + %CC% %STUBCFLAGS% -o %ODIR%\%%~nf.o.stub "%%~f" |
37 | 55 | )
|
38 | 56 | FOR %%f in (..\*.cpp) DO (
|
39 |
| - clang++ -target x86_64-pc-linux-gnu -ffreestanding -nostdlib -fno-builtin -fPIC -c -I"%OO_PS4_TOOLCHAIN%\include" -o %intdir%\%%~nf.o.stub "%%~f" |
| 57 | + %CXX% %STUBCXXFLAGS% -o %ODIR%\%%~nf.o.stub "%%~f" |
40 | 58 | )
|
41 | 59 |
|
42 |
| -SET stub_obj_files= |
43 |
| -FOR %%f in (%intdir%\\*.o.stub) DO SET stub_obj_files=!stub_obj_files! .\%%f |
| 60 | +SET STUBOBJS= |
| 61 | +FOR %%f in (%ODIR%\*.o.stub) DO SET STUBOBJS=!STUBOBJS! .\%%f |
44 | 62 |
|
45 |
| -clang++ -target x86_64-pc-linux-gnu -shared -fuse-ld=lld -ffreestanding -nostdlib -fno-builtin "-L%OO_PS4_TOOLCHAIN%\lib" %libraries% %stub_obj_files% -o "%outputStub%" |
| 63 | +%CC% %STUBOBJS% -o "%ODIR%\%TARGET%_stub.so" %STUBLFLAGS% |
46 | 64 |
|
47 | 65 | REM Create the prx
|
48 |
| -%OO_PS4_TOOLCHAIN%\bin\windows\create-lib.exe -in "%outputElf%" --out "%outputOelf%" --paid 0x3800000000000011 |
| 66 | +ECHO Creating OELF/PRX... |
| 67 | +%TOOLCHAIN%\bin\windows\create-lib.exe -in "%ODIR%\%TARGET%.elf" -out "%ODIR%\%TARGET%.oelf" |
49 | 68 |
|
50 | 69 | REM Cleanup
|
51 |
| -COPY "%outputPrx%" "%outputPath%\%targetname%.prx" |
52 |
| -DEL "%outputPrx%" |
| 70 | +COPY "%ODIR%\%TARGET%.prx" "%SDIR%\%TARGET%.prx" |
| 71 | +DEL "%ODIR%\%TARGET%.prx" |
0 commit comments