Skip to content

Commit

Permalink
remake and improve 'export-*', fix 'export-config-results'
Browse files Browse the repository at this point in the history
  • Loading branch information
pustotnik committed Apr 13, 2021
1 parent 81927c0 commit 551e535
Show file tree
Hide file tree
Showing 22 changed files with 338 additions and 174 deletions.
3 changes: 2 additions & 1 deletion demos/c/05-startdir/project/src/prog/test.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include <stdio.h>
#include "util.h"

int main(int argc, char **argv)
int main(int argc, char **argv)
{
foo();
printf("hello from main\n");
return 0;
}
5 changes: 1 addition & 4 deletions demos/c/05-startdir/zenmake/buildconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'features' : 'cshlib',
'source' : 'src/shlib/**/*.c',
'includes' : 'includes',
'export-includes': True,
'export' : 'includes config-results',
'configure' : [
dict(do = 'check-headers', names = 'stdio.h'),
],
Expand All @@ -16,9 +16,6 @@
'features' : 'cprogram',
'source' : 'src/prog/**/*.c',
'use' : 'util',
'configure' : [
dict(do = 'check-headers', names = 'stdio.h'),
],
},
}

Expand Down
4 changes: 2 additions & 2 deletions demos/c/07-with spaces/buildconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'features' : 'cshlib',
'source' : '"my shlib/**/*.c"',
'includes' : '"my includes"',
'export-includes' : True,
'export' : 'includes',
'configure' : [
{ 'do' : 'check-headers', 'names' : 'stdio.h' },
],
Expand All @@ -24,7 +24,7 @@
'features' : 'cshlib',
'source' : '"my shlib/my util.c" "my shlib/my util2.c"',
'includes' : '"my includes"',
'export-includes' : True,
'export' : 'includes',
'configure' : [
{ 'do' : 'check-headers', 'names' : 'stdio.h' },
],
Expand Down
2 changes: 1 addition & 1 deletion demos/codegen/01-simple/buildconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'configure' : [ dict(do = 'find-program', names = 'python'), ],
'run' : '${PYTHON} ${TOP_DIR}/gencode.py ${BUILDTYPE_DIR}/generated',
'target' : '',
'export-config-results' : True,
'export' : 'config-results',
},
'gen-code2' : {
'run' : '${PYTHON} ${TOP_DIR}/gencode.py ${BUILDTYPE_DIR}/generated step2',
Expand Down
3 changes: 1 addition & 2 deletions demos/cpp/04-complex/buildconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
'source' : 'shlib/**/*.cpp',
'includes' : 'include',
'defines' : 'ABC=1 DOIT MY_LONG_STRING="some long string"',
'export-includes' : True,
'export-defines' : True,
'export' : 'includes defines',
'install-path' : False,
'configure' : [
{
Expand Down
2 changes: 1 addition & 1 deletion demos/cpp/10-headeronly/buildconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
tasks = {
'util' : {
'includes' : 'headers',
'export-includes' : True,
'export' : 'includes',
},
'program' : {
'features' : 'cxxprogram',
Expand Down
2 changes: 1 addition & 1 deletion demos/gtk3/03-withlib/buildconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'configure' : [
{ 'do' : 'pkgconfig', 'packages' : 'gtk+-3.0' },
],
'export-config-results' : True,
'export' : 'config-results',
'install-files' : [
{
'src' : '${BUILDTYPE_DIR}/builder.ui',
Expand Down
5 changes: 3 additions & 2 deletions demos/gtk3/04-withlib2/buildconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# find 'glib-compile-resources' by pkg-config
{
'msg' : 'Looking for glib-compile-resources',
'do' : 'toolconfig', 'toolname' : 'pkg-config',
'do' : 'toolconfig',
'toolname' : 'pkg-config',
'args' : '--variable=glib_compile_resources gio-2.0',
'parse-as' : 'entire',
'var' : 'COMPILE_RES',
Expand All @@ -30,7 +31,7 @@
'configure' : [
{ 'do' : 'pkgconfig', 'packages' : 'gtk+-3.0' },
],
'export-config-results' : True,
'export' : 'config-results',
},
'gtk3demo2' : {
'features' : 'cprogram',
Expand Down
2 changes: 1 addition & 1 deletion demos/subdirs/1-first/libs/core/buildconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def check(**kwargs):
'features' : 'cshlib',
'source' : '**/*.c',
'includes' : 'src',
'export-includes' : True,
'export' : 'includes',
'ver-num' : '0.4.0',
'configure' : [
dict(do = 'check-headers', names = 'stdio.h'),
Expand Down
2 changes: 1 addition & 1 deletion demos/subdirs/1-first/libs/engine/buildconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'source' : dict( incl = 'src/**/*.cpp', excl = 'src/extra*' ),
'includes' : 'src',
'use' : 'extra',
'export-includes' : True,
'export' : 'includes',
'configure' : [
dict(do = 'check-headers', names = 'iostream'),
],
Expand Down
2 changes: 1 addition & 1 deletion demos/subdirs/2-complex/libs/core/buildconf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ tasks:
corelib :
features : cshlib
source : '**/*.c'
export-includes : true
export : includes
ver-num : 0.4.0
configure :
- do: check-headers
Expand Down
3 changes: 1 addition & 2 deletions demos/subdirs/2-complex/libs/engine/buildconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def check2(**kwargs):
'includes' : 'src',
'use' : 'extra',
'ver-num' : '0.3.1',
'export-includes' : True,
'configure' : [
dict( do = 'check-headers', names = 'stdio.h iostream' ),
dict( do = 'parallel', actions = [
Expand All @@ -51,7 +50,7 @@ def check2(**kwargs):
dict( do = 'write-config-header'),
dict( do = 'check-headers', names = 'string vector' ),
],
'export-config-results' : True,
'export' : 'includes config-results',
},
'extra-test' : {
'features' : 'cxxprogram test',
Expand Down
136 changes: 89 additions & 47 deletions docs/buildconf-taskparams.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,7 @@ includes
It's possible to use :ref:`selectable parameters<buildconf-select>`
to set this parameter.

export-includes
"""""""""""""""""""""
If it's True then it exports value of ``includes`` for all build tasks
which depend on the current task. Also it can be one or more paths
for explicit exporting. By default it's False.

If paths contain spaces and all these paths are listed
in one string then each such a path must be in quotes.

It's possible to use :ref:`selectable parameters<buildconf-select>`
to set this parameter.
This parameter can be :ref:`exported<buildconf-taskparams-export>`.

.. _buildconf-taskparams-toolchain:

Expand Down Expand Up @@ -351,23 +341,7 @@ defines
And it's possible to use :ref:`selectable parameters<buildconf-select>`
to set this parameter.

export-defines
"""""""""""""""""""""
If it's True then it exports value of
:ref:`defines<buildconf-taskparams-defines>` for all build tasks
which depend on the current task. Also it can be one or more defines
for explicit exporting. Defines from :ref:`configuration actions<config-actions>`
are not exported.
Use :ref:`export-config-results<buildconf-taskparams-export-config-results>`
to export defines from configuration actions.

By default it's False.

You can use :ref:`substitution<buildconf-substitutions>`
variables for this parameter.

And it's possible to use :ref:`selectable parameters<buildconf-select>`
to set this parameter.
Also this parameter can be :ref:`exported<buildconf-taskparams-export>`.

.. _buildconf-taskparams-use:

Expand Down Expand Up @@ -410,12 +384,12 @@ libs
task you may need to specify the same libraries for all other tasks which
depend on the current task. For example, you set library 'mylib'
to the task A but the task B has parameter ``use`` with 'A',
then it's recommended to add 'mylib' to the parameter ``libs`` of the
then it's recommended to add 'mylib' to the parameter ``libs`` for the
task B. Otherwise you can get link error ``... undefined reference to ...``
or something like that.
Some other ways to solve this problem includes using environment variable
``LD_LIBRARY_PATH`` or changing of /etc/ld.so.conf file. But last way usually
is not recommended.
Some other ways to solve this problem include using environment variable
``LD_LIBRARY_PATH`` or changing of /etc/ld.so.conf file. But usually last
method is not recommended.

Example:

Expand Down Expand Up @@ -646,17 +620,8 @@ configure
It's possible to use :ref:`selectable parameters<buildconf-select>`
to set this parameter.

.. _buildconf-taskparams-export-config-results:

export-config-results
"""""""""""""""""""""
If it's True then it exports all results of actions in
:ref:`configure<buildconf-taskparams-configure>` for all
build tasks which depend on the current task.
By default it's False.

It's possible to use :ref:`selectable parameters<buildconf-select>`
to set this parameter.
Results of these configuration actions
can be :ref:`exported<buildconf-taskparams-export>` with the name `config-results`.

.. _buildconf-taskparams-substvars:

Expand All @@ -672,13 +637,90 @@ substvars
It's possible to use :ref:`selectable parameters<buildconf-select>`
to set this parameter.

.. _buildconf-taskparams-export:

export-<param> / export
""""""""""""""""""""""""

Some task parameters can be exported to all dependent build tasks.

There two forms: ``export-<param>`` and ``export``.

In first form ``<param>`` is a name of task parameter that can be exported.
As value can be used True/False or specific value to export.
If value is True then ZenMake exports value of parameter from current task
to all dependent build tasks. If value is False then ZenMake
exports nothing.

Supported names: ``includes``, ``defines``, ``config-results``.

The parameter with ``config-results`` can not be used to export specific values.
It always must be True/False only.

In second form it must be string or list with the names of parameters to export.
Second form is simplified form of the first form when all values are True.
This form can not be used to set specific value to export.

By default ZenMake doesn't export anything (all values are False).

Exported values are inserted in the beginning of the current parameter values
in dependent tasks. It was made to have ability to overwrite parent values.
For example, task A has ``defines`` with value ``AAA=q`` and task B depends
on task A and has ``defines`` with value ``BBB=v``. So if task A has
``export-defines`` with True, then actual value of ``defines`` in task B will
be ``AAA=q BBB=v``.

Examples in YAML format:

.. code-block:: yaml
# export all includes from current task
export-includes: true
# the same result:
export: includes
# export all includes and defines from current task
export-includes: true
export-defines: true
# the same result:
export: includes defines
# export specific includes, value of parameter 'includes' from current
# task is not used
export-includes: incl1 incl2
# export specific defines, value of parameter 'defines' from current
# task is not used
export-defines : 'ABC=1 DOIT AAA="some long string"'
# export results of all configuration actions from current task
export-config-results: true
# export all includes, defines and results of configuration actions
export: includes defines config-results
Specific remarks:

:includes:
If specified paths contain spaces and all these paths are listed
in one string then each such a path must be in quotes.

:defines:
Defines from :ref:`configuration actions<config-actions>`
are not exported. Use ``export-config-results`` or
``export`` with ``config-results`` for that.

It's possible to use :ref:`selectable parameters<buildconf-select>`
to set this parameter.

install-path
"""""""""""""""""""""
String representing the installation path for the output files.
It's used in commands ``install`` and ``uninstall``.
To disable installation, set it to False or empty string.
If it's absent then general values of ``PREFIX``, ``BINDIR``
and ``LIBDIR`` will be used to detect path.
Path must be absolute.
You can use any :ref:`substitution<buildconf-substitutions>` variable
including ``${PREFIX}``, ``${BINDIR}`` and ``${LIBDIR}`` here
like this:
Expand Down Expand Up @@ -828,7 +870,7 @@ group-dependent-tasks
analyzing of the task dependencies and file paths in :ref:`source<buildconf-taskparams-source>`.
Such list of tasks is called `build group` and, by default, it's only one
build group for each project which uses ZenMake. If this parameter is true,
ZenMake creates a new build group for all other tasks which depend on the current task and
ZenMake creates a new build group for all other dependent tasks and
preparation for these dependent tasks will be run only when all jobs for current
task, including all dependencies, are done.

Expand All @@ -851,12 +893,12 @@ objfile-index
build task.

If you set this for one task but not for others in the same project and your
selected index number is matched with an one of automatic generated indexes
then it can cause compilation errors if different tasks uses the same files in
index number is matched with one of automatic generated indexes
then it can cause compilation errors if different tasks use the same files in
parameter ``source``.

Also you can set the same value for the all build tasks and often it's not a
problem while different tasks uses the different files in
problem while different tasks use the different files in
parameter ``source``.

Set this parameter only if you know what you do.
Expand Down
11 changes: 5 additions & 6 deletions docs/config-actions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,9 @@ These configuration actions in ``dict`` format:

*Supported languages*: C, C++.

After some configuration actions are executed, write a
configuration header in the build directory.
The configuration header is used to limit the size of the
command-line. By default file name is ``<task name>_config.h``.
Write a configuration header in the build directory after some
configuration actions.
By default file name is ``<task name>_config.h``.
Parameter ``guard`` can be used to change C/C++ header guard.
Parameter ``remove-defines`` means removing the defines after they are
added into configuration header file and it is True by default.
Expand Down Expand Up @@ -354,8 +353,8 @@ for parallel actions and for the whole bundle of parallel actions as well.

All results (defines and some other values) of configuration actions
(excluding ``call-pyfunc``) in one build
task can be exported to all build tasks which depend on the current task.
Use :ref:`export-config-results<buildconf-taskparams-export-config-results>`
task can be exported to all dependent build tasks.
Use :ref:`export<buildconf-taskparams-export>` with the name `config-results`
for this ability. It allows you to avoid writing the same config actions in tasks
and reduce configuration actions time run.

Expand Down
Loading

0 comments on commit 551e535

Please sign in to comment.