Compile scripts added.

This commit is contained in:
Curle 2019-07-25 22:07:36 +01:00
parent 440b4998e3
commit 568bb11573
3 changed files with 58 additions and 10 deletions

View File

@ -11,25 +11,21 @@ cd ./x64
rm objects.list
HeaderFiles=-I$CurrentDir/inc/ \
-I$CurrentDir/gnu-efi/inc \
-I$CurrentDir/gnu-efi/inc/x86_64 \
-I$CurrentDir/gnu-efi/inc/protocol \
-I$CurrentDir/gnu-efi/lib
HeaderFiles="-I$CurrentDir/inc/ -I$CurrentDir/gnu-efi/inc -I$CurrentDir/gnu-efi/inc/x86_64 -I$CurrentDir/gnu-efi/inc/protocol -I$CurrentDir/gnu-efi/lib"
set -v
for f in $CurrentDir/src/*.c; do
echo "$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-redzone -DGNU_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -c -MMD -MP -Wa,-adhln="${f%.*}.out" -MF"${f%.*}.d" -MT"${f%.*}.o" -o "${f%.*}.o" "$f"
"$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-redzone -DGNU_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -c -MMD -MP -Wa,-adhln="${f%.*}.out" -MF"${f%.*}.d" -MT"${f%.*}.o" -o "${f%.*}.o" "$f"
echo "$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-red-zone -DGNU_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -c -MMD -MP -Wa,-adhln="${f%.*}.out" -MT"${f%.*}.o" -o "${f%.*}.o" "$f"
"$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-red-zone -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -c -MMD -MP -Wa,-adhln="${f%.*}.out" -MT"${f%.*}.o" -o "${f%.*}.o" "$f"
done
set +v
set -v
while read f; do
echo "$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-red-zone -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFILES -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -c -MMD -MP -Wa,-adhln="${f%.*}.out" -MF"${f%.*}.d" -MT"${f%.*}.o" -o "${f%.*}.o" "$f"
"$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-red-zone -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFILES -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -c -MMD -MP -Wa,-adhln="${f%.*}.out" -MF"${f%.*}.d" -MT"${f%.*}.o" -o "${f%.*}.o" "$f"
echo "$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-red-zone -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -MMD -MP -Wa,-adhln="$CurrentDir${f%.*}.out" -MT"$CurrentDir${f%.*}.o" -o "$CurrentDir${f%.*}.o" -c "$CurrentDir$f"
"$GCC_NAME-gcc" -ffreestanding -fpic -fshort-wchar -fno-stack-protector -fno-stack-check -fno-strict-aliasing -fno-merge-all-constants -m64 -mno-red-zone -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11 $HeaderFiles -Og -g3 -Wall -Wextra -Wdouble-promotion -fmessage-length=0 -MMD -MP -Wa,-adhln="$CurrentDir${f%.*}.out" -MT"$CurrentDir${f%.*}.o" -o "$CurrentDir${f%.*}.o" -c "$CurrentDir$f"
done < $CurrentDir/c_files.txt
set +v
@ -43,8 +39,11 @@ for f in $CurrentDir/src/*.o; do
done
set -v
"$GCC_NAME-ld" -T$Linker -nostdlib --warn-common --no-undefined -znocombreloc -s -shared -Bsymbolic -Map=output.map -o "program.so" @"objects.list"
"ld" -T$Linker -nostdlib --warn-common --no-undefined -znocombreloc -shared -Bsymbolic -Map=output.map -o "program.so" @"objects.list"
set +v
rm image/efi/boot/BOOTx64.efi
objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .rel* -j .reloc --target=efi-app-x86_64 "program.so" "image/efi/boot/BOOTx64.efi"
objcopy --only-keep-debug image/efi/boot/BOOTx64.efi BOOTX64.debug
objcopy --add-gnu-debuglink=BOOTX64.debug image/efi/boot/BOOTx64.efi
read -n 1

View File

@ -1,3 +1,7 @@
src/main.c
src/gfx.c
src/bootloader.c
src/memory.c
gnu-efi/lib/misc.c
gnu-efi/lib/print.c
gnu-efi/lib/smbios.c

45
compile.py Normal file
View File

@ -0,0 +1,45 @@
import os
import subprocess
CurrentPath = os.getcwd()
print(CurrentPath)
# Here goes the absolute path to your x86_64-mingw-w64 folder.
# There should be a \bin\gcc.exe relative to that folder.
GCC_FOLDER = "C:\\Users\Gem\Desktop\comp\mingw64"
if os.path.exists('objects.list'):
os.remove("objects.list")
HeaderFiles="-Iinc/ -Ignu-efi/inc -Ignu-efi/inc/x86_64 -Ignu-efi/inc/protocol -Ignu-efi/lib"
LinkScript = "gnu-efi/gnuefi/elf_x86_64_efi.lds"
OBJECTS = ""
with open('c_files.txt') as file:
line = file.readline().strip()
while line:
line = line[:-2]
print(f'{HeaderFiles}')
if line == "gnu-efi/lib/x86_64/setjmp" or line == "gnu-efi/lib/x86_64/efi_stub":
print(f'Assembling file {line}.s')
subprocess.run([f'{GCC_FOLDER}/bin/as.exe', '-64', '-I/inc/', '-g', '-o', f'{line}.o', f'{line}.s'], shell=True)
else:
print(f'Compiling file {line}.c')
subprocess.run([f'{GCC_FOLDER}/bin/gcc.exe', '-ffreestanding', '-fpic', '-fshort-wchar', '-fno-stack-protector', '-fno-stack-check', '-fno-strict-aliasing', '-fno-merge-all-constants', '-m64', '-mno-red-zone', '-DGNU_EFI_USE_MS_ABI', '-maccumulate-outgoing-args', '--std=c11', '-Iinc/', '-Ignu-efi/inc', '-Ignu-efi/inc/x86_64', '-Ignu-efi/inc/protocol', '-Ignu-efi/lib', '-Og', '-g3', '-Wall', '-Wextra', '-Wdouble-promotion', '-Wpedantic', '-fmessage-length=0', '-c', '-MMD', '-MP', f'-Wa,-adghlmns={line}.out', f'-MT{line}.o', '-o', f'{line}.o', f'{line}.c'], shell=True)
OBJECTS = line + ".o "
os.path.normpath(OBJECTS)
with open('objects.list', 'a') as objectsfile:
ofile = OBJECTS.replace('\\', '/')
objectsfile.write(ofile + "\n")
line = file.readline().strip()
subprocess.run([f'{GCC_FOLDER}/bin/ld.exe', f'-T{LinkScript}', "-nostdlib", "--warn-common", "--no-undefined", "-shared", "--subsystem", '10', "-Bsymbolic", "--gc-sections", "-Map=output.map" , "-o Syncboot.efi", "@objects.list"])
subprocess.run(['objcopy', '-j .text', '-j .sdata', '-j .data', '-j .dynamic', '-j .dynsym', '-j .rel', '-j .rela', '-j .rel.*', '-j .rel*', '-j .reloc', '--target=efi-app-x86_64', 'Syncboot.efi', 'image/efi/boot/BOOTX64.efi'])
subprocess.run(['objcopy', '--only-keep-debug', 'image/efi/boot/BOOTX64.efi', 'BOOTX64.debug'])
subprocess.run(['--add-gnu-debuglink=BOOTX64.debug', 'image/efi/boot/BOOTX64.efi'])