Package: zmake
ZMake - A Make/ninja-build file generator from Kconfig/YAMLZMake - A Make/ninja-build file generator from Kconfig/YAML1. Overview2. How to intsall3. How to use4. YAML Configuration5. How to add one module6. TODO1. OverviewThis is a Make/ninja-build file generator from Kconfig/YAML config files for the modularized softwares. It makes use ofMake,Ninja-buildandKconfiglib. ForKconfiglib, more details could be found atgithub.com/ulfalizer/Kconfiglib.The following features are supplied:Project are configured byYAML file;Tools and basic options forCC/AR/LDcould be specified;Multiple applications and libraries are supported;Multiple level modules are supported;Each module has its own public and/or private header files, source files(C/C++/assembly),Kconfig scriptsandYAML configuration file;All the files that belongs to one module are placed in one directory;The following attribute of the libraries could be specified:Name;corresponding Kconfig option that are used to enable/disable this module;Source files;Public header directory;Compiler flags;The following attribute of the applications could be specified:Name;corresponding Kconfig option that are used to enable/disable this module;Source files;Compiler flags;linker flags;libraries depended that are used to include corresponding hedear files and libraries for this module;The following attribute of the source files could be specified:Compiler flags;TheYAMLroot file is by defaulttop.ymlin the root directory, or can be specified with-y "YAML file";TheKconfigfile root is by defaultKconfigin the root directory, or can be specified with-k "Kconfig file";Thedefconfigfile forKconfigis unsued by default, or can be specified with-d "defconfig file";Build order are decided by the defined order in YAML configuration files for Makefile;Build order are decided by the depends in YAML configuration files for Ninja build.2. How to intsallPython3must be installed forZMake, and at least one ofGNU MakeorNinja-buildshould be installed.Kconfiglibpackage should be installed too:$pip3installkconfiglibNotethatKconfiglibpath may be need to be added to 'PATH' environment variable; for Linux, executeexport PATH=$PATH:~/.local/binin the shell or add this command to~/.bashrcor~/.bash_profile;ZMakecould be installed bypip3:$pip3installzmakeZMakecould be installed from source code also:$gitclonehttps://github.com/matthewzu/zmake.git
$cdzmake
zmake$pythonsetup.pysdistbdist_wheel
zmake$pip3installdist/zmake-0.1.0.tar.gz3. How to useZMakeprovides a command to directly generate a source code directory as a demo:$zmake-demo<path/of/demo>Use the following command to generate a project from the demo directory:<path/of/demo>$zmake<path/of/project># generate Makefile<path/of/demo>$zmake<path/of/project>-gninja# generate build.ninja<path/of/demo>$zmake<path/of/project>-V# generate Makefile with verbose output enabled<path/of/demo>$zmake<path/of/project>-dtest_defconfig# generate Makefile with defconfig file<path/of/demo>$zmake<path/of/project>-kxxx.config# generate Makefile with xxx.config<path/of/demo>$zmake<path/of/project>-yxxx.yml# generate Makefile with xxx.ymlNotethat:
* The build log will be saved in<path/of/project>/zmake.log;
*Makefileorbuild.ninjawill be egnerated in <path/of/project>;
* The more options could be used:$zmake-h
usage:zmake[-h][-v][-V][-k"Kconfig file"][-y"YAML file"][-d"defconfig file"|-m"Source Code Path"][-g{make,ninja}]project

ZMakebuildGenerator

positionalarguments:projectprojectpath

