mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-18 04:50:17 +02:00
Got rid of the requirement to have a "package" directive. Fixed a grammar error
found in the process. Also taught the regression test system a new trick: the path to "fped" can be passed in the environment variable FPED. E.g., FPED=fped.r5943 make test - fped.c (usage, main): duplicating the -T option produces a dump to stdout before exiting (like %dump would) - test/Common: new command fped_dump to invoked fped with a second -T option - test/Common: if the environment variable FPED is set, use its content to invoke fped (default is ../fped) - test/Common: if the environment variable CWD_PREFIX is set, prepend it to $FPED if the latter is a relative path - Makefile (test, tests): set CWD_PREFIX to .., so that the path given in FPED is valid at the point of invocation - fpd.y: revised grammar to make "package" optional - fpd.y: measurements were syntactically allowed inside non-root frame (test/structure) - test/structure: test various combinations of the grammatical file structure - test/tsort: removed all the now unnecessary "package" directives git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5944 99fdad57-331a-0410-800a-d7fa5415bdb3
This commit is contained in:
parent
bc27b094af
commit
39fef16d1c
2
Makefile
2
Makefile
@ -162,7 +162,7 @@ test tests: all
|
|||||||
LANG= sh -c \
|
LANG= sh -c \
|
||||||
'passed=0 && cd test && \
|
'passed=0 && cd test && \
|
||||||
for n in [a-z]*; do \
|
for n in [a-z]*; do \
|
||||||
SCRIPT=$$n . ./$$n; done; \
|
SCRIPT=$$n CWD_PREFIX=.. . ./$$n; done; \
|
||||||
echo "Passed all $$passed tests"'
|
echo "Passed all $$passed tests"'
|
||||||
|
|
||||||
valgrind:
|
valgrind:
|
||||||
|
7
README
7
README
@ -148,6 +148,8 @@ unit mm
|
|||||||
unit mil
|
unit mil
|
||||||
unit auto
|
unit auto
|
||||||
|
|
||||||
|
If the "unit" directive is omitted, fped defaults to millimeters.
|
||||||
|
|
||||||
When saving a footprint definition, the default unit is set to the
|
When saving a footprint definition, the default unit is set to the
|
||||||
unit set in the GUI.
|
unit set in the GUI.
|
||||||
|
|
||||||
@ -301,8 +303,9 @@ meas a b 0.2 mm
|
|||||||
Package name
|
Package name
|
||||||
- - - - - -
|
- - - - - -
|
||||||
|
|
||||||
The package name is a string of printable ASCII characters, including
|
The package name is a non-empty string of printable ASCII characters,
|
||||||
spaces.
|
including spaces. If the "package" directive is omitted, fped defaults
|
||||||
|
to using the name "_".
|
||||||
|
|
||||||
package "<name>"
|
package "<name>"
|
||||||
|
|
||||||
|
23
fpd.y
23
fpd.y
@ -342,7 +342,10 @@ all:
|
|||||||
;
|
;
|
||||||
|
|
||||||
fpd:
|
fpd:
|
||||||
| frame_defs part_name opt_unit frame_items
|
frame_defs part_name opt_unit opt_frame_items opt_measurements
|
||||||
|
| frame_defs unit opt_frame_items opt_measurements
|
||||||
|
| frame_defs frame_items opt_measurements
|
||||||
|
| frame_defs opt_measurements
|
||||||
;
|
;
|
||||||
|
|
||||||
part_name:
|
part_name:
|
||||||
@ -364,7 +367,11 @@ part_name:
|
|||||||
;
|
;
|
||||||
|
|
||||||
opt_unit:
|
opt_unit:
|
||||||
| TOK_UNIT ID
|
| unit
|
||||||
|
;
|
||||||
|
|
||||||
|
unit:
|
||||||
|
TOK_UNIT ID
|
||||||
{
|
{
|
||||||
if (!strcmp($2, "mm"))
|
if (!strcmp($2, "mm"))
|
||||||
curr_unit = curr_unit_mm;
|
curr_unit = curr_unit_mm;
|
||||||
@ -400,14 +407,18 @@ frame_def:
|
|||||||
frames = curr_frame;
|
frames = curr_frame;
|
||||||
last_frame = curr_frame;
|
last_frame = curr_frame;
|
||||||
}
|
}
|
||||||
frame_items '}'
|
opt_frame_items '}'
|
||||||
{
|
{
|
||||||
set_frame(root_frame);
|
set_frame(root_frame);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
opt_frame_items:
|
||||||
|
| frame_items
|
||||||
|
;
|
||||||
|
|
||||||
frame_items:
|
frame_items:
|
||||||
| measurements
|
frame_item
|
||||||
| frame_item frame_items
|
| frame_item frame_items
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -763,6 +774,10 @@ pad_type:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
opt_measurements:
|
||||||
|
| measurements
|
||||||
|
;
|
||||||
|
|
||||||
measurements:
|
measurements:
|
||||||
meas
|
meas
|
||||||
{
|
{
|
||||||
|
7
fped.c
7
fped.c
@ -65,11 +65,12 @@ static void load_file(const char *name)
|
|||||||
static void usage(const char *name)
|
static void usage(const char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [-k] [-p|-P] [-T] [cpp_option ...] [in_file [out_file]]\n\n"
|
"usage: %s [-k] [-p|-P] [-T [-T]] [cpp_option ...] [in_file [out_file]]\n\n"
|
||||||
" -k write KiCad output, then exit\n"
|
" -k write KiCad output, then exit\n"
|
||||||
" -p write Postscript output, then exit\n"
|
" -p write Postscript output, then exit\n"
|
||||||
" -P write Postscript output (full page), then exit\n"
|
" -P write Postscript output (full page), then exit\n"
|
||||||
" -T test mode. Load file, then exit\n"
|
" -T test mode. Load file, then exit\n"
|
||||||
|
" -T -T test mode. Load file, dump to stdout, then exit\n"
|
||||||
" cpp_option -Idir, -Dname[=value], or -Uname\n"
|
" cpp_option -Idir, -Dname[=value], or -Uname\n"
|
||||||
, name);
|
, name);
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -85,6 +86,7 @@ int main(int argc, char **argv)
|
|||||||
char opt[] = "-?";
|
char opt[] = "-?";
|
||||||
int error;
|
int error;
|
||||||
int batch = 0;
|
int batch = 0;
|
||||||
|
int test_mode = 0;
|
||||||
int batch_write_kicad = 0;
|
int batch_write_kicad = 0;
|
||||||
int batch_write_ps = 0, batch_write_ps_fullpage = 0;
|
int batch_write_ps = 0, batch_write_ps_fullpage = 0;
|
||||||
int c;
|
int c;
|
||||||
@ -102,6 +104,7 @@ int main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
batch = 1;
|
batch = 1;
|
||||||
|
test_mode++;
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'U':
|
case 'U':
|
||||||
@ -167,6 +170,8 @@ int main(int argc, char **argv)
|
|||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
if (test_mode > 1)
|
||||||
|
dump(stdout);
|
||||||
|
|
||||||
purge();
|
purge();
|
||||||
inst_revert();
|
inst_revert();
|
||||||
|
15
test/Common
15
test/Common
@ -17,7 +17,7 @@ fped()
|
|||||||
echo -n "$1: " 1>&2
|
echo -n "$1: " 1>&2
|
||||||
shift
|
shift
|
||||||
cat >_in
|
cat >_in
|
||||||
$VALGRIND ../fped -T _in "$@" >_out 2>&1 || {
|
$VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 || {
|
||||||
echo FAILED "($SCRIPT)" 1>&2
|
echo FAILED "($SCRIPT)" 1>&2
|
||||||
cat _out
|
cat _out
|
||||||
rm -f _in _out
|
rm -f _in _out
|
||||||
@ -27,12 +27,18 @@ fped()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fped_dump()
|
||||||
|
{
|
||||||
|
fped "$@" -T
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fped_fail()
|
fped_fail()
|
||||||
{
|
{
|
||||||
echo -n "$1: " 1>&2
|
echo -n "$1: " 1>&2
|
||||||
shift
|
shift
|
||||||
cat >_in
|
cat >_in
|
||||||
$VALGRIND ../fped -T _in "$@" >_out 2>&1 && {
|
$VALGRIND ${FPED:-../fped} -T _in "$@" >_out 2>&1 && {
|
||||||
echo FAILED "($SCRIPT)" 1>&2
|
echo FAILED "($SCRIPT)" 1>&2
|
||||||
cat _out
|
cat _out
|
||||||
rm -f _in _out
|
rm -f _in _out
|
||||||
@ -54,3 +60,8 @@ expect()
|
|||||||
rm -f _out _diff
|
rm -f _out _diff
|
||||||
passed=`expr ${passed:-0} + 1`
|
passed=`expr ${passed:-0} + 1`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if [ ! -z "$CWD_PREFIX" -a ! -z "$FPED" -a "$FPED" = "${FPED#/}" ]; then
|
||||||
|
FPED="$CWD_PREFIX/$FPED"
|
||||||
|
fi
|
||||||
|
103
test/structure
Executable file
103
test/structure
Executable file
@ -0,0 +1,103 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
. ./Common
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
fped_dump "structure: empty file" <<EOF
|
||||||
|
EOF
|
||||||
|
expect <<EOF
|
||||||
|
/* MACHINE-GENERATED ! */
|
||||||
|
|
||||||
|
package "_"
|
||||||
|
unit mm
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
fped_dump "structure: just an empty frame definition" <<EOF
|
||||||
|
frame foo {
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
expect <<EOF
|
||||||
|
/* MACHINE-GENERATED ! */
|
||||||
|
|
||||||
|
frame foo {
|
||||||
|
}
|
||||||
|
|
||||||
|
package "_"
|
||||||
|
unit mm
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
fped_dump "structure: just the package name" <<EOF
|
||||||
|
package "hello"
|
||||||
|
EOF
|
||||||
|
expect <<EOF
|
||||||
|
/* MACHINE-GENERATED ! */
|
||||||
|
|
||||||
|
package "hello"
|
||||||
|
unit mm
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
fped_dump "structure: just the unit" <<EOF
|
||||||
|
unit mil
|
||||||
|
EOF
|
||||||
|
expect <<EOF
|
||||||
|
/* MACHINE-GENERATED ! */
|
||||||
|
|
||||||
|
package "_"
|
||||||
|
unit mil
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
fped_dump "structure: just one root frame item" <<EOF
|
||||||
|
vec @(1mm, 1mm)
|
||||||
|
EOF
|
||||||
|
expect <<EOF
|
||||||
|
/* MACHINE-GENERATED ! */
|
||||||
|
|
||||||
|
package "_"
|
||||||
|
unit mm
|
||||||
|
__0: vec @(1mm, 1mm)
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
fped_dump "structure: frame plus measurement" <<EOF
|
||||||
|
frame f {
|
||||||
|
a: vec @(0mm, 0mm)
|
||||||
|
b: vec @(1mm, 1mm)
|
||||||
|
}
|
||||||
|
meas f.a -> f.b
|
||||||
|
EOF
|
||||||
|
expect <<EOF
|
||||||
|
/* MACHINE-GENERATED ! */
|
||||||
|
|
||||||
|
frame f {
|
||||||
|
a: vec @(0mm, 0mm)
|
||||||
|
b: vec @(1mm, 1mm)
|
||||||
|
}
|
||||||
|
|
||||||
|
package "_"
|
||||||
|
unit mm
|
||||||
|
meas f.a -> f.b
|
||||||
|
EOF
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
fped_fail "structure: measurement in frame" <<EOF
|
||||||
|
frame f {
|
||||||
|
a: vec @(0mm, 0mm)
|
||||||
|
b: vec @(1mm, 1mm)
|
||||||
|
meas f.a -> f.b
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
expect <<EOF
|
||||||
|
4: syntax error near "meas"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
###############################################################################
|
16
test/tsort
16
test/tsort
@ -4,8 +4,6 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
fped "tsort: total order" <<EOF
|
fped "tsort: total order" <<EOF
|
||||||
package "_"
|
|
||||||
|
|
||||||
%tsort {
|
%tsort {
|
||||||
a b
|
a b
|
||||||
a c
|
a c
|
||||||
@ -25,8 +23,6 @@ EOF
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
fped "tsort: partial order change (1)" <<EOF
|
fped "tsort: partial order change (1)" <<EOF
|
||||||
package "_"
|
|
||||||
|
|
||||||
%tsort {
|
%tsort {
|
||||||
a b
|
a b
|
||||||
a c
|
a c
|
||||||
@ -44,8 +40,6 @@ EOF
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
fped "tsort: partial order change (2)" <<EOF
|
fped "tsort: partial order change (2)" <<EOF
|
||||||
package "_"
|
|
||||||
|
|
||||||
%tsort {
|
%tsort {
|
||||||
b c
|
b c
|
||||||
c d
|
c d
|
||||||
@ -62,8 +56,6 @@ EOF
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
fped "tsort: old order differs from resolution order" <<EOF
|
fped "tsort: old order differs from resolution order" <<EOF
|
||||||
package "_"
|
|
||||||
|
|
||||||
%tsort {
|
%tsort {
|
||||||
+a +b +c +d
|
+a +b +c +d
|
||||||
a c
|
a c
|
||||||
@ -81,8 +73,6 @@ EOF
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
fped "tsort: order change due to priority" <<EOF
|
fped "tsort: order change due to priority" <<EOF
|
||||||
package "_"
|
|
||||||
|
|
||||||
%tsort {
|
%tsort {
|
||||||
a b
|
a b
|
||||||
a c 1
|
a c 1
|
||||||
@ -99,8 +89,6 @@ EOF
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
fped "tsort: priority accumulation without decay" <<EOF
|
fped "tsort: priority accumulation without decay" <<EOF
|
||||||
package "_"
|
|
||||||
|
|
||||||
%tsort {
|
%tsort {
|
||||||
+a +b +c +d
|
+a +b +c +d
|
||||||
a b 1
|
a b 1
|
||||||
@ -117,8 +105,6 @@ EOF
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
fped "tsort: priority accumulation with decay" <<EOF
|
fped "tsort: priority accumulation with decay" <<EOF
|
||||||
package "_"
|
|
||||||
|
|
||||||
%tsort {
|
%tsort {
|
||||||
+a -b +c +d
|
+a -b +c +d
|
||||||
a b 1
|
a b 1
|
||||||
@ -135,8 +121,6 @@ EOF
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
fped_fail "tsort: cycle" <<EOF
|
fped_fail "tsort: cycle" <<EOF
|
||||||
package "_"
|
|
||||||
|
|
||||||
%tsort {
|
%tsort {
|
||||||
a b
|
a b
|
||||||
b a
|
b a
|
||||||
|
Loading…
Reference in New Issue
Block a user