digitalmars.D - Using DMD's -v to build dependencies
- Sergey Gromov (29/29) Dec 12 2008 After some twitting ;) here's my Windows shell script (a .cmd file)
- Bill Baxter (4/33) Dec 12 2008 So how fast is dmd -o-? Does this pretty much double the compile time?
- Sergey Gromov (13/15) Dec 13 2008 Here's the benchmark.
- Bill Baxter (7/22) Dec 13 2008 Excellent, thanks for collecting and reporting that data, Sergey.
After some twitting ;) here's my Windows shell script (a .cmd file) which can effectively replace bud/rebuild in some simple cases. This script makes use of GNU grep and sed. Both are available from GnuWin32 or Cygwin or as separate ports. file "sbd.cmd" ---8<------------------- :: Build a D program including any dependencies :: 2008, Sergey 'SnakE' Gromov <snake.scaly gmail.com> echo off setlocal if "%1" == "" ( echo Build a D program with all dependencies echo Usage: %0 master [options] echo master master source, root of the import hierarchy echo options any options are forwarded to DMD exit /b 1 ) set DEP=dependencies.tmp :: generate dependencies dmd %* -c -o- -v | grep "^import" | grep -v "phobos\|tango\|\.di)" | sed "s/^.*(\(.*\)).*$/\1/" > %DEP% :: compile dmd %* %DEP% || goto error :: cleanup del %DEP% exit /b 0 :error del %DEP% exit /b 1 ---8<-------------------
Dec 12 2008
So how fast is dmd -o-? Does this pretty much double the compile time? An option to reuse a previously generated .deps might be nice. --bb On Sat, Dec 13, 2008 at 7:18 AM, Sergey Gromov <snake.scaly gmail.com> wrote:After some twitting ;) here's my Windows shell script (a .cmd file) which can effectively replace bud/rebuild in some simple cases. This script makes use of GNU grep and sed. Both are available from GnuWin32 or Cygwin or as separate ports. file "sbd.cmd" ---8<------------------- :: Build a D program including any dependencies :: 2008, Sergey 'SnakE' Gromov <snake.scaly gmail.com> echo off setlocal if "%1" == "" ( echo Build a D program with all dependencies echo Usage: %0 master [options] echo master master source, root of the import hierarchy echo options any options are forwarded to DMD exit /b 1 ) set DEP=dependencies.tmp :: generate dependencies dmd %* -c -o- -v | grep "^import" | grep -v "phobos\|tango\|\.di)" | sed "s/^.*(\(.*\)).*$/\1/" > %DEP% :: compile dmd %* %DEP% || goto error :: cleanup del %DEP% exit /b 0 :error del %DEP% exit /b 1 ---8<-------------------
Dec 12 2008
Sat, 13 Dec 2008 07:37:18 +0900, Bill Baxter wrote:So how fast is dmd -o-? Does this pretty much double the compile time? An option to reuse a previously generated .deps might be nice.Here's the benchmark. I'm compiling dwt-samples\examples\helloworld\HelloWorld5.d from dwt trunk rev. 119, without any pre-compilation. The system is a 1.83 GHz Core2 Duo notebook under Win XP. The compiler is DMD 1.033/Tango. The -c -o- -v stage takes 0.97 seconds (best of five, all files in memory, no swap). The result is a list of 202 files in win-dwt. That's more than a half of dwt (357 .d files). The actual build phase takes 3.27 seconds, best of five, etc. The result is a working 1.7 MB executable. So the -v phase is at least 3 times faster than the actual compilation. Also note that in -o- mode the compiler misses some semantic errors which means it doesn't do full analysis.
Dec 13 2008
Excellent, thanks for collecting and reporting that data, Sergey. So it's not too bad, but still that says to me that caching dependencies would be beneficial for bigger programs. But anyway, you it would certainly be hard to beat your script in terms of simplicity. Cached dependencies can be left as an exercise for the reader. :-) --bb On Sun, Dec 14, 2008 at 3:35 AM, Sergey Gromov <snake.scaly gmail.com> wrote:Sat, 13 Dec 2008 07:37:18 +0900, Bill Baxter wrote:So how fast is dmd -o-? Does this pretty much double the compile time? An option to reuse a previously generated .deps might be nice.Here's the benchmark. I'm compiling dwt-samples\examples\helloworld\HelloWorld5.d from dwt trunk rev. 119, without any pre-compilation. The system is a 1.83 GHz Core2 Duo notebook under Win XP. The compiler is DMD 1.033/Tango. The -c -o- -v stage takes 0.97 seconds (best of five, all files in memory, no swap). The result is a list of 202 files in win-dwt. That's more than a half of dwt (357 .d files). The actual build phase takes 3.27 seconds, best of five, etc. The result is a working 1.7 MB executable. So the -v phase is at least 3 times faster than the actual compilation. Also note that in -o- mode the compiler misses some semantic errors which means it doesn't do full analysis.
Dec 13 2008