optionalarguments:-h,--helpshowthishelpmessageandexit-v,--versionshowversion-V,--verboseenableverboseoutput-k"Kconfig file",--kconfig"Kconfig file"specifyKconfigrootconfigurationfile,"Kconfig"bydefault-y"YAML file",--yaml"YAML file"specifyYAMLrootconfigurationfile,"top.yml"bydefault-d"defconfig file",--defconfig"defconfig file"specifydefconfigfile-m"Source Code Path",--menuconfig"Source Code Path"enablemenuconfigmethod,usedafterprojectcreatedONLY-g{make,ninja},--generator{make,ninja}buildgenerator,"make"bydefaultConfigure/build/clean project:<path/of/project>$makeconfig# configuration project<path/of/project>$make# build project<path/of/project>$makeclean# clean project<path/of/project>$makeconfigV=1# configuration project with verbose output enabled<path/of/project>$makeV=1# build project with verbose output enabled<path/of/project>$makecleanV=1# clean project with verbose output enabled<path/of/project>$
<path/of/project>$ninjaconfig# configuration project<path/of/project>$ninja# build project<path/of/project>$ninjaclean# clean project<path/of/project>$ninjaconfig-v# configuration project with verbose output enabled<path/of/project>$ninja-v# build project with verbose output enabled<path/of/project>$ninjaclean-v# clean project with verbose output enabled4. YAML ConfigurationThe source directory should contain aYAMLroot configuration file (top.ymlby default). It should include the the references to other configuration files or ZMake Entity configurations. For example:# zmake top configuration# includes, note that file contents MUST NOT be overlapped,# otherwise the latter will overwrite the former.includes:-mod1/mod11/mod11.yml# library mod11 yaml-mod1/mod12/mod12.yml# library mod12 yaml-mod2/mod2.yml# library mod2 yaml-main/main.yml# application main/mani2 yaml# entities defines for the following types:#   1)'var':    variables that is used to save build arguments or intermediate variables,#   could be be referenced by '$(variable name)';#   2)'target': target for build command(make/ninja...);#   3)'app':    applications that could be executed;#   4)'lib':    libraries that could be linked to applications.# system variables#   1)SRC_PATH: path for source code#   2)PRJ_PATH: path for project#   3)CC:       compiler with parameters for objects, must be specified#   3)AR:       archiver with parameters for libraries, must be specified#   3)LD:       linker with parameters for applications, must be specifiedCC:type:vardesc:compiler with parameters for objectsval:gcc -MDAR:type:vardesc:archiver with parameters for librariesval:arLD:type:vardesc:linker with parameters for applicationsval:gcc# customer variables## example:##   variable name:  # must be unique for all entities#     type: var#     desc: xxx # optional, description that is only for display#     val:  xxx # value of the variable, which can be of any type; if string, it can contain#               # references to other variables defined previously, such as '$(var_name)'MOD11_PATH:type:vardesc:path for moudle11 libraryval:$(SRC_PATH)/mod1/mod11# libraries## example:## library name:             # must be unique for all entities#   type:       lib#   desc:       xxx         # optional, description that is only for display#   opt:        CONFIG_XXX  # optional, Kconfig option that decides whether library is enabled:#                           #   if present, it must be a Kconfig option that will be 'y' or 'n';#                           #   if absent, library will be will be forced to enable.#   src:                    # list, source files or directories:#     - $(ZMake variable name)/xxx/xxx.c#     - $(ZMake variable name)/xxx  # for directory, all source files in the directory (subdirectories involved) will be involved#   hdrdirs:                # optional, list, public header file directories#     - $(ZMake variable name)/xxx#   cflags:                 # optional, additional compiler flags for C files#     all:      xxx         # compiler flags for all C files#     xxx.c:    xxx         # compiler flags for xxx.c#   cppflags:               # optional, additional compiler flags for cpp files#     all:      xxx         # compiler flags for all CPP files#     xxx.cpp:  xxx         # compiler flags for xxx.cpp#   asmflags:   xxx         # optional, additional compiler flags for assembly files#     all:      xxx         # compiler flags for all assembly files#     xxx.s:    xxx         # compiler flags for xxx.s#     xxx.S:    xxx         # compiler flags for xxx.Smod11:type:libdesc:moudle11 libraryopt:CONFIG_MODULE11src:-$(MOD11_PATH)hdrdirs:-$(MOD11_PATH)/includecflags:all:-DMOD11mod11.c:-DMOD11_MOD11 -I$(MOD11_PATH)/include# applications## example:## application name:         # must be unique for all entities#   type:       app#   desc:       xxx         # optional, description that is only for display#   opt:        CONFIG_XXX  # optional, Kconfig option that decides whether application is enabled:#                           #   if present, it must be a Kconfig option that will be 'y' or 'n';#                           #   if absent, application will be will be forced to enable.#   src:                    # list, source files or directories:#     - $(ZMake variable name)/xxx/xxx.c#     - $(ZMake variable name)/xxx  # for directory, all source files in the directory (subdirectories involved) will be involved#   cflags:                 # optional, additional compiler flags for C files#     all:      xxx         # compiler flags for all C files#     xxx.c:    xxx         # compiler flags for xxx.c#   cppflags:               # optional, additional compiler flags for cpp files#     all:      xxx         # compiler flags for all CPP files#     xxx.cpp:  xxx         # compiler flags for xxx.cpp#   asmflags:   xxx         # optional, additional compiler flags for assembly files#     all:      xxx         # compiler flags for all assembly files#     xxx.s:    xxx         # compiler flags for xxx.s#     xxx.S:    xxx         # compiler flags for xxx.S#   linkflags:  xxx         # optional, additional linker flags#   libs:       xxx         # optional, library dependency list:#     - xxx                 #   library defined previouslymain:type:appdesc:main applicationsrc:-$(SRC_PATH)/main/main.ccflags:-all:-DMAINlibs:-mod11-mod12# system targets##   1)config:     configure Kconfig option for project#   2)all:        building all applications/libraries, default target#   3)clean:      clean all compiled files##   To enable verbose output, add "V=1" option for make or add "-v" for ninja.# customer targets## example:## target name:      # must be unique for all entities#   type: target#   desc: xxx # optional, description that is only for display#   cmd:  xxx # string, optional, commands that need be executed with description#   deps: xxx # optional, library/application/target dependency list:#     - xxx   #   library/application/target defined previously## Note that 'cmd' and 'deps' MUST NOT be absent at the same time.info:type:targetdesc:display hello worldcmd:echo hello world5. How to add one moduleCreate one directory in the framework for this module;Add source files andYAML configuration fileto this directory;Add public header directory with public header files to this directory as you need;Add private header files to this directory as you need;AddKconfigfiles(*.config) to this directory and include it fromKconfigin the root directory of the framework.6. TODOAdd support for dynamic library, dynamic module and pre-compiled library.