-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generators can have extra target dependencies. Closes #4131.
- Loading branch information
Showing
11 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
## Generators have a new `depends` keyword argument | ||
|
||
Generators can now specify extra dependencies with the `depends` | ||
keyword argument. It matches the behaviour of the same argument in | ||
other functions and specifies that the given targets must be built | ||
before the generator can be run. This is used in cases such as this | ||
one where you need to tell a generator to indirectly invoke a | ||
different program. | ||
|
||
```meson | ||
exe = executable(...) | ||
cg = generator(program_runner, | ||
output: ['@BASENAME@.c'], | ||
arguments: ['--use-tool=' + exe.full_path(), '@INPUT@', '@OUTPUT@'], | ||
depends: exe) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import sys, subprocess | ||
|
||
prog, infile, outfile = sys.argv[1:] | ||
|
||
subprocess.check_call([prog, infile, outfile]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include<stdio.h> | ||
#include<assert.h> | ||
|
||
#define BUFSIZE 1024 | ||
|
||
int main(int argc, char **argv) { | ||
char buffer[BUFSIZE]; | ||
size_t num_read; | ||
size_t num_written; | ||
FILE *fin = fopen(argv[1], "rb"); | ||
FILE *fout; | ||
assert(fin); | ||
num_read = fread(buffer, 1, BUFSIZE, fin); | ||
assert(num_read > 0); | ||
fclose(fin); | ||
fout = fopen(argv[2], "wb"); | ||
assert(fout); | ||
num_written = fwrite(buffer, 1, num_read, fout); | ||
assert(num_written == num_read); | ||
fclose(fout); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
int func() { | ||
return 42; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
runner = find_program('copyrunner.py') | ||
|
||
copier = executable('copier', 'filecopier.c', native: true) | ||
|
||
cg = generator(runner, | ||
output: ['@BASENAME@.c'], | ||
arguments: [copier.full_path(), '@INPUT@', '@OUTPUT@'], | ||
depends: copier) | ||
|
||
test('generatordep', | ||
executable('gd', 'prog.c', cg.process('libsrc.c.in'))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
int func(); | ||
|
||
int main(int argc, char **argv) { | ||
return func() != 42; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters