SConscript 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import os
  2. import sys
  3. from building import *
  4. cwd = GetCurrentDir()
  5. # Import component build module and build support
  6. sys.path.append(os.path.join(cwd, '../../tools'))
  7. from build_component import build_example_component
  8. from build_support import clean_rust_build
  9. # Load feature configurations
  10. try:
  11. from feature_config_component import setup_all_component_features
  12. setup_all_component_features()
  13. except ImportError:
  14. print("Warning: Could not load component feature configurations")
  15. def _has(sym: str) -> bool:
  16. """Helper function to check if a configuration symbol is enabled."""
  17. try:
  18. return bool(GetDepend([sym]))
  19. except Exception:
  20. return bool(GetDepend(sym))
  21. # Early return if Rust or log component is not enabled
  22. if not _has('RT_USING_RUST'):
  23. group = []
  24. Return('group')
  25. if not _has('RUST_LOG_COMPONENT'):
  26. group = []
  27. Return('group')
  28. # Source files – component glue code if needed
  29. src = []
  30. LIBS = []
  31. LIBPATH = []
  32. LINKFLAGS = ""
  33. # Handle clean operation
  34. if GetOption('clean'):
  35. comp_build_dir = clean_rust_build(Dir('#').abspath, "example_component")
  36. if os.path.exists(comp_build_dir):
  37. print(f'Registering {comp_build_dir} for cleanup')
  38. Clean('.', comp_build_dir)
  39. else:
  40. print('No example_component build artifacts to clean')
  41. else:
  42. # Build the component using the extracted build module
  43. import rtconfig
  44. LIBS, LIBPATH, LINKFLAGS = build_example_component(
  45. cwd=cwd,
  46. has_func=_has,
  47. rtconfig=rtconfig,
  48. build_root=os.path.join(Dir('#').abspath, "build", "example_component")
  49. )
  50. # Define component group for SCons
  51. group = DefineGroup(
  52. 'example_component_log',
  53. src,
  54. depend=['RT_USING_RUST'],
  55. LIBS=LIBS,
  56. LIBPATH=LIBPATH,
  57. LINKFLAGS=LINKFLAGS
  58. )
  59. Return('group')