Knowledge-Technology(Claude Opus 5) used - to assess the situation and present implementation avenues - for discussion while shaping the solution - for generating code and validating results Clang based tooling is used frequently for code analysis and navigation. This requires however that the exact flags and invocation is captured for each possible translation unit in the code base. That knowledge exists solely in the build system, and the established way to hand it over is the LLVM "JSON Compilation Database". SCons has provided a `CompilationDatabase` builder since 4.0, and it fits our setup well: it installs an emitter on the object builders and captures each command line while the dependency graph is constructed. Hence nothing is compiled -- generating takes about two seconds -- and the result always describes the complete build graph as declared, rather than the target actually requested on this invocation. This feature is provided as ''opt-in'', either through the sticky option `COMPILEDB=yes` or by direct invocation with `scons compiledb` The `compile_commands.json` is generated into the build output `target/' dir For configuration, a `.clangd` in project root instructs the language server where to find this file. __Note__ the ordering constraint recorded in `CompileDB.py`: the emitter must be installed only after `Platform.configure()` has run, or it also captures the `conftest_*` compilations of the configure checks. That is why this is a plain helper invoked from the `SConstruct` -- similar to Setup, Options, Platform -- and not a tool loaded from the `LumieraEnvironment`.
71 lines
3.1 KiB
Python
71 lines
3.1 KiB
Python
# coding: utf-8
|
||
##
|
||
## Options.py - SCons build: command line options and help
|
||
##
|
||
|
||
# Copyright (C)
|
||
# 2012, Hermann Vosseler <Ichthyostega@web.de>
|
||
#
|
||
# **Lumiera** is free software; you can redistribute it and/or modify it
|
||
# under the terms of the GNU General Public License as published by the
|
||
# Free Software Foundation; either version 2 of the License, or (at your
|
||
# option) any later version. See the file COPYING for further details.
|
||
#####################################################################
|
||
|
||
|
||
from SCons.Script import PathVariable, EnumVariable, BoolVariable, Help
|
||
|
||
|
||
|
||
|
||
|
||
def defineCmdlineVariables(buildVars):
|
||
""" several toggles and configuration variables can be set on the commandline,
|
||
current settings will be persisted in a options cache file.
|
||
you may define custom variable settings in a separate file.
|
||
Commandline will override both.
|
||
"""
|
||
buildVars.AddVariables(
|
||
('ARCHFLAGS', 'Set architecture-specific compilation flags (passed literally to gcc)','')
|
||
,('CC', 'Set the C compiler to use.', 'gcc')
|
||
,('CXX', 'Set the C++ compiler to use.', 'g++')
|
||
,EnumVariable('BUILDLEVEL', 'NoBug build level for debugging', 'ALPHA', allowed_values=('ALPHA', 'BETA', 'RELEASE'))
|
||
,BoolVariable('DEBUG', 'Build with debugging information and no optimisations', False)
|
||
,BoolVariable('OPTIMIZE', 'Build with strong optimisation (-O3)', False)
|
||
,BoolVariable('VALGRIND', 'Run Testsuite under valgrind control', True)
|
||
,BoolVariable('VERBOSE', 'Print full build commands', False)
|
||
,BoolVariable('COMPILEDB','Generate target/compile_commands.json for clangd', False)
|
||
,('TESTSUITES', 'Run only test suites matching the given pattern', '')
|
||
,('TESTMODE', 'test suite error mode for test.sh', '')
|
||
# ,BoolVariable('OPENGL', 'Include support for OpenGL preview rendering', False)
|
||
# ,EnumVariable('DIST_TARGET', 'Build target architecture', 'auto',
|
||
# allowed_values=('auto', 'i386', 'i686', 'x86_64' ), ignorecase=2)
|
||
,PathVariable('PREFIX', 'Installation dir prefix', 'usr/local', PathVariable.PathAccept)
|
||
,PathVariable('INSTALLDIR', 'Root output directory for install. Final installation will happen in INSTALLDIR/PREFIX/... ', '/', PathVariable.PathAccept)
|
||
)
|
||
|
||
|
||
|
||
def prepareOptionsHelp(buildVars,env):
|
||
prelude = """
|
||
USAGE: scons [-c] [OPTS] [key=val [key=val...]] [TARGETS]
|
||
Build and optionally install Lumiera.
|
||
Without specifying any target, just the (re)build target will run.
|
||
Add -c to the commandline to clean up anything a given target would produce
|
||
|
||
Special Targets:
|
||
build : just compile and link
|
||
research: build experimental code (might fail)
|
||
testcode: additionally compile the Testsuite
|
||
check : build and run the Testsuite
|
||
doc : generate documentation (Doxygen)
|
||
compiledb: just (re)generate target/compile_commands.json for clangd
|
||
all : build and testcode and doc
|
||
install : install created artifacts at PREFIX
|
||
|
||
Configuration Options:
|
||
"""
|
||
Help(prelude + buildVars.GenerateHelpText(env))
|
||
|
||
|
||
|