SConscript 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import os
  2. import sys
  3. from building import *
  4. cwd = GetCurrentDir()
  5. # Import usrapp build module and build support
  6. sys.path.append(os.path.join(cwd, '../../tools'))
  7. from build_usrapp import build_example_usrapp
  8. from build_support import clean_rust_build
  9. def _has(sym: str) -> bool:
  10. try:
  11. return bool(GetDepend([sym]))
  12. except Exception:
  13. return bool(GetDepend(sym))
  14. def load_extended_feature_configs():
  15. """
  16. Load extended feature configurations if available.
  17. This allows users to add custom configuration mappings.
  18. """
  19. try:
  20. from feature_config_examples import setup_all_example_features
  21. setup_all_example_features()
  22. print("Extended feature configurations loaded successfully.")
  23. except ImportError:
  24. print("Using default feature configurations.")
  25. group = []
  26. if not _has('RT_RUST_BUILD_APPLICATIONS'):
  27. Return('group')
  28. # Load extended feature configurations
  29. load_extended_feature_configs()
  30. src = []
  31. LIBS = []
  32. LIBPATH = []
  33. LINKFLAGS = ""
  34. if GetOption('clean'):
  35. app_build_dir = clean_rust_build(Dir('#').abspath, "example_usrapp")
  36. if os.path.exists(app_build_dir):
  37. print(f'Registering {app_build_dir} for cleanup')
  38. Clean('.', app_build_dir)
  39. else:
  40. print('No example_usrapp build artifacts to clean')
  41. else:
  42. import rtconfig
  43. LIBS, LIBPATH, LINKFLAGS = build_example_usrapp(
  44. cwd=cwd,
  45. has_func=_has,
  46. rtconfig=rtconfig,
  47. build_root=os.path.join(Dir('#').abspath, "build", "example_usrapp")
  48. )
  49. group = DefineGroup(
  50. 'example_usrapp',
  51. src,
  52. depend=['RT_USING_RUST'],
  53. LIBS=LIBS,
  54. LIBPATH=LIBPATH,
  55. LINKFLAGS=LINKFLAGS
  56. )
  57. Return('group')