-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
119 lines (103 loc) · 3.04 KB
/
build.py
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
import sys
import os
import ftplib
import glob
import datetime
import shutil
from ftplib import FTP
def allFile(pattern):
s = "";
for file in glob.glob(pattern):
s += file + " ";
return s;
def allFolderFile(pattern, ext):
s = "";
for dirpath, dirnames, filenames in os.walk(pattern):
for filename in [f for f in filenames if f.endswith(ext)]:
s+= os.path.join(dirpath, filename) + ' '
return s;
EUR_TID = "000400000014F200"
USA_TID = "000400000014F100"
JAP_TID = "000400000014F000"
NAME = "SMM_cheats"
FTP_FOLDER = "./plugin/" + EUR_TID + "/"
HOST = "192.168.1.99"
PORT = "5000"
COPYTOPATH = NAME + ".plg"
CC = "arm-none-eabi-gcc"
CP = "arm-none-eabi-g++"
OC = "arm-none-eabi-objcopy"
LD = "arm-none-eabi-ld"
CTRULIB = '../libctru'
DEVKITARM = 'c:/devkitPro/devkitARM'
LIBPATH = '-L ./lib '
ARCH = ' -march=armv6k -mlittle-endian -mtune=mpcore -mfloat-abi=hard '
CFLAGS = ' -Os -c ' + ARCH
ASFLAGS = ' -Os -c -s ' + ARCH
LIBFLAGS = " -lg -lsysbase -lntr -lShark2NTR_dev -lctr -lc -lgcc "
LDFLAGS = ' -pie --gc-sections -T 3ds.ld -Map=' + NAME +'.map '
INCLUDES = " -I Includes -I Sources -I Includes/libntrplg "
CFILES = allFolderFile(".\\Sources\\", ".c")
ASFILES = allFolderFile(".\\Sources\\", ".s")
OFILES = allFolderFile(".\\ofiles\\", ".o")
ftp = FTP()
FILE = COPYTOPATH
def connect(host, port):
ftp.connect(host, port);
def disconnect():
ftp.quit();
def ls():
ftp.dir();
def send(path):
file = open(FILE, 'rb');
ftp.cwd(path);
ftp.storbinary('STOR '+ FILE, file);
file.close();
def printf(string):
print(datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S') + " : " + string);
def run(cmd):
#print(cmd);
return (os.system(cmd));
def error():
print("\n\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
printf("There's some errors on your code.");
printf("Correct them and try again, for now I'm exiting the compilation.\n");
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n");
sys.exit();
cwd = os.getcwd()
print("\n\n");
printf("Hello !\n");
printf("How are you ?\n");
printf("I'm preparing to compile your " + COPYTOPATH + " plugin.\n");
printf("Please just wait a second...\n");
if (os.path.isfile("obj/cheats.o")):
run("rm obj/*.o")
if (os.path.isfile(COPYTOPATH)):
run("rm *.plg")
printf("Compiling C files");
result = run(CC + CFLAGS + INCLUDES + CFILES);
if (result != 0):
error();
printf("Compiling S files");
result = run(CC + ASFLAGS + ASFILES);
if (result != 0):
error();
OFILES += allFile("*.o") + " " + allFile("lib/*.o")
printf("Linking all files into " + COPYTOPATH);
result = run(LD + LDFLAGS + ' ' + LIBPATH + OFILES + LIBFLAGS )
if (result != 0):
error();
if (os.path.isfile("config.o")):
run("cp -r *.o obj/ ")
run("rm *.o")
if (os.path.isfile("a.out")):
run(OC +" -O binary a.out payload.bin -S")
if (os.path.isfile("a.out")):
run("rm *.out")
if (os.path.isfile("payload.bin")):
shutil.copy2("payload.bin", COPYTOPATH);
run("rm payload.bin");
if (os.path.isfile(NAME + ".map")):
run("rm *.map");
printf("Done, enjoy your plugin !\n\n");