nanobyte-dev / nanobyte_os

OS tutorial from Nanobyte YouTube channel.
The Unlicense
456 stars 69 forks source link

None should be -1 in utility.py FindIndex #25

Open Shadowblitz16 opened 1 year ago

Shadowblitz16 commented 1 year ago

I kept getting

shadowblitz16@Node202-Debian:~/Documents/source/OS/Nano$ scons toolchain
scons: Reading SConscript files ...
TypeError: 'NoneType' object cannot be interpreted as an integer:
  File "/home/shadowblitz16/Documents/source/OS/Nano/SConstruct", line 139:
    SConscript('src/bootloader/stage2/SConscript', variant_dir=variantDir + '/stage2', duplicate=0)
  File "/home/shadowblitz16/.local/lib/python3.9/site-packages/SCons/Script/SConscript.py", line 660:
    return method(*args, **kw)
  File "/home/shadowblitz16/.local/lib/python3.9/site-packages/SCons/Script/SConscript.py", line 597:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/shadowblitz16/.local/lib/python3.9/site-packages/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/shadowblitz16/Documents/source/OS/Nano/src/bootloader/stage2/SConscript", line 26:
    obj_crti = objects.pop(FindIndex(objects, lambda item: IsFileName(item, 'crti.o')))
  File "/usr/lib/python3.9/collections/__init__.py", line 1229:
    return self.data.pop(i)

everywhere because

def FindIndex(the_list, predicate):
    for i in range(len(the_list)):
        if predicate(the_list[i]):
            return i
    return None

should be...

def FindIndex(the_list, predicate):
    for i in range(len(the_list)):
        if predicate(the_list[i]):
            return i
    return -1

in build_scripts/utility.py

chibicitiberiu commented 1 year ago

The problem isn't that it's returning None. The problem is that it can't find crti.o in your object files.

ghost commented 9 months ago

The problem isn't that it's returning None. The problem is that it can't find crti.o in your object files.

You may find the CMake build system a little easier to approach if your looking to keep things simple for your user base. I say this mainly due to some not having any previous Python knowledge to even make proper use of Scons

chibicitiberiu commented 5 months ago

You may find the CMake build system a little easier to approach if your looking to keep things simple for your user base. I say this mainly due to some not having any previous Python knowledge to even make proper use of Scons

I agree with you that SCons might be a bit much for a beginner. But having used CMake before, I don't find it any easier. I think moving away from make was the right decision, the more a project evolves, makefiles tend to get more unmaintainable and harder to understand, and any complex operation (like generating the disk image files) ends up as a shell script.