"""vxsdk-build modules This module provides package abstraction and build core function for the Vhex Operating system project. """ from core.logger import log from cli.build.default import build_default_cli from cli.build.doctor import build_doctor_cli __all__ = [ '__VXSDK_MODULE_META__', 'cli_validate', 'cli_parse', ] __VXSDK_MODULE_META__ = ( ['build'], "Build a project", r"""vxsdk-build Build System Abstraction USAGE: vxsdk build(-) [OPTIONS] DESCRIPTION: Compile Vhex project. NOTES: The Vex build system is extremely powerful and polyvalent. It allows the user to totally ignore the build part and the dependencies management. All Vhex projects use a <.vxsdk.toml> file wich should be stored at the root of the project directory (you cam generate a project template using the `vxsdk project new `). This file uses the TOML language to control the build step of a project. ``` # Default meta-data information for the pacakge manager. [project] name = 'myaddin' # required version = '1.0.0' # required type = 'addin' # optional ('addin' or 'app') description = ''' # optional An old-school demo-scene ! Written by Yatis :) ''' # Dependencies information for the build manager. (optional) # # The version can target or branch name. # # Note that you can use a powerfull operations for managing version of # dependencies if the 'version' is detected to respect the correct # semantic versioning like caret (^), tilde (~) and wildcard (*): # # Caret requirements (^) # ^1.2.3 := >=1.2.3, <2.0.0 # ^1.2 := >=1.2.0, <2.0.0 # ^1 := >=1.0.0, <2.0.0 # ^0.2.3 := >=0.2.3, <0.3.0 # ^0.2 := >=0.2.0, <0.3.0 # ^0.0.3 := >=0.0.3, <0.0.4 # ^0.0 := >=0.0.0, <0.1.0 # ^0 := >=0.0.0, <1.0.0 # # Tilde requirements (~) # ~1.2.3 := >=1.2.3, <1.3.0 # ~1.2 := >=1.2.0, <1.3.0 # ~1 := >=1.0.0, <2.0.0 # # Wildcard requirements (*) # * := >=0.0.0 # 1.* := >=1.0.0, <2.0.0 # 1.2.* := >=1.2.0, <1.3.0 # # Note that it's possible that a package can have two same versions (one # for branch name and another for a tag), by default, the tag is always # selected, but here the display information will explicitly describe if # the version is a tag and / or a branch. [dependencies] vxkernel = 'master' # recommanded sh-elf-vhex = 'master' # recommanded custom-lib = '^1.5' # exemple of carret (^) operation # Manual build indication (option) # # Note that if this section is specified then only this build indication # will be executed, no default step will be used # # All building steop are, in order: # > configure # > build # > install # And during all of theses building step, the vxSDk setup some # environment variable: # > VXSDK_PKG_NAME - project name # > VXSDK_PKG_VERSION - project version # > VXSDK_PREFIX_BUILD - project build prefix (for object files) # > VXSDK_PREFIX_INSTALL - project installation prefix # > VXSDK_PREFIX_LIB - prefix for all stored librairy # > VXSDK_CFLAGS_INCLUDE - Include flags for GCC # > VXSDK_CFLAGS_LINK - Linker flags for GCC # > VXSDK_ASSETS_SRC - Assets sources file directory # > VXSDK_ASSETS_BUILD - Assets build directory (for object) [build] configure = 'mkdir -p build && cd build && ../configure --verbose' build = 'cd build && make' # Dependencies Hook (optional) # # You need to create a section wich is named like [extra.] # and you can "hook" some step of particular dependencies (here # vxkernel for exemple). # # A hook is simply additional string that will be send to the # appropriate step of the build. [extra.vxkernel] configure = '--static --verbose' ``` Above is a exemple of a defaut project configuration file that can be used for a new project. OPTIONS: -v, --verbose Disable threading and display log information -r, --rebuild Force rebuild the project -u, --update Update dependencies --extra-conf [ARG]... Add extra configuration flags --extra-build [ARG]... Add extra build flags ACTIONS: doctor Display all information about one package """ ) #--- # Public #--- def cli_validate(name): """ validate the module name """ return name.find('build') == 0 def cli_parse(argv): """ Build subcommand entry """ if len(argv) > 2: if '--help' in argv or '-h' in argv: log.user(__VXSDK_MODULE_META__[2]) return 0 if argv[1] == 'doctor': return build_doctor_cli(argv[2:]) return build_default_cli(argv)