The Microsoft® Shared Source implementation of the JScript compiler is
very similar to the implementation in the Microsoft® .NET Framework SDK and
Microsoft Visual
Studio® 2005. Both implementations originated from the same source base but some
options and features that rely on functionality in Microsoft® Windows® have been
removed from the Shared Source implementation.
To produce an executable JScript program, use the command-line compiler, jsc.exe.
You must have your environment configured correctly. For more information
on the Shared Source CLI environment configuration, see
env.html.
Please note, as the JScript compiler is a managed application, it needs to be run under the clix launcher. Eg. "clix jsc.exe Program1.js".
The following option areas and related options were modified:
Complete documentation for the .NET Framework JScript compiler and tutorials is available on msdn.microsoft.com. Other than the changes mentioned above, the functionality in the Shared Source implementation of the JScript compiler is the same as the .NET Framework implementation.
The JScript compiler produces executable (.exe) files and dynamic-link libraries (.dll files).
JScript is a managed application. To execute managed
applications you must use the clix application launcher.
Every compiler option is available in two forms: -option and /option.
Option | Description | |
---|---|---|
@response_file | Specifies a response_file which is a file that lists compiler options or
source code files to compile. The @ option lets you specify a file that contains compiler options and source code files to compile. These compiler options and source code files will be processed by the compiler just as if set out on the command line. To specify more than one response file in a compilation, specify multiple response file options. For example: @file1.rsp @file2.rsp In a response file, multiple compiler options and source code files can appear on one line. A single compiler option specification must appear on one line (it cannot span multiple lines). Response files can have comments that begin with the # symbol. Specifying compiler options from within a response file is just like making those commands on the command line. The compiler processes command options as they are encountered. Therefore, the options in one response file might be incompatible with the options in another response file or the command line options. This can generate errors. Response files cannot be nested. You cannot place @response_file inside a response file. The JScript compiler reports an error for such cases. For example, the following are a few lines from a sample response file: # build the first output file /target:exe /out:MyExe.exe source1.js source2.js |
|
/? | Outputs compiler options to console. Equivalent to
/help. This option causes the compiler to display a list of compiler options along with a brief description of each option. |
|
/autoref[+ | -] | References assemblies automatically if they have the same name as an imported namespace or as a
type annotation when declaring a variable. Option Values
The /autoref option instructs the compiler to reference assemblies without having to pass the assembly to /reference. When you use import to import a namespace, or you use a fully qualified type name in your code, the JScript compiler searches for an assembly that contains the type. See /lib for a discussion of how the JScript compiler searches for assemblies. The compiler does not try to reference an assembly if it has the same name as the output file of the program you are building. The following program will compile and run when /autoref+ is in effect; the compiler will reference System.dll as a result of the type annotation when declaring a variable. var s: System.Collections.Specialized.StringCollection = new System.Collections.Specialized.StringCollection(); print(s); The following program will compile and run when /autoref+ is in effect; the compiler will reference System.dll as a result of the import statement. import System; var s = new System.Collections.Specialized.StringCollection(); print(s); These examples also show how the compiler looks for assembly names based on type annotation or import statements. When the compiler did not find an assembly called System.Collections.Specialized.dll that contained StringCollection, it looked for System.Collections.dll. Failing to find that file, it looked for System.dll, which it did find to contain StringCollection. |
|
/codepage:id | Specifies the code page to use for all source code files in the
compilation where id is the ID of that code page. If you compile one or more source code files that when created did not designate use of the default code page on your computer, you can use the /codepage option to specify which code page should be used. /codepage applies to all source code files in your compilation. If the source code files were created with the same codepage that is in effect on your computer or if the source code files were created with UNICODE or UTF-8, you need not use /codepage. |
|
/debug[+|-] | Emits debugging information. | |
/define:name1 [=value1][,name2[=value1]] |
Defines preprocessor symbols where name1 and name2 are
the name of one or more symbols that you want to define and value1 and value2
are the values for the symbols to take. These can be Boolean values or numbers. The /define option defines names as symbols in your program. You can define multiple symbols with /define by using a comma to separate symbol names. For example: /define:DEBUG,trace=true,max_Num=100 /d is the short form of /define. Compile with /define:. print("testing") /*@cc_on @*/ /*@if (@xx) print("xx defined") @else @*/ print("xx not defined") /*@end @*/ |
|
/fast[+ | -] | Produces an output file optimized for speed but that does not support certain language features from previous releases. JScript source code from versions before the .NET Framework might need to be
modified to compile with this option switched on. Option values:
When /fast is in effect:
|
|
/help | Outputs compiler options to the console. Equivalent to /?. This option causes the compiler to display a list of compiler options along with a brief description of each option. |
|
/lcid:id | Specifies acode page for compiler messages where id is the ID of the code page to use for printing out messages from the compiler. | |
/lib:dir1[, dir2] | Specifies the location of assemblies referenced
through the /reference option.
Option values:
The /lib option specifies the location of assemblies referenced through the /reference option. The compiler searches for assembly references that are not fully qualified in the following order:
Use /reference to specify an assembly reference. /lib is additive; specifying it more than once appends to any prior values. For example, compile t2.js to create an .exe. The compiler will look in the working directory and in the root directory of the C drive for assembly references. jsc /lib:c:\ /reference:t2.dll t2.js |
|
/linkresource:filename [,name[,public|private]] |
Creates a link to a managed resource.
Option values:
The /linkresource option does not embed the resource file in the output file. Use the /resource option to embed a resource file in the output file. If filename is a managed resource created by the Resource File Generator, for example, it can be accessed with members in the System.Resources namespace. /linkres is the short form of /linkresource. For example, compile in.js and link to resource file rf.resource: jsc /linkresource:rf.resource in.js |
|
/nologo |
The /nologo option suppresses display of the banner when the compiler starts. |
|
/nostdlib[+ | -] | Does not import standard library (mscorlib.dll).
Option values:
Specifying /nostdlib+ also specifies /autoref-. For example, if you have a component called System.String (or any other name in mscorlib) could only access your component using /nostdlib /r:your_library,mscorlib to search your library before mscorlib. Typically, you would not define a namespace in your application called System. |
|
/out:filename | Specifies output file name where filename is the name of
the output file created by the compiler. The /out option specifies the name of the output file. The compiler expects to find one or more source code files following the /out option. If you do not specify the name of the output file:
On the command line, it is possible to specify multiple output files for a compilation. All source code files specified after an /out option will be compiled into the output file specified by that /out option. Specify the full name and extension of the file you want to create. The extension must be either .exe or .dll. It is possible to specify a .dll extension for /t:exe projects. For example, compile t2.js, create output filet2.exe, and build t3.js and create output file t3.exe: jsc t2.js /out:t3.exe t3.js |
|
/print[+ | -] | Specifies whether the print statement is available.
Option values:
You should use /print- if your DLL will be loaded into an environment that does not have a console. You can set Microsoft.JScript.ScriptStream.Out to be an instance of a TextWriter object to enable print to send output elsewhere. |
|
/reference:file[;file2] | Imports the information in the metadata of the referenced
assembly for use in resolving external references where file and file2
are one or more files that contains an assembly manifest.
To import more than one file, separate file names with either a comma or a semicolon. The /reference option directs the compiler to make public type information in the specified files available to the project you are currently compiling. The file or files you reference must be assemblies. /reference cannot take a module as input. Although executable files can be referenced as assemblies it is not recommended that shared, referenced code be stored in executable assemblies. Instead, place the shared code in an assembly library. If you reference an assembly (Assembly A), which itself references another assembly (Assembly B), you will need to reference Assembly B if:
Use /lib to specify the directory in which one or more of your assembly references is located. /r is the short form of /reference. For example, compile source file jsc /reference:metad1.dll;metad2.dll /out:out.exe input.js |
|
/resource:filename [,name[,public|private]] |
Embeds a managed resource in an assembly. Option values:
Use the /resource option to link a resource to an assembly and not place the resource file in the output file. If filename is a managed resource file created, for example, by Resgen, it can be accessed with members in the System.Resources namespace. For more information, see System.Resources.ResourceManager. /res is the short form of /resource. For example, compile jsc /res:rf.resource in.js |
|
/target:output_type | Causes a .NET Framework assembly manifest to be placed in a specified type of binary output file. If you create an assembly, you can indicate that all or part of your code is CLS-compliant with the CLSCompliantAttribute class attribute. import System; [assembly:System.CLSCompliant(true)] // Specify assembly compliance. System.CLSCompliant(true) class TestClass // Specify compliance for element. { var i: int; }output_type specifies the format of the output file using one of three options: |
|
/target:exe | Creates a console .exe file.
The /target:exe option causes the compiler to create an executable (EXE), console application. The /target:exe option is in effect by default. The executable file will be created with the .exe extension. Unless otherwise specified with the /out option, the output file name takes the name of the first source code file in the compilation for each output file. When specified at the command line, all files up to the next /out or /target:library option are used to create the .exe. The /target:exe option is in effect for all files following the previous /out or /target:library option. |
|
/target:library | Creates a code library (DLL). The /target:library option causes the compiler to create a DLL rather than an EXE. The DLL will be created with the .dll extension. Unless otherwise specified with the /out option, the output file name takes the name of the first input file. When specified at the command line, all source files up to the next /out or /target:exe option are used to create the DLL. |
|
/target:winexe | Creates an
executable Windows GUI application. The executable file will be created
with the .exe extension. This sets the subsystem information in the portable
executable (PE) file,
which is used by Windows to determine some execution characteristics
of the application. This information is ignored by the Shared Source implementation of the CLI. However, if the application is executed under the .NET Framework, this option will have an effect on the Windows loader. For more information on the
console or Windows subsystem setting see msdn.microsoft.com and search for
"console subsystem". |
|
/utf8output[+ | -] | Displays compiler output using UTF-8 encoding. Option values:
In some international configurations, compiler output cannot correctly be displayed to the console. In these configurations, use /utf8output and redirect compiler output to a file. The default for this option is /utf8output-. Specifying /utf8output is equivalent to specifying /utf8output+. |
|
/versionsafe[+ | -] | Ensures that all overrides are explicit. Option values:
Use the hide or override keywords to explicitly indicate the override status of a method. For example, the following code will generate an error when compiled with /versionsafe: class c { function f() { } } class d extends c { function f() { } } |
|
/warn:option | Sets a warning level where option is the
minimum warning level you want displayed for the build.
The /warn option specifies the warning level for the compiler to display. The compiler always displays errors. /w is the short form of /warn. Valid values are 0-4. |
|
Warning level | Meaning | |
0 | Turns off emission of all warning messages; displays errors only. | |
1 | Displays errors and severe warning messages. | |
2 | Displays all errors and level 1 warnings plus certain, less-severe warnings, such as warnings about hiding class members. | |
3 | Displays errors and level 1 and 2 warnings, plus certain, less-severe warnings, such as warnings about expressions that always evaluate to true or false. | |
4 | Displays all errors and level 1-3 warnings, plus informational warnings. This is the default warning level at the command line. | |
/warnaserror[+ | -] | Promotes warnings to errors.
Any messages that would ordinarily be reported as warnings are instead reported as errors. No output files are created. The build continues in order to identify as many errors and warnings as possible. By default, /warnaserror- is in effect, which causes warnings to not prevent the generation of an output file. /warnaserror, which is equivalent to /warnaserror+, causes warnings to be treated as errors. Use /warn to specify the level of warnings that you want the compiler to display. |
clix jsc File.js
clix jsc /target:library File.js
clix jsc /out:My.exe File.js
test.js
and creates a DLL:
clix jsc /target:library test.js
Copyright (c) 2006 Microsoft Corporation. All rights reserved.