rejetto forum

Software => HFS ~ HTTP File Server => Programmers corner => Topic started by: LeoNeeson on November 21, 2018, 07:04:05 AM

Title: [Tutorial] How to compile the HFS's Source code
Post by: LeoNeeson on November 21, 2018, 07:04:05 AM
[Tutorial] How to compile the HFS's Source code

As the result of this (http://rejetto.com/forum/index.php?topic=13086.0), and for the first time ever, I would like to publish the complete process of compiling the HFS's Source code (as simple as possible, step by step, so everyone could do it). It's recomended to watch first THIS (https://imgur.com/a/M6nrOcP) video tutorial (download (https://www.4shared.com/s/f_7Lom4mMee) size: 1.56 MB, in GIF format), to see the enterelly compilation process. Then, just follow these steps:

1] Download 'Portable Turbo Delphi Lite v1.0d', from here (http://www.andyaska.com/?act=download&mode=detail&id=34).
2] Download the 'Library pack' required by HFS, from here (http://www.mediafire.com/?z32tkfzezfx36i7).
3] Download the latest 'Source code' file of HFS, from here (https://sourceforge.net/projects/hfs/files/HFS/2.3m/hfs2.3m.src.zip/download).
4] Install and/or unrar the exe of the step one, on: C:\Portable\TDLite
5] Unzip the file from the step two, on this exact folder: C:\Portable\TDLite\lib
6] Unzip the source code file of HFS, from step three, here: C:\Portable\TDLite\Projects\HFS
7] Start Turbo Delphi by opening the file "TDrun.exe" or using the shortcut on your desktop.
8] Go to the menu 'Tools' and click on 'Options...' and the 'Options' window will open.
     There, on go to: 'Environment Options' > 'Delphi Options' > 'Library - Win32'.
     Now on 'Directories' > 'Library path:' replace it with the following path:

Code: [Select]
$(BDS)\lib;$(BDS)\lib\Obj;$(BDS)\Imports;$(BDS)\lib\DelphiZLib.128;$(BDS)\lib\FastMM4991;$(BDS)\lib\GifImaged2010b;$(BDS)\lib\JCL1_22\source;$(BDS)\lib\Kdl32;$(BDS)\lib\OverbyteIcsV7Gold\Delphi\Vc32;$(BDS)\lib\TRegExpr\Source;$(BDS)\Projects\HFS;
9] Go to the menu 'File' and click on 'Open Project...' and locate the file 'hfs.bdsproj'.
10] Go to the menu 'Project' and click on 'Options...' and the 'Project Options' will open.
       There, click on 'Compiler Messages' and on 'Warnings', uncheck the following items:

Code: [Select]
    - Deprecated Symbol
    - Platform Symbol
    - Return value of function might be undefined

(This entirely step 10 is optional, but recommended. If you don't do it, you will encounter 32 or 33 Warnings on compiling time, but this doesn't affect the compilation process and you will get the very same functional executable. Those warnings are not important, but informative).

11] Finally, go to the menu 'Project' and click on 'Build hfs' and wait the process to finish.
       Once finished, you will see (in bold text): 'Done: Build All', click on 'OK' and it's done.
       You will find the new executable hfs.exe on this folder: C:\Portable\TDLite\Projects\HFS

12] Enjoy! :)

