Skip to content

Commit 73bf1ff

Browse files
committed
doc: document pymod_do_main
1 parent 2f774a2 commit 73bf1ff

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

docs/InputFormatReference.md

+31-25
Original file line numberDiff line numberDiff line change
@@ -500,47 +500,60 @@ In addition, command expansions (unlike other variable expansions) may
500500
include nested variable expansions. So something like this is allowed:
501501
502502
```
503-
'variables' : [
503+
'variables' : {
504504
'foo': '<!(echo Build Date <!(date))',
505-
],
505+
},
506506
```
507507
508508
expands to:
509509
510510
```
511-
'variables' : [
511+
'variables' : {
512512
'foo': 'Build Date 02:10:38 PM Fri Jul 24, 2009 -0700 PDT',
513-
],
513+
},
514514
```
515515
516516
You may also put commands into arrays in order to quote arguments (but
517517
note that you need to use a different string quoting character):
518518
519519
```
520-
'variables' : [
520+
'variables' : {
521521
'files': '<!(["ls", "-1", "Filename With Spaces"])',
522-
],
522+
},
523523
```
524524
525525
GYP treats command failures (as indicated by a nonzero exit status)
526526
during command expansion as errors.
527527
528-
#### Example
528+
#### pymod_do_main
529529
530+
You can use the special `pymod_do_main` symbol to get GYP to import the specified Python module, and call it's `DoMain`
531+
method passing any parameters given.
532+
533+
```python
534+
{
535+
'variables' : {
536+
'res': '<!pymod_do_main(modulename par ame ters)',
537+
},
538+
}
530539
```
540+
541+
#### Example
542+
543+
```python
531544
{
532545
'sources': [
533-
'!(echo filename with space.cc)',
546+
'<!(echo filename with space.cc)',
534547
],
535548
'libraries': [
536-
'!@(pkg-config --libs-only-l apr-1)',
549+
'<!@(pkg-config --libs-only-l apr-1)',
537550
],
538551
}
539552
```
540553

541554
might expand to:
542555

543-
```
556+
```python
544557
{
545558
'sources': [
546559
'filename with space.cc', # no @, expands into a single string
@@ -558,18 +571,13 @@ Conditionals use the same set of variables used for variable expansion.
558571
As with variable expansion, there are two phases of conditional
559572
evaluation:
560573

561-
* “Early” or “pre” conditional evaluation, introduced in
562-
[conditions](#conditions) sections.
563-
* “Late,” “post,” or “target” conditional evaluation, introduced in
564-
[target\_conditions](#target_conditions) sections.
574+
* “Early” or “pre” conditional evaluation, introduced in [conditions](#conditions) sections.
575+
* “Late”, “post”, or “target” conditional evaluation, introduced in [target\_conditions](#target_conditions) sections.
565576

566-
The syntax for each type is identical, they differ only in the key name
567-
used to identify them and the timing of their evaluation. A more
568-
complete description of syntax and use is provided in
569-
[conditions](#conditions).
577+
The syntax for each type is identical, they differ only in the key name used to identify them and the timing of their evaluation.
578+
A more complete description of syntax and use is provided in [conditions](#conditions).
570579

571-
The difference the two phases of evaluation is described in [Early and
572-
Late Phases](#Early_and_Late_Phases).
580+
The difference the two phases of evaluation is described in [Early and Late Phases](#Early_and_Late_Phases).
573581

574582
## Timing of Variable Expansion and Conditional Evaluation
575583

@@ -578,13 +586,11 @@ Late Phases](#Early_and_Late_Phases).
578586
GYP performs two phases of variable expansion and conditional evaluation:
579587

580588
* The “early” or “pre” phase operates on [conditions](#conditions)
581-
sections and the `<` form of [variable
582-
expansions](#Variable_Expansions).
589+
sections and the `<` form of [variable expansions](#Variable_Expansions).
583590
* The “late,” “post,” or “target” phase operates on
584591
[target\_conditions](#target_conditions) sections, the `>` form
585592
of [variable expansions](#Variable_Expansions),
586-
and on the `!` form of [command
587-
expansions](#Command_Expansions_(!,_!@)).
593+
and on the `!` form of [command expansions](#Command_Expansions_(!,_!@)).
588594

589595
These two phases are provided because there are some circumstances in
590596
which each is desirable.
@@ -604,7 +610,7 @@ behaviors depending on the specifics of a target.
604610

605611
Given this input:
606612

607-
```
613+
```python
608614
{
609615
'target_defaults': {
610616
'target_conditions': [

0 commit comments

Comments
 (0)