Skip to content

Commit 675fb48

Browse files
committed
scons: more tests, less readme, create command
1 parent 5a08ed3 commit 675fb48

29 files changed

Lines changed: 116 additions & 54 deletions

File tree

‎scons/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Tested on SCons v2.3.0.
88
1. [Alias 2](alias2/)
99
1. [Default](default/)
1010
1. [Multi source](multi-source/)
11-
1. [Glob](glob/)
12-
1. [CPPPATH](cpppath/)
13-
1. [Library](library/)
11+
1. [Glob](glob/)
12+
1. [Library](library/)
13+
1. [Commane](command/)
1414
1. [SConscript](sconscript/)
1515
1. [Help](help/)
1616
1. [ARGUMENTS](arguments/)

‎scons/cflags/test‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
set -eu
33
scons
44
! scons std=c89
5-

‎scons/command/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/lib.c

‎scons/command/README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Command
2+
3+
Do an arbitrary build action.
4+
5+
Can promise to generate a target a file, and depend on a file, so useful for source generation.

‎scons/command/SConstruct‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def create_lib(target, source, env):
2+
with open(target[0].get_path(), 'w') as f:
3+
f.write('''\
4+
#include <stdio.h>
5+
6+
#include "lib.h"
7+
8+
void f() {
9+
puts("hello");
10+
}
11+
''')
12+
13+
env = Environment()
14+
lib_src = env.Command(
15+
# File to generate.
16+
'lib.c',
17+
# File dependencies.
18+
None,
19+
create_lib
20+
)
21+
env.Program(target='main.out', source=['main.c', lib_src])
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#ifndef LIB_H
22
#define LIB_H
3-
#define S "hello"
3+
void f();
44
#endif
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#include <stdio.h>
2-
31
#include "lib.h"
42

53
int main(void) {
6-
puts(S);
4+
f();
75
}

‎scons/command/test‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
scons --clean
5+
scons
6+
[ "$(./main.out)" = hello ]
7+
8+
# Clean also removes the generated source file.
9+
scons --clean
10+
[ ! -f lib.c ]

‎scons/cpppath/README.md‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎scons/cpppath/SConstruct‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)