SConscript 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import os
  2. import rtconfig
  3. import subprocess
  4. from building import *
  5. group = []
  6. cwd = GetCurrentDir()
  7. CPPPATH = [cwd, cwd + "/kernel"]
  8. list = os.listdir(cwd)
  9. src = Glob('kernel/*.c') + Glob('kernel/*.S')
  10. if not GetDepend(['RT_USING_VDSO']):
  11. Return('group')
  12. if rtconfig.ARCH != "aarch64" and rtconfig.ARCH != "risc-v":
  13. # not supported arch
  14. src = []
  15. else:
  16. if not hasattr(rtconfig, 'CPP') or rtconfig.CPP is None:
  17. rtconfig.CPP = rtconfig.PREFIX + 'cpp'
  18. if not hasattr(rtconfig, 'CPPFLAGS') or rtconfig.CPPFLAGS is None:
  19. rtconfig.CPPFLAGS = ' -E -P -x assembler-with-cpp'
  20. if not os.path.exists(cwd + "/user" + "/arch" +"/" + rtconfig.ARCH + "/vdso.lds"):
  21. Preprocessing("user/arch/" + rtconfig.ARCH + "/vdso.lds.S", ".lds", CPPPATH=[cwd])
  22. vdso_arch = os.path.join(cwd, 'user',"arch", rtconfig.ARCH)
  23. process_env = os.environ.copy()
  24. if hasattr(rtconfig, 'EXEC_PATH') and rtconfig.EXEC_PATH is not None:
  25. process_env['RTT_EXEC_PATH'] = rtconfig.EXEC_PATH
  26. if hasattr(rtconfig, 'PREFIX') and rtconfig.PREFIX is not None:
  27. process_env['RTT_CC_PREFIX'] = rtconfig.PREFIX
  28. if hasattr(rtconfig, 'DEVICE') and rtconfig.DEVICE is not None:
  29. process_env['RTT_DEVICE'] = rtconfig.DEVICE
  30. command = ["scons", "-C", vdso_arch]
  31. clean_command = ["scons", "-C", vdso_arch, "--clean"]
  32. if not GetOption('clean'):
  33. result = subprocess.run(command, env=process_env, check=True)
  34. else:
  35. result = subprocess.run(clean_command, env=process_env, check=True)
  36. if result.returncode == 0:
  37. print("Command executed successfully")
  38. else:
  39. print("Command failed with exit code:", result.returncode)
  40. exit(1)
  41. group = DefineGroup('vDSO', src, depend = ['RT_USING_SMART','RT_USING_VDSO'], CPPPATH = CPPPATH)
  42. Return('group')