If you need a tool to unzip/uncompress, you can use 7-Zip (https://www.7-zip.org/).

If you want to use another folder path location (for example to run it from a USB drive), it's better you complete steps one to six from those locations, and then move that folder to the USB before running step seven. This way, you don't mess up with folder locations. Of course, if you choose another folder, you need to change the path in all the steps, but do NOT change the path of step eight (since it will auto-detect the new location).

» WARNING: the instructions and libraries found on this post are outdated, since latest HFS versions were compiled using the new Delphi 10.3.3 Community Edition. My instructions were only valid to old HFS versions (up to v2.3m). Instructions could have changed since then, and now you have to use the latest libraries listed here (https://github.com/rejetto/hfs2#libs-used). This post will be updated on the future.

» DISCLAIMER: I'm not making me responsible for any damage or miss-configuration on your PC. Always backup first, and keep in mind this tutorial was done on fresh installed Windows computer. If you already have any version of Delphi, running this portable version of 'Turbo Delphi' could lead you to problems, so avoid using it on a PC with Delphi installed. My uploads are untouched and virus free, but you must re-check that the MD5 file checksums are the same, as follows:

Quote
hfs2.3m.src.zip / MD5: AE2C3025B36FFF2BC72DB5FF7784C4BD
HFS.Libraries.zip / MD5: 7751002A930B7C211BFC1F9C7AA1853C
PortableTurboDelphiLiteInstaller10d.exe / MD5: 9B24FA6BD91FAF9ACA8AEA78B90AEF07
(You could use the freeware HashCheck (http://code.kliu.org/hashcheck/) to verify the MD5 file checksums (https://en.wikipedia.org/wiki/Checksum))

» HFS.Libraries.zip Download link:
https://www.4shared.com/s/fsY2jRS7Tda
http://www.mediafire.com/?z32tkfzezfx36i7

Feel free to leave a comment or ask any question if you have doubts, and also report if you find any problem when compiling, or if you need further help.

Cheers,
Leo.-
Title: Re: [Tutorial] How to compile the HFS's Source code
Post by: LeoNeeson on November 21, 2018, 07:15:04 AM
(This space is reserved for future use, please ignore this)
Title: Re: [Tutorial] How to compile the HFS's Source code
Post by: LeoNeeson on November 21, 2018, 08:12:55 AM
With this, I could say that I'm a 'virtual member' of the group of users who can compile HFS, and I hope I could contribute in the future (to Rejetto) with small and tested modifications (that's in the case he likes something I could do, but if he don't, at least I will publish it here so anyone could benefit of it). For the time being, I don't plan to implement any change (I currently don't have too much free time, and I've spent too much time and energy on getting everything working, along with doing this tutorial for the benefit of anyone who could be interested on compile HFS).

I encourage that any member, with a basic level of Pascal/Delphi knowledge, feel free to join the virtual group of 'compilers/programmers', contributing (here on the forum) with any change, modification or enhancement that could have in mind (even leaving new ideas). That doesn't mean Rejetto automatically would incorporate those new ideas in HFS, but perhaps if something is good enough, he could take some of those contributions. Team work is always positive in the open source world. ;)

Cheers,
Leo.-
Title: Re: [Tutorial] How to compile the HFS's Source code
Post by: bmartino1 on November 24, 2018, 06:52:54 AM
I appreciate this LEO. Thank you Rejetto for this program and code, and Thank you, Mars and many other users on the form for this software.

I have tested it and can confirm that this process works.

I will note that the warning messages were not 100% necessary to disable:
    - Deprecated Symbol
    - Platform Symbol
    - Return value of function might be undefined

I have created a sfx zip (self extracting exe zip file that contains the portable application, the lib files and current hfs source file 2.3m)
https://drive.google.com/file/d/1UntWvAcJcHgXMoHD14ThB7SQy2NGywtE/view?usp=sharing

* This zip has successfully built hfs and is also in the folder. you will have to delete hfs.exe form
% path% \ TDLite \ Projects \ HFS \ hfs.exe

run the portable application and build.

Thank you, Leo, for this, I will now be able to review the code for a bit easier and may find the kink in the chain from my previous attempt form last attempt at this.

https://drive.google.com/file/d/1A2YNVyo17jxtjG6ih5gDwAswhbzxHrUM/view?usp=sharing
Title: Re: [Tutorial] How to compile the HFS's Source code
Post by: rejetto on December 02, 2018, 04:12:15 PM
cool!
Title: Re: [Tutorial] How to compile the HFS's Source code
Post by: newbie on March 09, 2021, 11:04:04 PM
Hi,
I'm trying to compile the HFS 2.4.0 RC07 codebase with instructions from this thread, and I'm encountering the following errors.
[Pascal Fatal Error] hslib.pas(33): F1026 File not found: 'system.contnrs.dcu'
If I comment out the use of the system.contnrs lib I get other errors:
[Pascal Error] hslib.pas(209): E2003 Undeclared identifier: 'TobjectList'
[Pascal Error] hslib.pas(309): E2004 Identifier redeclared: 'chop'
[Pascal Error] hslib.pas(314): E2004 Identifier redeclared: 'chop'
[Pascal Fatal Error] hslib.pas(338): F1026 File not found: 'ansistrings.dcu'

Note that the instructions worked just fine for 2.3m, and the current build is attempted on the same machine.

Any suggestions would be appreciated.

Thanks
Title: Re: [Tutorial] How to compile the HFS's Source code
Post by: SilentPliz on March 10, 2021, 08:31:04 AM
Hi,


HFS 2.4 is compiled with Delphi 10 now.

Quote from: rejetto
hi guys,
this days i had some spare time, so first i reinitialized my Windows system after 5 years. Muchi better now!Then i decided to try to go for Delphi 10.3.3, that is the latest free version (it's callled "community edition").
https://www.embarcadero.com/products/delphi/starter/free-download (https://www.embarcadero.com/products/delphi/starter/free-download)

...
Title: Re: [Tutorial] How to compile the HFS's Source code
Post by: newbie on March 25, 2021, 03:24:05 PM
Hi,
I'm trying to build 2.4.0 rc07 with Embarcadero 10.3.3 Community Edition.

1. Do I use the same Library pack as mentioned by LeoNeeson at the top of this thread? Or is there a new one somewhere?
2. Delphi fails to build with this error: "Cannot resolve unit name 'uFreeLocalizer' at line 28 of hfs.dpr" Got past this.
3. I now get an error in uFreeLocalizer.pas
Code: [Select]
WideToAnsiString(ws, s, GetACP);. Modified definition to
Code: [Select]
s: AnsiString; and it got past.
4. Next compile error in OverbytelcsMimeUtils.pas Undeclared identifier errors: TBufferedFileStream(Stream).Mode & TBufferedFileStream(Stream).FastSize

I'm playing whack-a-mole here so it kinda appears that there is a new Library Pack, I need to use.

Thanks
Title: Re: [Tutorial] How to compile the HFS's Source code
Post by: LeoNeeson on March 25, 2021, 11:24:42 PM
@newbie: The 'Library Pack' posted on this thread, was something I've done to simplify the compiling process, but there isn't an 'Official Pack' to download. You have to manually download the latest versions of each libraries (from each author's website), listed HERE (https://github.com/rejetto/hfs2#libs-used). You can find more information about the switch to the new Delphi version, HERE (http://rejetto.com/forum/index.php?topic=13288.0) (be sure to read the whole thread).

Summarizing, HFS is currently using these libraries:
:-[ Sadly, I don't have any free time to update this package, neither to update this post with updated instructions for the new 'Delphi 10.3.3'. It's on my 'to-do list', but I don't have any estimation of when I will be able to complete this (but anyone is welcome to comment here which changes are needed to compile HFS with the new Delphi version).

Cheers,
Leo.-
Title: Re: [Tutorial] How to compile the HFS's Source code
Post by: newbie on March 26, 2021, 05:06:35 PM
@LeoNeeson. Thanks for those pointers.

I was able to figure out how to build HFS 2.4.0 rc07.
But it reqd a few lines of code changes. Not sure if its the right changes.

Specifically:
In utilLib.pas:  Line 363-365:
RAD IDE's drop-down helper suggested 2 possibilities: MountPointReparseBuffer or SymbolicLinkReparseBuffer. I chose the former.
Code: [Select]
      if BytesReturned < DWORD(ReparseData.Reparse.MountPointReparseBuffer.SubstituteNameLength + SizeOf(WideChar)) then exit;
      SetLength(Destination, (ReparseData.Reparse.MountPointReparseBuffer.SubstituteNameLength div SizeOf(WideChar)));
      Move(ReparseData.Reparse.MountPointReparseBuffer.PathBuffer[0], Destination[1],
     ReparseData.Reparse.MountPointReparseBuffer.SubstituteNameLength);

Anyway, here's my full Readme.txt that got me up and running w/ 2.4.0 rc07


README for building 2.4.0 rc07

Code: [Select]
Assumption: Installed everything to E:\Portable\TDLite.
If you move it elsewhere, modify include paths in RAD (Step 4a) appropriately

1. Install Embarcadero 10.3.3 RAD IDE Community Edition to E:\Portable\TDLite
https://www.embarcadero.com/products/delphi/starter


1. Install HFS Source
   https://github.com/rejetto/hfs2#libs-used
   2.4.0rc07: https://github.com/rejetto/hfs2/releases/tag/v2.4-rc07
   https://github.com/rejetto/hfs2/archive/refs/tags/v2.4-rc07.zip
   Extract to: E:\Portable\TDLite\Projects\hfs2-2.4-rc07

   Build HFS Data resources:
   Execute: E:\Portable\TDLite\Projects\hfs2-2.4-rc07\recompile_data.bat

3. Setting up HFS Library pack
HFS incl. all all its reqd 3rdparty libs will be installed under E:\Portable\Projects\hfs-lib

Ref: https://github.com/rejetto/hfs2#libs-used
a. Overbyte 8.64: http://www.overbyte.eu/frame_index.html
   Daily archive: http://wiki.overbyte.eu/arch/icsv8w.zip
   Extract to: E:\Portable\Projects\hfs-lib\OverbyteIcsV8_64
b. TRegExpr 0.952b: https://github.com/andgineer/TRegExpr/releases
   https://github.com/andgineer/TRegExpr/archive/refs/tags/0.952b.zip
   Extract to: E:\Portable\TDLite\Projects\hfs-lib\TRegExpr0_952b
c. Jedi CL 2.7: https://github.com/project-jedi/jcl
   Install this git repo to a temp folder somewhere.
   git clone --recurse-submodules -j8 https://github.com/project-jedi/jcl.git
   cd jcl/jcl
   ./Install.bat
   copy *.* E:\Portable\TDLite\hfs-lib\JCL2_7
d. KDL 4.1: https://sites.google.com/site/kryvich/localizer
   kdl41.zip: https://drive.google.com/open?id=0BwH77FLlRxs2RnFRTnMxcnZNbUE
   Extract to E:\Portable\Projects\hfs-lib\kdl41

4. Building in Embarcadero RAD:
   Open E:\Portable\TDLite\Projects\hfs2-2.4-rc07\hfs.bdsproj

   a. Modify include paths:
      In Projects window, right-click hfs.exe and choose "Options"
      Click on "Delphi Compiler" > Search Path, and replace w/:
      $(DELPHI)\Lib\win32\release;$(DELPHI)\Projects\hfs-lib;$(DELPHI)\Imports;$(DELPHI)\Projects\hfs-lib\JCL2_7\source\windows;$(DELPHI)\Projects\hfs-lib\JCL2_7\source\common;$(DELPHI)\Projects\hfs-lib\JCL2_7\source\include;$(DELPHI)\Projects\hfs-lib\Kdl41;$(DELPHI)\Projects\hfs-lib\OverbyteIcsV8_64\Source;$(DELPHI)\Projects\hfs-lib\OverbyteIcsV8_64\Source\Include;$(DELPHI)\Projects\hfs-lib\TRegExpr0_952b\Source;$(DELPHI)\Projects\hfs2-2.4-rc07;
      Save and close.
     
   b. SourceModifications reqd to compile:
      utilLib.pas
      Line 363-365:
      if BytesReturned < DWORD(ReparseData.Reparse.MountPointReparseBuffer.SubstituteNameLength + SizeOf(WideChar)) then exit;
      SetLength(Destination, (ReparseData.Reparse.MountPointReparseBuffer.SubstituteNameLength div SizeOf(WideChar)));
      Move(ReparseData.Reparse.MountPointReparseBuffer.PathBuffer[0], Destination[1], ReparseData.Reparse.MountPointReparseBuffer.SubstituteNameLength);
   
   c. In Projects window, right-click hfs.exe and choose "Build"
 
DONE
   
Title: Re: [Tutorial] How to compile the HFS's Source code
Post by: bmartino1 on July 31, 2022, 08:15:32 PM
Current sources to compile https://github.com/rejetto/hfs2/releases

I may need to relook into the lib and sources to compile the current revision.
At the time of this writing, as i have been distant on the form.

Per Rejeto HFS "fork me on GitHub Sources:
https://github.com/rejetto/hfs2/

I have found this to be done with Delphi / Free Pascal - C+ coding:
(My Google Drive has file still available, I can only assume multiple geo access to the US Google drive has forced drive to change or disable my account from time to time.)

Introduction
You can use HFS (HTTP File Server) to send and receive files. It's different from classic file sharing because it uses web technology. It also differs from classic web servers because it's very easy to use and runs "right out-of-the box".

The virtual file system will allow you to easily share even one single file.

Dev notes
Initially developed in 2002 with Delphi 6, now with Delphi 10.3.3 (Community Edition). Icons are generated at http://fontello.com/ . Use fontello.json for further modifications.

For the default template we are targeting compatibility with Chrome 49 as it's the latest version running on Windows XP.

Libs used
ICS v8.64 by François PIETTE :http://www.overbyte.eu/frame_index.html
Download: http://www.overbyte.eu/eng/download.html?url=http://www.overbyte.eu/arch/icsv858.zip

TRegExpr v0.952b by Andrey V. Sorokin :https://github.com/andgineer/TRegExpr/releases
Download: https://github.com/andgineer/TRegExpr/releases/download/0.952b/TRegExpr_0952b_20040105.zip

JEDI Code Library v2.7 :https://github.com/project-jedi/jcl
Download: http://jcl.sourceforge.net/daily/

Kryvich's Delphi Localizer v4.1 :https://sites.google.com/site/kryvich/localizer / https://github.com/Kryuski/kryvich-delphi-localizer
Download: (requires Google drive share access): https://drive.google.com/open?id=0BwH77FLlRxs2RnFRTnMxcnZNbUE