www.digitalmars.com Home | Search | CTG | RTL | IDDE | STL
Last update Sun Oct 14 09:46:24 2007
Compiler & Tools Guide

Compiling
Compiling Code
C Implementation
C++ Implementation
Language Extensions
Mixing Languages
Assembly Language
Inline Assembler
Optimizing Code
Numerics Programming
Regular Expressions
Acrtused
Pragmas
Precompiled Headers
Predefined Macros
Warning Messages
Error Messages
Runtime Messages


Linking
Optlink
Switches
Module Definition Files
Operation and Design
Error Messages


Win32 Programming
Win32 Programming


DOS and Win16
Programming

Memory Models
16 Bit Pointer Types
and Type Modifiers

Handle Pointers
DOS
DOS 32 (DOSX)
Win16
Win16 DLLs
Win16 Prolog/Epilog


C/C++ Extensions
Contract Programming
__debug statement
__debug declaration
Dynamic Profiling
Embedding C in HTML


Tools
BCC
CHMOD
CL
COFF2OMF
COFFIMPLIB
DMC
DIFF
DIFFDIR
DUMP
DUMPOBJ
DUMPEXE
EXE2BIN
FLPYIMG
GREP
HC
IMPLIB
LIB
LIBUNRES
MAKE
MAKEDEP
ME
OBJ2ASM
PATCHOBJ
RC
RCC
SC
SHELL
SMAKE
TOUCH
UNMANGLE
WHEREIS


Porting to DMC++
Switching to DMC++
from Microsoft
from Borland
Porting Guide


SHELL: Run scripts

shell is an unusual script runner. It's unique properties make it much superior than commonly used batch files:
  • Use of NAME=VALUE style macros, from the command line and embedded in the script file, in a manner equivalent to make.
  • Simplified exit status handling.
  • Grouping related commands into groups which can be executed multiple times.
  • Repeated execution of groups based on combinatorial permutations of the arguments to it.
Script files are text files with a .sh extension, consisting of a sequence of lines. Lines are \ line spliced. Each line is one of:
Blank Line
nothing on the line
Comment Line
first non-blank character is a #
Macro Line
line of the form NAME=VALUE
Command Line
a command to be executed
Blank lines are used to separate command lines into groups. Groups of commmand lines are executed multiple times, once for each combination of options. Comment and macro lines are not group separators.

Commands can be prefixed with a special character to control how it is executed (just like makefiles for make):

+ Force use of COMMAND.COM or CMD.EXE to execute the rule. This is useful for .BAT files or commands using I/O redirection.
- Ignore exit status from this rule.
% Exit status must be non-zero.
@ Do not echo this rule when it's executed.
* Use _CMDLINE environment variable to pass long command lines.

Macros are expanded like in make, i.e. one letter macros are expanded by $M, multi-letter macros by $(ABC).

Options are specified as lists of | separated choices enclosed by parentheses, such as:

	del *.(c|h)
	
means execute the command twice, once using the c and the other time using the h. Blank options, like (c|), are allowed. Multiple options can be used:
	dir *.(c|) /(w|d)
	
will execute the command 4 times with:
	dir *.c /w
	dir *. /w
	dir *.c /d
	dir *. /d
	
The substitutions are stored as numbered macros, and are available for expansion in the subsequent lines in the group as well:
	dmc -m(s|n) test (-g|-o)
	link lib$1
	
causes these to be executed:
	dmc -ms test -g
	link libs
	dmc -mn test -g
	link libn
	dmc -ms test -o
	link libs
	dmc -mn test -o
	link libn
	

Command Line Switches

Shell is invoked by:
	shell filename.sh { macro definitions }
	
If no filename.sh is given, shell looks for and runs test.sh.

macro definitions are of the form NAME=VALUE.

Bugs

  • options should nest
  • macros should nest
  • no escaping of ( or |
  • no quoting
  • command line macro definitions should override definitions in the text file