Commit graph

509 commits

Author SHA1 Message Date
Moritz Lell
0d8d19437e Set file descriptor as inheritable for all pythons >=3.4
This is mandated by PEP 446
2019-10-30 21:28:49 +01:00
Moritz Lell
62845688e5 Unify print function usage for Python 2 and 3 via __future__ import 2019-10-30 21:28:49 +01:00
Moritz Lell
491040ea72 Run 2to3 utility 2019-10-30 19:58:12 +01:00
Moritz Lell
e8d4809bc5 Remove python interpreter selection 2019-10-30 19:58:12 +01:00
Avery Pennarun
b08b5efcef t/shelltest.od: Add a new preliminary test for IFS= behaviour.
Apparently in zsh (when in sh compatibility mode), IFS=/ will split
"/a/b/c/" into 5 parts ("", "a", "b", "c", ""). Other shells all seem
to agree that it's 4 parts ("", "a", "b", "c"). zsh seems maybe more
correct to me, but the majority rules, so we'll warn on it.

Meanwhile, we'll also fix the one place in minimal/do that failed due
to this oddity, since it's relatively easy to avoid.

Reported-by: shamrin@gmail.com
2019-07-24 03:27:12 -04:00
Avery Pennarun
262d272f29 t/103-unicode: workaround unicode normalization on newer macOS.
As named, the file would be extracted by git on macOS, then
(un)helpfully normalized by the macOS filesystem. After that,
"git clean -fdx" would delete the file, since it no longer
had the expected name, so git thought it wasn't part of its repo.

I considered pre-normalizing the filename, but a) that would break
on any future OS that normalizes differently; and b) that means we
won't test denormalized filenames. Instead, we'll remove the directory
from git, and create it from sh instead, then figure out what name
it got really created as, and then pass the "real" name to redo.
2019-07-24 03:27:04 -04:00
Avery Pennarun
bc9cc75bc6 Disable docker container test from toplevel 'redo test'
It's not reliable on all versions of docker, and we haven't had time to
fix it yet, so just turn it off. It's not essential to redo.

Reported-by: fcsmith@gmail.com
2019-07-24 03:27:04 -04:00
Avery Pennarun
8924fa35fa Oops, redo/whichpython.do would fail if python2.7 didn't exist. 2019-06-21 00:27:40 +09:00
Avery Pennarun
12b0d59b9f Merge remote-tracking branch 'origin/experimental/dockrepo'
* origin/experimental/dockrepo:
  docs/cookbook/container: update docker image builder.
2019-05-15 18:55:52 -07:00
Avery Pennarun
fb0a5bd69c Fix more problems with "/usr/bin/env python" picking python3.
Open files in 'rb' (read binary) mode to prevent useless default utf8
encoding in python3, without breaking python2 compatibility.

Reported-by: Tharre <tharre3@gmail.com>
2019-05-15 16:54:21 -07:00
Avery Pennarun
2e4d3d518e cookbook/container/default.sha256.do: use explicit close_fds=False.
Some people have /usr/bin/python as a link to python3. The script is
designed to work in either python2 or python3, but python3's subprocess
model defaults to close_fds=True, which closes the jobserver fds and
causes an error.  Explicitly force close_fds=False to get identical
behaviour on python2 and python3.

Reported-by: Tharre <tharre3@gmail.com>
2019-05-15 15:19:06 -07:00
Avery Pennarun
1ff5262124 redoconf/configure.sh: use "cmp -s" to silence output.
Eliminates this warning:
    $ mkdir out
    $ ../configure
    $ ../configure --prefix=/usr
    cmp: EOF on _flags after byte 33

Reported-by: compufreak@gmail.com
2019-05-15 14:12:26 -07:00
Avery Pennarun
4b01cdd9b5 Fix minor pylint warnings. 2019-05-13 23:08:51 +00:00
Avery Pennarun
5684142f11 redo-log: "(resumed)" lines didn't print as often as they should.
If we print a line indicating that we've started building a subprogram,
then that's an "interruption" of the detailed output of the current
program; we need to "resume" the current program's logs before printing
any new detailed information that comes through.
2019-05-13 22:58:42 +00:00
Avery Pennarun
642d6fa193 Unset CDPATH if it is set.
Apparently on some (probably buggy) platforms, when CDPATH is set, the
'cd' command will always print text to stdout.  This caused fail 122
and 123 in shelltest.od.

CDPATH is an interactive-mode option, so let's clear it when running
scripts.
2019-05-01 13:17:35 -04:00
Avery Pennarun
7238b370e4 builder.py: create temp log file in the same directory as the final one.
We're going to rename() it from the temp name to the final name, which
doesn't work across filesystems, so the safest option is to keep it in
the same directory.

Reported-by: spacefrogg@meterriblecrew.net
2019-03-12 00:03:34 -04:00
Avery Pennarun
e24e045a07 docs/cookbook/redoconf-simple: a simple redoconf C++ project.
This is a little simpler than the docs/cookbook/c project, which
doesn't actually have a doc yet because there was too much to explain.
I think I might make that a follow-on cookbook chapter, for people who
have read this simple one.

I think this doc is maybe a little too long; I intended it to be
"here's what you do to get started" but it turned into "here's what you
do to get started, and why it works, in excruciating detail." Not quite
sure how to fix.

(Also updated some other parts of the docs to refer to redoconf as a
real thing now instead of a "maybe someone should write this" thing.)
2019-03-06 03:05:04 -05:00
Avery Pennarun
7845f6ddde docs/cookbook/container: update docker image builder.
Apparently some newer docker versions crash if there is no "repository"
file in the resulting image.  Its syntax seems simple enough, described
in https://github.com/moby/moby/blob/master/image/spec/v1.md

Reported-by: Matthew Singletary <matt.singletary@gmail.com>
2019-03-05 21:49:36 -05:00
Avery Pennarun
2bea74df35 Work around ancient shells where >$3 does not implicitly quote $3.
Also add an entry in shelltest.od to reject any shell exhibiting that
bug.

Reported-by: Wayne Scott <wsc9tt@gmail.com>
2019-03-03 20:56:17 -05:00
Avery Pennarun
7895c947d5 shelltest.od: warning 84 (W84) triggered on *all* shells, not just posh.
I must have changed this at the last minute when adding it, but I don't
know why.  We were redefining f4() inside a subshell, so it never
applied to the parent shell, so it was always considered a failure.
But that's not what we were supposed to be testing.

This is just supposed to be a test of the really rare syntax of
defining a function without enclosing braces, which only fails on posh,
as far as I've seen.
2019-03-03 20:55:48 -05:00
Avery Pennarun
0dcc685739 Minor clarifications to redo install instructions.
Reported-by: @DRMacIver on twitter
2019-03-03 19:35:32 -05:00
Avery Pennarun
cead02bd21 redo-log: sometimes print a (resumed) line after ending a level of recursion.
If A calls B, and B produces stderr output, and then A wants to produce
output, the resulting log would be confusing: we'd see 'redo A' and
then 'redo B' and then B's output, but no indicator that B has ended
and we're back in A.  Now we show 'redo A (resumed)' before A's output.

If B didn't produce any output, or A doesn't produce any output, we
don't bother with the (resumed) line.  This seems nice, as it doesn't
clutter the log when there is no ambiguity anyway.
2019-03-02 19:08:47 -05:00
Avery Pennarun
b196315222 Change -x/-v to only affect top-level targets by default, not recursively.
Because redo targets are nicely isolated (unlike make targets), you
usually only want to debug one of them at a time.  Using -x could be
confusing, because you might end up with a dump of output from a
dependency you're not interested in.

Now, by default we'll disable -x when recursing into sub-targets, so
you only see the trace from the targets you are actually trying to
debug.  To get recursive behaviour, specify -x twice, eg. -xx.

Same idea with -v.
2019-03-02 18:46:00 -05:00
Avery Pennarun
7b4e3326bd logs.py: don't print (unchanged) lines with --no-log unless DEBUG.
This accidentally made output look different with --no-log vs with
normal redo-log output, because redo-log has a -u option while plain
redo does not.

(This is on purpose.  When running redo, you only want to see the things
that actually happened, so it never passes -u to the auto-launched
redo-log instance.  But when reviewing logs later, you might want to
look at the past logs from building a component that was unchanged in
the most recent run.)
2019-03-02 18:41:37 -05:00
Avery Pennarun
3071d13416 Merge branch 'redoconf'
* redoconf:
  redoconf: a stub rc_include() now sources ./redoconf.rc automatically.
  redoconf: assorted minor fixes.
  redoconf: move -Wl,-rpath flags to shlib.rc and add -Wl,-z,origin.
  mkdocs: don't bother to include cookbook/c/out.*/ dirs.
  docs/cookbook/c/allconfig.do: avoid need for '&' backgrounding.
  Precompiled headers: supply "-x c-header" or "-x c++-header" if available.
  minimal/do: remove dependency on 'seq' command.
  Fix some build problems on MacOS X.
  redoconf: posix.rc: fix abort when timespec is not available.
  redoconf: better handling of required vs optional detectors.
  redoconf: clock_gettime() detection needs to depend on -lrt.
  redoconf: avoid sed -E in _objlist().
  Experimental new redoconf C/C++ build/autoconfiguration system.
