Subversion Repositories Kolibri OS

Rev

Rev 9340 | Rev 9387 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9340 Rev 9342
Line 170... Line 170...
170
    thread = Thread(target = run_tests_serially_thread, args = (tests, root_dir))
170
    thread = Thread(target = run_tests_serially_thread, args = (tests, root_dir))
171
    thread.start()
171
    thread.start()
172
    return thread
172
    return thread
Line 173... Line 173...
173
 
173
 
174
def gcc(fin, fout):
174
def gcc(fin, fout):
175
    flags = "-m32 -std=c11 -g -O0 -fno-pie -w" # -masm-intel
175
    flags = "-m32 -std=c11 -g -O0 -fno-pie -w"
176
    defines = "-D_FILE_OFFSET_BITS=64 -DNDEBUG -D_POSIX_C_SOURCE=200809L"
176
    defines = "-D_FILE_OFFSET_BITS=64 -DNDEBUG -D_POSIX_C_SOURCE=200809L"
177
    include = "-Iumka -Iumka/linux"
177
    include = "-Iumka -Iumka/linux"
178
    command = f"clang {flags} {defines} {include} -c {fin} -o {fout}"
178
    command = f"clang {flags} {defines} {include} -c {fin} -o {fout}"
179
    print(command)
179
    print(command)
Line 183... Line 183...
183
    include = "INCLUDE=\"../../programs/develop/libraries/libcrash/hash\""
183
    include = "INCLUDE=\"../../programs/develop/libraries/libcrash/hash\""
184
    flags = "-dUEFI=1 -dextended_primary_loader=1 -dUMKA=1"
184
    flags = "-dUEFI=1 -dextended_primary_loader=1 -dUMKA=1"
185
    files = "umka/umka.asm umka/build/umka.o -s umka/build/umka.fas"
185
    files = "umka/umka.asm umka/build/umka.o -s umka/build/umka.fas"
186
    memory = "-m 2000000"
186
    memory = "-m 2000000"
187
    command = f"{include} fasm {flags} {files} {memory}"
187
    command = f"{include} fasm {flags} {files} {memory}"
-
 
188
    if sys.platform != "win32":
188
    print(command)
189
        print(command)
189
    os.system(command)
190
        os.system(command)
-
 
191
    else:
-
 
192
        my_env = os.environ.copy()
-
 
193
        my_env["INCLUDE"] = "../../programs/develop/libraries/libcrash/hash"
-
 
194
        print(subprocess.check_output(f"fasm {flags} {files} {memory} -dwin32=1", shell = True, env = my_env))
Line 190... Line 195...
190
 
195
 
191
def build_umka():
196
def build_umka():
192
    if not enable_umka:
197
    if not enable_umka:
193
        return
198
        return
194
    if os.path.exists("umka_shell.exe"):
199
    if os.path.exists("umka_shell.exe"):
195
        return
200
        return
-
 
201
    os.makedirs("umka/build/linux", exist_ok = True)
196
    os.makedirs("umka/build/linux", exist_ok = True)
202
    os.makedirs("umka/build/win32", exist_ok = True)
197
    sources = [ "umka_shell.c", 
203
    sources = [ "umka_shell.c", 
198
                "shell.c",
204
                "shell.c",
199
                "vdisk.c",
205
                "vdisk.c",
200
                "lodepng.c",
206
                "lodepng.c",
-
 
207
                "getopt.c" ]
-
 
208
    if sys.platform == "win32":
-
 
209
        sources += [ "win32/pci.c", "win32/thread.c" ]
201
                "linux/pci.c",
210
    else:
202
                "linux/thread.c" ]
211
        sources += [ "linux/pci.c", "linux/thread.c" ]
203
    sources = [f"umka/{f}" for f in sources]
212
    sources = [f"umka/{f}" for f in sources]
204
    objects = []
213
    objects = []
205
    for source in sources:
214
    for source in sources:
206
        object_path = source.replace("umka/", "umka/build/")
215
        object_path = source.replace("umka/", "umka/build/")
207
        object_path = f"{object_path}.o"
216
        object_path = f"{object_path}.o"
208
        gcc(source, object_path)
217
        gcc(source, object_path)
209
        objects.append(object_path)
218
        objects.append(object_path)
210
    build_umka_asm()
219
    build_umka_asm()
211
    objects.append("umka/build/umka.o")
220
    objects.append("umka/build/umka.o")
-
 
221
    objects = " ".join(objects)
-
 
222
    if sys.platform != "win32":
-
 
223
        ld_script = "-T umka/umka.ld"
-
 
224
    else:
212
    objects = " ".join(objects)
225
        ld_script = ""
213
    command = f"gcc -m32 -no-pie -o umka_shell.exe -static -T umka/umka.ld {objects}"
226
    command = f"clang -m32 -fno-pie -o umka_shell.exe -static {ld_script} {objects}"
214
    print(command)
227
    print(command)
-
 
228
    os.system(command)
-
 
229
    if not os.path.exists("umka_shell.exe"):
-
 
230
        print("Could't compile umka_shell.exe")
Line 215... Line 231...
215
    os.system(command)
231
        exit()
216
 
232
 
217
def create_relocated(root_dir, fname):
233
def create_relocated(root_dir, fname):
218
    with open(fname, "rb") as f:
234
    with open(fname, "rb") as f:
Line 225... Line 241...
225
    return outname
241
    return outname
Line 226... Line 242...
226
 
242
 
227
def run_umka_test(root_dir, test_file_path):
243
def run_umka_test(root_dir, test_file_path):
228
    test = create_relocated(root_dir, test_file_path)
244
    test = create_relocated(root_dir, test_file_path)
229
    ref_log = create_relocated(root_dir, f"{test_file_path[:-2]}.ref.log")
245
    ref_log = create_relocated(root_dir, f"{test_file_path[:-2]}.ref.log")
-
 
246
    out_log = f"{test_file_path[:-2]}.out.log"
-
 
247
    if sys.platform != "win32":
-
 
248
        prefix = "./"
-
 
249
    else:
230
    out_log = f"{test_file_path[:-2]}.out.log.o"
250
        prefix = ""
-
 
251
    os.system(f"{prefix}umka_shell.exe < {test} > {out_log}")
-
 
252
    if sys.platform == "win32":
-
 
253
        with open(out_log, "rb") as f:
-
 
254
            contents = f.read()
-
 
255
        contents_no_crlf = contents.replace(b"\r\n", b"\n")
-
 
256
        with open(out_log, "wb") as f:
231
    os.system(f"./umka_shell.exe < {test} > {out_log}")
257
            f.write(contents_no_crlf)
232
    if not filecmp.cmp(ref_log, out_log):
258
    if not filecmp.cmp(ref_log, out_log):
233
        print(f"FAILURE: {test_file_path}\n", end = "")
259
        print(f"FAILURE: {test_file_path}\n", end = "")
234
    else:
260
    else: