Sign in Join
Wiki copytemporary

Using Lazarus for other computer languages: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Using Lazarus for other computer languages

OldNewLine
1+Lazarus is great for Free Pascal. But you can use the IDE for other languages too. This is useful to port C code or to edit cross multi tier applications, without the need to use different editors and reducing the trouble when switching between different sets of shortcuts and menu entries.
2+
3+# Syntax Highlighting
4+
5+Lazarus comes with syntax highlighting for more than a dozen languages. The language is guessed from the file extension. The colors can be setup in the editor options.
6+
7+If your language is not yet there, you can either use one of the existing highlighters by extending the list of file extensions in the editor options. Or you can create your own highlighter and send us the new highlighter. The easiest way to create a new highlighter is to copy an existing file in lazarus/components/synedit/. The highlighter units all begin with 'synhighlighter', for example synhighlighterphp.pp is the php highlighter.
8+
9+Hint: You can quick switch the syntax highlighter for a file via the popup menu of the source editor. Just right click / file settings / highlighter.
10+
11+# Compilation
12+
13+To setup the compile command there are three possibilities:
14+
15+## 1. Create a new shortcut
16+
17+You can create a new shortcut and a menu item, that starts an external program with Tools / Configure Custom Tools / Add.
18+
19+For example to invoke 'make' to compile via Makefile:
20+
21+- Title: Build via make
22+- Programfilename: \$MakeExe(make)
23+- Parameters:
24+- Working Directory: \$ProjPath()
25+- Options: all disabled
26+- Key: choose one or leave untouched
27+
28+The **MakeExe** macro function appends the file extension '.exe' under windows. The **ProjPath** macro is replaced by the current project directory - the directory where the .lpi file is.
29+
30+### Pros
31+
32+- Works for all projects. No need to setup for every new project.
33+
34+### Cons
35+
36+- The same command and parameters for all projects. Individuality must be achieved by calling a script.
37+
38+## 2. Replace the compile command of the project
39+
40+When you press F9 or Ctrl-F9 the IDE checks if something has changed and invokes the compiler. The compiler is normally FPC, but you can replace that with a command of your choice.
41+
42+Open Project / Compiler Options / Compilation. Then disable in the *Compiler* box all options **Compile**, **Build** and **Run**. Then write the new command in the *Execute before* box and enable **Show all messages**.
43+
44+For example to invoke 'make' to compile via Makefile:
45+
46+\$MakeExe(make)
47+
48+The **MakeExe** macro function appends the file extension '.exe' under windows. The working directory is always the project directory - where the .lpi file is.
49+
50+### Pros
51+
52+- Command is stored in the .lpi file, so project can easily be distributed and copied to other machines.
53+- Only invoked if a file is changed.
54+- Required Packages are auto compiled before.
55+
56+### Cons
57+
58+- Must be copied to every new project.
59+
60+## 3. Define a compile command for a single file
61+
62+Normally when pressing F9 or Ctrl-F9 the IDE compiles a project. But you can override this behavior for each file in a project via Run / Configure Build+Run file.
63+
64+This works pretty much like the two above examples.
65+
66+### Pros
67+
68+- Good for mixed source projects. For example a pascal project with one or more files in another language.
69+- These settings are stored for pascal sources as IDE directives directly in the pascal source and since lazarus 0.9.25 for non pascal files it is stored in the project (.lpi file).
70+
71+### Cons
72+
73+- No update check. The called script/compiler must check itself if a build is needed.
74+
75+## See Also
76+
77+- [[LCL Bindings]]
78+
79+---
80+*From the Free Pascal wiki, page "Using Lazarus for other computer languages", as it stood on 2015-08-21 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
81+Category: Lazarus

Back to history