casteng / i-pascal

A free Object Pascal language plugin for IntelliJ IDEA
112 stars 33 forks source link

How to Import Delphi Project #43

Closed aadog closed 5 years ago

aadog commented 5 years ago

How to Import Delphi Project,

I've tested a lot of solutions, and using the default configuration has the following problems

  1. Unit1 in'Unit1. pas'{Form1}; such a syntax would prompt Unit1. DCU can't find

  2. How to import existing dcu, such as vcl, does not seem to be able to parse dcu.

Can you come up with a tutorial to configure the Delphi project, preferably in Delphi 7 or Delphi Xe or Delphi 10.3

casteng commented 5 years ago
  1. You should mark all directories with source code as source in File > Project structure > Modules > Sources
  2. I-Pascal can't parse .dcu by itself but can use DCU32INT decompiler. To use it:
  3. Download and unzup the decompiler.
  4. Set path to the decompiler executable in your Delphi SDK settings in I-Pascal
  5. Add RTL DCU directories in Project structure > SDKs > [your delphi SDK] > classpath

I'll add more detailed tutorial to project site soon.

aadog commented 5 years ago

It seems that the current project management is very confusing and will not be compiled into the file at the dep of the module. I think we should adjust the directory. By the way, how can we replace dcc32 with dcc64?

casteng commented 5 years ago

Can you please clarify first two sentences? I didn't understood. As of dcc64 - currently you need change in SDK settings compiler command to full path of dcc64 and replace 32 bit RTL unit paths with 64-bit ones in classpath. In one of the nearest updates all targets will be imported automatically on SDK addition.

aadog commented 5 years ago

Sorry, my English is very poor. All the texts are completed by the translation work, so it may lead to your misunderstanding.

1. When using the project structure setting module -> project -> dependencies, the dependent project does not seem to be compiled into it.

2.When using the project structure to set the sdk -> classpath code to be compiled into it but an exception will occur:

Error:(7812, -1) Pascal builder: F1026 File not found: 'System.Variants'

3. It seems that the SDK always seems to be recognized as dcc32, how to make him recognize as dcc64

aadog commented 5 years ago
  1. It seems that DCU32INT has no effect after setting it. Can you get a simple example?

Thank you very much, this is a very good project, solved a lot of delphi code editor shortage

casteng commented 5 years ago
  1. In IDEA a module corresponding to what in Delphi called project. There is no such thing as compilation into a project. When a project file (.dpr) from a module with dependency is compiled, source directories of all dependent modules will be included in compiler's search path. As well as source path of the module itself. Completion works from all modules (regardless of dependencies) so you can create a module and add RTL sources here and mark all directories with sources as source in the module settings.
  2. This happens because directories specified in classpath of SDK is also added to compiler search path. And the compiler can't compile RTL sources unfortunately. So there should be directories with compiled (.dcu) versions of RTL files.
  3. In SDK settings you can see the following fields: image To setup dcc64 you have to set:
    • "Compiler command" (marked as "1") - there should be path to dcc64 executable
    • "Classpath" (marked as "3") - there should be directory containing compiled RTL x64 units. E.g. c:\delphi\20.0\lib\win64\release
  4. To setup DCU32INT you should enter full path to dcu32int executable into "Decompiler command" field (marked as "2"). After that you should be able to open any .dcu file in the editor and see Pascal code of the unit's interface part.
aadog commented 5 years ago

image

Is it set to do this, it seems that the IDE does not recognize the DCU correctly?

aadog commented 5 years ago

image

aadog commented 5 years ago

Can you print a simple project delphi setup?, basic rtl and an extra separate dcu control

aadog commented 5 years ago

It seems that this is a bit confusing. It seems to me that I only need DCU files. Is it necessary to set the source code in RTL?

casteng commented 5 years ago

It seems that DCU32INT doesn't support Delphi 10.3. The latest version it supports is 10.2. You can write to its author to release DCU32INT for 10.3. The more requests will be the more likely it will be released. At the moment the only option with 10.3 is to create a new module with content root directory pointing to RTL sources and mark it as source.

casteng commented 5 years ago

From v2.40 RTL paths specified in Delphi SDK do not get passed to compiler.