IQ.Pilot Release Commit @ 412b00f

This commit is contained in:
IQ.Lvbs CI [bot]
2026-08-18 07:14:33 -05:00
commit dca8172e55
4594 changed files with 1234560 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
import re
import SCons
from SCons.Action import Action
from SCons.Scanner import Scanner
pyx_from_import_re = re.compile(r'^from\s+(\S+)\s+cimport', re.M)
pyx_import_re = re.compile(r'^cimport\s+(\S+)', re.M)
cdef_import_re = re.compile(r'^cdef extern from\s+.(\S+).:', re.M)
def pyx_scan(node, env, path, arg=None):
contents = node.get_text_contents()
# from <module> cimport ...
matches = pyx_from_import_re.findall(contents)
# cimport <module>
matches += pyx_import_re.findall(contents)
# Modules can be either .pxd or .pyx files
files = [m.replace('.', '/') + '.pxd' for m in matches]
files += [m.replace('.', '/') + '.pyx' for m in matches]
# cdef extern from <file>
files += cdef_import_re.findall(contents)
# Handle relative imports
cur_dir = str(node.get_dir())
files = [cur_dir + f if f.startswith('/') else f for f in files]
# Filter out non-existing files (probably system imports)
files = [f for f in files if env.File(f).exists()]
return env.File(files)
pyxscanner = Scanner(function=pyx_scan, skeys=['.pyx', '.pxd'], recursive=True)
cythonAction = Action("$CYTHONCOM")
def create_builder(env):
try:
cython = env['BUILDERS']['Cython']
except KeyError:
cython = SCons.Builder.Builder(
action=cythonAction,
emitter={},
suffix=cython_suffix_emitter,
single_source=1
)
env.Append(SCANNERS=pyxscanner)
env['BUILDERS']['Cython'] = cython
return cython
def cython_suffix_emitter(env, source):
return "$CYTHONCFILESUFFIX"
def generate(env):
env["CYTHON"] = "cythonize"
env["CYTHONCOM"] = "$CYTHON $CYTHONFLAGS $SOURCE"
env["CYTHONCFILESUFFIX"] = ".cpp"
c_file, _ = SCons.Tool.createCFileBuilders(env)
c_file.suffix['.pyx'] = cython_suffix_emitter
c_file.add_action('.pyx', cythonAction)
c_file.suffix['.py'] = cython_suffix_emitter
c_file.add_action('.py', cythonAction)
create_builder(env)
def exists(env):
return True

View File

@@ -0,0 +1,51 @@
import platform
from SCons.Script import Dir, File
def compile_single_filter(env, target, filter_gen_script, output_dir, extra_gen_artifacts, script_deps):
generated_src_files = [File(f) for f in [f'{output_dir}/{target}.cpp', f'{output_dir}/{target}.h']]
extra_generated_files = [File(f'{output_dir}/{x}') for x in extra_gen_artifacts]
generator_file = File(filter_gen_script)
action = f"{File(generator_file).relpath} {target} {Dir(output_dir).relpath}"
if hasattr(env, 'PrettyAction'): # short colored line when the top-level pretty tool is present
action = env.PrettyAction(action, 'GEN')
env.Command(generated_src_files + extra_generated_files,
[generator_file] + script_deps, action)
generated_cc_file = File(generated_src_files[:1])
return generated_cc_file
class BaseRednoseCompileMethod:
def __init__(self, base_py_deps, base_cc_deps):
self.base_py_deps = base_py_deps
self.base_cc_deps = base_cc_deps
class CompileFilterMethod(BaseRednoseCompileMethod):
def __call__(self, env, target, filter_gen_script, output_dir, extra_gen_artifacts=[], gen_script_deps=[]):
objects = compile_single_filter(env, target, filter_gen_script, output_dir, extra_gen_artifacts, self.base_py_deps + gen_script_deps)
linker_flags = env.get("LINKFLAGS", [])
if platform.system() == "Darwin":
linker_flags = ["-undefined", "dynamic_lookup"]
lib_target = env.SharedLibrary(f'{output_dir}/{target}', [self.base_cc_deps, objects], LINKFLAGS=linker_flags)
return lib_target
def generate(env):
templates = env.Glob("$REDNOSE_ROOT/rednose/templates/*")
sympy_helpers = env.File("$REDNOSE_ROOT/rednose/helpers/sympy_helpers.py")
ekf_sym = env.File("$REDNOSE_ROOT/rednose/helpers/ekf_sym.py")
gen_script_deps = templates + [sympy_helpers, ekf_sym]
filter_lib_deps = []
env.AddMethod(CompileFilterMethod(gen_script_deps, filter_lib_deps), "RednoseCompileFilter")
def exists(env):
return True