Import('env', 'arch', 'messaging', 'common', 'visionipc', 'ffmpeg_libs')

libs = [common, messaging, visionipc] + ffmpeg_libs + ['pthread', 'm', 'zstd']
frameworks = []

src = ['logger.cc', 'zstd_writer.cc', 'video_writer.cc', 'encoder/encoder.cc', 'encoder/jpeg_encoder.cc']
if arch == "comma_arm64":
  src += ['clip_encoder.cc', 'encoder/v4l_encoder.cc', 'encoder/v4l_decoder.cc']
else:
  src += ['encoder/ffmpeg_encoder.cc']
  if arch == "Darwin":
    frameworks += ['VideoToolbox', 'CoreMedia', 'CoreFoundation', 'CoreVideo']

logger_lib = env.Library('logger', src)
libs.insert(0, logger_lib)

env.Program('loggerd', ['loggerd.cc'], LIBS=libs, FRAMEWORKS=frameworks)
env.Program('encoderd', ['encoderd.cc'], LIBS=libs, FRAMEWORKS=frameworks)
env.Program('bootlog.cc', LIBS=libs, FRAMEWORKS=frameworks)
