Difference between revisions of "pas2js.cfg"

From Free Pascal wiki
Jump to navigationJump to search
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
= Locations =
 
= Locations =
  
You can see where pas2js searches for its cfg file and what it finds using the command line parameter '''-vt'''.
+
You can see where [[pas2js|pas2js]] searches for its cfg file and what it finds using the command line parameter '''-vt'''.
  
 
On Unix (Linux, MacOS, BSD) pas2js searches
 
On Unix (Linux, MacOS, BSD) pas2js searches
Line 9: Line 9:
  
 
On Windows the compiler searches:
 
On Windows the compiler searches:
 +
* %HOME%\pas2js.cfg
 
* in the directory of the compiler binary. For example if pas2js is installed in ''C:\pascal\pas2js\bin\pas2js'', then it searches ''C:\pascal\pas2js\bin\pas2js.cfg''
 
* in the directory of the compiler binary. For example if pas2js is installed in ''C:\pascal\pas2js\bin\pas2js'', then it searches ''C:\pascal\pas2js\bin\pas2js.cfg''
  
Line 74: Line 75:
 
# end.
 
# end.
 
</pre>
 
</pre>
 +
[[Category:Pas2js]]

Revision as of 11:10, 9 March 2021

Locations

You can see where pas2js searches for its cfg file and what it finds using the command line parameter -vt.

On Unix (Linux, MacOS, BSD) pas2js searches

  • $HOME/.pas2js.cfg - note the dot at the beginning of .pas2js.cfg
  • in the directory of the compiler binary. For example if pas2js is installed in /usr/lib/fpc/3.0.4/bin/pas2js, then it searches /usr/lib/fpc/3.0.4/bin/pas2js.cfg
  • in /etc/pas2js.cfg

On Windows the compiler searches:

  • %HOME%\pas2js.cfg
  • in the directory of the compiler binary. For example if pas2js is installed in C:\pascal\pas2js\bin\pas2js, then it searches C:\pascal\pas2js\bin\pas2js.cfg

You can disable the search for the default config file using the parameter -n.

You can pass additional config files using the @ parameter. For example:

pas2js -n @/etc/pas2js.cfg

This will skip the default config file and parse /etc/pas2js.cfg.

Structure

  • Leading spaces and tabs are skipped.
  • Empty lines or lines only containing spaces are skipped
  • Lines beginning with # followed by a space or tab are comment lines
  • Lines beginning with #name are config directives:
    • #IFDEF define
    • #IFNDEF define
    • #IF expression - same as $if, except only defines
    • #ELSEIF
    • #ELSE
    • #ENDIF
    • #ERROR text
  • Other lines are treated as single parameters. For example -FuFol der is the same as passing "-FuFol der" as command line parameter.
  • Search paths (e.g. -Fu or -Fi) in config files are searched from top to bottom, while on the command line they are searched from right to left.
  • For defines see Compiler directives

Macros

  • $Pas2jsFullVersion - major.minor.release<extra>
  • $Pas2jsVersion - major.minor.release
  • $CfgDir - The directory of this config file
  • $Env - environment variable, e.g. $Env(HOME)

You can see the supported macros running pas2js -h

Examples

Here is a typical pas2js.cfg file:

#
# Minimal config file for pas2js compiler
#
# -d is the same as #DEFINE
# -u is the same as #UNDEF
#
# Write always a nice logo ;)
-l

# Display Warnings, Notes and Hints
-vwnh
# If you don't want so much verbosity use
#-vw

-Fu$CfgDir/../../packages/*
-Fu$CfgDir/../../compiler/utils/pas2js/dist/

#IFDEF nodejs
-Jirtl.js
#ENDIF

# Put all generated JavaScript into one file
-Jc

# end.