Recent

Author Topic: Avoid automatic file saving when starting program  (Read 4791 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11914
  • Debugger - SynEdit - and more
    • wiki
Re: Avoid automatic file saving when starting program
« Reply #30 on: July 03, 2025, 10:18:22 pm »
- The FreePascal textmode IDE has an integrated compiler, so it is not completely unlikely this can be done for Lazarus.
How is it done? The compiler must then be in a form of a library with an API and linked to the IDE.

The text mode IDE directly uses the units of the compiler. And there isn't much API besides "compile file xyz" and some hooks for feedback.

Just for clarification... (for myself too).

- If the compiler is "used" (via "Uses ...") then yes it can be called in memory.

- An entrypoint like "compile file xyz" would still want a file?
- Well, ok, it probably be possible to skip the loader, and say "compile_source(ASource_as_pchar_or_string)" (or some other format).

But, when that source contains a "uses" then that used file needs to be compiled. The compiler would want to load that file from disk.
To prevent that, there would need to be a hook to inject a custom file loader? So then any file can be "loaded" from memory (or where ever).

PascalDragon

  • Hero Member
  • *****
  • Posts: 6235
  • Compiler Developer
Re: Avoid automatic file saving when starting program
« Reply #31 on: July 03, 2025, 11:16:16 pm »
- An entrypoint like "compile file xyz" would still want a file?

The entry point takes a command line string containing the options and the involved source file.

- Well, ok, it probably be possible to skip the loader, and say "compile_source(ASource_as_pchar_or_string)" (or some other format).

But, when that source contains a "uses" then that used file needs to be compiled. The compiler would want to load that file from disk.
To prevent that, there would need to be a hook to inject a custom file loader? So then any file can be "loaded" from memory (or where ever).

Looking at the compiler hooks one might even be able to cook something up using a virtual file system or something... 🤔

n7800

  • Hero Member
  • *****
  • Posts: 583
  • Lazarus IDE contributor
    • GitLab profile
Re: Avoid automatic file saving when starting program
« Reply #32 on: July 03, 2025, 11:51:19 pm »
For example, compile a project directly from a ZIP archive or any repository commit? ))

Thaddy

  • Hero Member
  • *****
  • Posts: 18515
  • Here stood a man who saw the Elbe and jumped it.
Re: Avoid automatic file saving when starting program
« Reply #33 on: July 04, 2025, 05:04:31 pm »
For example, compile a project directly from a ZIP archive or any repository commit? ))
Do you really have no clue: Streams. Compression streams and decompression streams are streams.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

n7800

  • Hero Member
  • *****
  • Posts: 583
  • Lazarus IDE contributor
    • GitLab profile
Re: Avoid automatic file saving when starting program
« Reply #34 on: July 05, 2025, 12:15:30 am »
For example, compile a project directly from a ZIP archive or any repository commit? ))
Do you really have no clue: Streams. Compression streams and decompression streams are streams.

What do you mean? The file just needs to be unpacked into memory and passed to the compiler. Files from Git can also be obtained without using the file system (by reading the output stream of the process git show <commit>:<path>).

 

TinyPortal © 2005-2018