2019-03-02 04:32:07 -05:00
Avery Pennarun
1a3c11f220 redoconf: a stub rc_include() now sources ./redoconf.rc automatically.
This lets us remove the awkward ". ./redoconf.rc" line from zillions
of .od scripts, without paying the price of *always* including that
whole file every time default.do.sh is used.
2019-03-02 04:24:58 -05:00
Avery Pennarun
49f85f2156 redoconf: assorted minor fixes.
- libqt4.rc: add detection of the 'moc' command in $MOC.
- libssl.rc: add detection script for openssl.
- default.do.sh: provide a die() function to all .od files.  It's just
  too useful to not have it (I haven't converted everything to it yet).
- When building out/x/y.z, match against $S/default.z.od and
  $S/default.od if they exist.
- *.list files (lists of source/object files to include in a binary)
  can now contain *.o files in addition to *.c, *.cc, etc.
- rename compile() to _compile() to avoid polluting the namespace for
  scripts called from default.do.sh.
- When building a .so file in the top level directory, no need to
  make a symlink of it into the top level directory.
- link.od and link-shlib.od forgot to make use of the $xLIBS variable.
2019-03-02 04:12:25 -05:00
Avery Pennarun
1e2fc9be8a Merge branch 'master' into redoconf
* master:
  builder.py: atomically replace the log for a given target.
  redo-ifchange regression: if REDO_LOG is not set, assume it's 1.
  Explicitly reject target/source filenames with newlines in them.
  If redo searched all the way up to /default.do, it would run ./default.do instead.
  Overridden files were accidentally getting reclassified as static.
  Certain redo post-build failures would still mark a target as built.
  minimal/do: remove dependency on 'seq' command.
2019-03-02 04:09:17 -05:00
Avery Pennarun
63230a1ae3 builder.py: atomically replace the log for a given target.
Previously we were truncating the log if it existed.  This would cause
redo-log to produce invalid output if you had the following (admittedly
rare) sequence in a single session:
- start building X
- redo-log starts showing the log for X
- finish building X
- redo-log has not finished showing the log for X yet
- start building X again for some reason
- redo-log sees a truncated logfile.

Now, redo-log can finish reading the original file (which no longer has
a filename since it was overwritten) while the new file is being
created.
2019-03-02 04:05:36 -05:00
Avery Pennarun
8a97b0cb2c redo-ifchange regression: if REDO_LOG is not set, assume it's 1.
At some point this got broken during a refactoring.  The result was
that redo-ifchange, run from the command line (as opposed to inside a
.do script) would fail to start the log prettifier.
2019-03-02 04:05:36 -05:00
Avery Pennarun
83bc49512f Explicitly reject target/source filenames with newlines in them.
This avoids an ugly assertion failure when we try to log a message
containing an inner newline.
2019-03-02 04:05:36 -05:00
Avery Pennarun
e5a27f04e8 If redo searched all the way up to /default.do, it would run ./default.do instead.
This only happened if the containing project was buggy, ie. you tried
to build a target that has no .do file available anywhere. However, it
resulted in a confusing outcome for that case, where we'd run the wrong
default.do file with the wrong parameters.

Extended an existing test to catch this mistake.
2019-03-02 04:05:36 -05:00
Avery Pennarun
90989d1ffb Overridden files were accidentally getting reclassified as static.
This is relatively harmless, since we treat them *almost* identically,
except that we print a warning for overridden files to remind you that
something fishy is going on.

Add a test for the actual warning message to ensure it is printed.  (I
don't like tests for specific warning messages, but it was necessary in
this case.)
2019-03-02 04:05:36 -05:00
Avery Pennarun
8100aa4973 Certain redo post-build failures would still mark a target as built.
If we failed because:
- target dir doesn't exist
- failed to copy from stdout
- failed to rename $3

We would correctly return error 209, but the target would still be
marked as having been built, so redo-ifchange would not try to build it
next time, beause we forgot to call sf.set_failed() in those cases.

minimal/do worked correctly.

Added a test to catch this in the future.
2019-03-02 04:05:36 -05:00
Avery Pennarun
8a0effa5b3 minimal/do: remove dependency on 'seq' command.
It was not available in older versions of FreeBSD and MacOS.

Reported-by: Wayne Scott <wsc9tt@gmail.com>
2019-03-02 04:05:35 -05:00
Avery Pennarun
88250334da redoconf: move -Wl,-rpath flags to shlib.rc and add -Wl,-z,origin.
It was kind of ugly to have this kind of special flag directly in
link.od; now we detect whether it's available.  This also gives a
project the ability to override the flag in some other way if they
want.

As a result, rc/shlib.rc needs to be included in all.rc.od if you want
to create or link against shared libraries.

While we're here, also add -Wl,-z,origin on platforms where it works.
This is apparently needed for FreeBSD 8.0 at least, and probably other
platforms.

Reported-by: Wayne Scott <wsc9tt@gmail.com>
2019-03-01 13:55:22 -05:00
Avery Pennarun
1eb7b2879d mkdocs: don't bother to include cookbook/c/out.*/ dirs. 2019-03-01 13:55:22 -05:00
Avery Pennarun
e036e2522d docs/cookbook/c/allconfig.do: avoid need for '&' backgrounding.
Instead of running a bunch of separate rc_include statements in the
background, which causes unpredictable ordering of log output and
prevents -j from controlling parallelism, let's do a single
redo-ifchange for all of them (the slow part) followed by sequentially
checking the results (the fast part).
2019-03-01 13:55:22 -05:00
Avery Pennarun
1574b11598 Precompiled headers: supply "-x c-header" or "-x c++-header" if available.
Some older versions of gcc give "all.hpp: linker input file unused
because linking not done" otherwise, because they don't realize files
named *.hpp are headers.

Reported-by: Wayne Scott <wsc9tt@gmail.com>
2019-02-25 13:09:11 +00:00
Avery Pennarun
313ac6a51c minimal/do: remove dependency on 'seq' command.
It was not available in older versions of FreeBSD and MacOS.

Reported-by: Wayne Scott <wsc9tt@gmail.com>
2019-02-24 22:37:06 -05:00
Avery Pennarun
328d4ead7a Fix some build problems on MacOS X.
- Linking shared libraries needs slightly different options.

- We were trying to detect mach_time.h but needed to detect
  mach/mach_time.h instead.

While we're here, add a --disable-shared option to ./configure, which
is different from --enable-static.  --disable-shared does not build
*new* share libraries, but doesn't pass -static to the linker
(apparently there is no static linking posible on MacOS).
2019-02-24 22:29:19 -05:00
Avery Pennarun
017997c035 redoconf: posix.rc: fix abort when timespec is not available.
Now we define HAS_POSIX=1 if it works, and to blank otherwise, to be
consistent with other rc scripts, but it doesn't abort if we can't find
timespec.

Meanwhile, slightly clarify the error message in rc.sh.

Reported-by: Nathaniel Filardo <nwfilardo@gmail.com>
2019-02-23 21:00:26 -05:00
Avery Pennarun
bdb8d8a27d redoconf: better handling of required vs optional detectors.
CC.rc was the only "mandatory" detection, which was weird and
inconsistent.  Instead, make it optional like the others, and have it
set a HAVE_CC variable appropriately (and have CXX.rc work the same
way).  Then, add a default.required.rc.od that checks the HAVE_* for
any variable and aborts if it is not available.

This allows us to fix confusing behaviour in allconfig.do, which would
try every compiler on the system, but redo would print a (non-fatal)
error message (and prevent redo-stamp optimization) when CC.rc failed
for any non-working compilers.  Now CC.rc just politely reports that it
didn't find a compiler.  Then we change all.rc.od to make CC.rc
mandatory.

Reported-by: Nathaniel Filardo <nwfilardo@gmail.com>
2019-02-23 16:51:25 -05:00
Avery Pennarun
337e026ce3 redoconf: clock_gettime() detection needs to depend on -lrt.
More generally, default.func.rc.od wasn't super useful because you
couldn't specify either a header file or library dependencies.  Drop it
and make an explicit clock_gettime.rc.od.  As a bonus, this also checks
that CLOCK_MONOTONIC exists as expected.

Reported-by: Wayne Scott <wsc9tt@gmail.com>
2019-02-23 15:51:30 -05:00
Avery Pennarun
ea6a7135f1 redoconf: avoid sed -E in _objlist().
Turns out there's a less confusing way to do it using 'case' wildcards
instead.

Reported-by: Wayne Scott <wsc9tt@gmail.com>
2019-02-23 15:44:46 -05:00
Avery Pennarun
6dae51f4d2 Experimental new redoconf C/C++ build/autoconfiguration system.
To test it out, try this:
	./do -j10 build
	cd docs/cookbook/c
	redo -j10 test

It should detect all the compilers on your system and make three
separate builds for each one: normal, debug, and optimized.  Then it
tries to run a test program under each one.

If there are windows cross compilers and you also have 'wine'
installed, it'll try running the test program under wine as well.

redoconf currently has no documentation other than the example program.
We'll fix that later.
2019-02-23 06:52:25 -05:00
Avery Pennarun
5db883ac58 mkdocs: exclude more generated file types.
These files can appear/disappear during a parallel build, which
confuses mkdocs when it tries to refer to them, even though we never
wanted them in the docs anyway.
2019-02-23 06:48:24 -05:00
Avery Pennarun
e7ea1e651d Merge remote-tracking branch 'origin/master'
* origin/master:
  Fix builder: Reinstate stderr instead of opening /dev/tty
2019-02-23 00:42:29 -05:00
Avery Pennarun
cb60966d9e mkdocs: exclude more generated files from cookbook/container. 2019-02-20 19:18:02 -05:00
Avery Pennarun
938c6c65c4 cookbook/container/kvm: better handling of \r\n line endings. 2019-02-20 19:14:37 -05:00