Recent

Author Topic: ct2laz - convertor between CodeTyphon and Lazarus  (Read 43844 times)

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
ct2laz - convertor between CodeTyphon and Lazarus
« on: June 27, 2015, 03:11:46 pm »
Introduction
I use both Lazarus and CodeTyphon, but I don't like the fact that projects and components can't simply be loaded to both. I really like many components that can be found only in CodeTyphon, but since it changed names of some basic packages I had to manually adjust them with each new release when I wanted to use them in Lazarus. I like to have a freedom to choose one or the other IDE, and ct2laz utility tries to solve this problem.

Info
ct2laz utility can convert CodeTyphon projects and component packages to Lazarus, and Lazarus projects and component packages to CodeTyphon. It can also download zillion component packages and project examples from CodeTyphon web site and execute needed source file transformations to make them compatible with Lazarus. You can use CodeTyphon local files instead of downloaded ones if you prefer that way. Such transformed component packages can be installed into Lazarus, and most of the provided CodeOcean examples should work out of the box. One of the advantages of using CodeTyphon pl_* packages is that many of them are trully cross platform and well tested on each supported platform. Package compatibility info for Win/Lin/BSD/Sol/Mac/GTK2/QT4/QT5/WinCE/x86/x86_64/Arm/Arm64 supported platforms can be found here. Some CodeTyphon packages will only work with trunk versions of FPC and Lazarus.

Download
Latest version with full sources can be downloaded from http://bitbucket.org/avra/ct2laz

Prerequisites
For archives extraction you will need to download 7zip tool from http://www.7-zip.org on Windows, or p7zip package on Linux.

License
ct2laz is released under Mozilla Public License 2.0 (MPL-2.0) https://www.mozilla.org/MPL/2.0
License is explained in plain English at https://www.tldrlegal.com/l/mpl-2.0

Community
Contributors are welcome. If you find bugs, create patches for this or some other feature, please report here or as an issue in repository.

UPDATE: Added Linux version info.
« Last Edit: January 21, 2017, 06:44:40 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #1 on: June 27, 2015, 05:13:43 pm »
Hi
Sounds like a really useful utility.
WHen I run the exe I get replacements.csv missing if i click ok, get index out of bounds
Ideas?

Edit. File is a separate download
« Last Edit: June 27, 2015, 05:42:05 pm by josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #2 on: June 27, 2015, 07:57:33 pm »
WHen I run the exe I get replacements.csv missing if i click ok, get index out of bounds
You are right. Windows EXE was in downloads, while CSV was supposed to be downloaded from repository. Although you figured it out at the end, I have fixed it so CSV is also in downloads now. I hope it's less confusing now. Thanks!
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

rtusrghsdfhsfdhsdfhsfdhs

  • Full Member
  • ***
  • Posts: 162
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #3 on: June 28, 2015, 09:21:04 am »
Thank you very much for this.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #4 on: June 28, 2015, 09:59:21 am »
Thank you very much for this.
You are welcome.  :D I am glad people find it useful. It was time for me to give something back to the community.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

verasan

  • New Member
  • *
  • Posts: 11
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #5 on: July 01, 2015, 08:26:00 pm »
Hello!!!
your tool sounds good but what about version for linux?

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #6 on: July 02, 2015, 08:58:17 am »
what about version for linux?
When I catch time again I will try to integrate it with fpcup and then I will need to make it work on Linux too. There is nothing Windows specific in it so conversion shouldn't be too hard. If you take a look at the source you can find this:
Code: [Select]
  // linux: sh -c " whole commandline" (not tested yet)
  // OurProcess.Executable := '/bin/sh';
  // OurProcess.Parameters.Add('-c');
  // OurProcess.Parameters.Add('7z  -y x %COMPONENTS typhon/components/* -r -o%UNPACKDIR');
so I did think about linux. When time comes you will just need to install p7zip first with your package manager. I will probably default to 7zr instead and parameters will probably be different, but you get the picture. ct2laz should work with Wine, so I don't think that many folks will be eager for linux version and that's why it's not high on my priority list right now. If someone wants to take a bite on his own, be my guest and share a patch. ;)
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #7 on: January 04, 2017, 01:41:39 am »
I am asking for help to make this tool compile under linux.

After removing all CodeTyphon specific components my next move was to try to compile ct2laz under linux (Mint Cinammon Debian Edition with official Laz 1.6.2 and FPC 3.0.0), but I am stuck and need help.

First on compilation I get this error:
Quote
Compile Project, Target: ct2laz: Exit code 256, Errors: 1, Warnings: 1
Warning: Recompiling dynlibs, checksum changed for dl {impl}
openssl.pas(85,3) Fatal: Cannot find dynlibs used by openssl. Make sure all ppu files of a package are in its output directory. ppu in wrong directory=/usr/lib/fpc/3.0.0/units/i386-linux/rtl/dynlibs.ppu..

If I then locate dynlibs.pas and add it as a project requirement file I get this:
Quote
Compile Project, Target: ct2laz: Exit code 256, Errors: 1
strings.pp(109,2) Fatal: Cannot open include file "strings.inc"

After adding I386 version of strings.inc file I get such strange compilation errors that it was clear I am on wrong path.

Can anyone help?  ;) %) ;)


Quote
    HISTORY:
    0.9.5.154 Lazarus version is now default (if you want CT version then convert project with it's executable:)
    0.9.5.151 removed CodeTyphon specific components, show message on CSV file missing
    0.9.1.136 initial public release
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #8 on: January 04, 2017, 08:43:19 am »
I am asking for help to make this tool compile under linux.

After removing all CodeTyphon specific components my next move was to try to compile ct2laz under linux (Mint Cinammon Debian Edition with official Laz 1.6.2 and FPC 3.0.0), but I am stuck and need help.
I've forked your repo. I'll see what I can do.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #9 on: January 04, 2017, 08:58:33 am »
I've forked your repo. I'll see what I can do.
Thank you very much! Any help is most appreciated.   :D
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4459
  • I like bugs.
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #10 on: January 04, 2017, 03:13:43 pm »
Can anyone help?  ;) %) ;)
Yes! But damn it was a nasty one.  :o
The fundamental reason is that RTL already has a unit named "dl" in rtl/unix/dl.pp.
Just rename your unit to "mydl" or whatever and it starts to work. After renaming you can test by adding "dl" again to uses section. Ctrl-Click it and see where it jumps. :)

Some notes, although these don't cause errors:
Reference to "sdflaz" is not needed in project .lpr file.
Package "FCL" dependency is not needed, it comes through LCL.
Also the package "sdflaz" is not needed as a project dependency because it is installed in IDE.
Normally an installed design-run-time-packages dependency is needed but now all used units are from FPC libs.

[Edit] I looked at your commit history. "dl.pas" was added with commit message :
 "removed CodeTyphon specific components"
although it looks like a refactoring change where code was moved out of main unit into 2 new units.

A question comes to mind: why was the error message so misleading?
It did not say anything about unit "dl" or the units used by "dl".
The problem was especially difficult to find because clean build (Shift-F9) apparently did not clean everything. I commented out units, also "dl" but the same error still came. By luck I happened to delete the whole project lib folder.
How could such errors be found easier?
Anyway, in this case the name "dl" was a bad choice because UNIX systems have libdl.
« Last Edit: January 05, 2017, 11:22:59 am by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #11 on: January 04, 2017, 08:00:26 pm »
Yes! But damn it was a nasty one.  :o
The fundamental reason is that RTL already has a unit named "dl" in rtl/unix/dl.pp.
In fact, that's the only "error" before the project builds on Linux. Fork cancelled %)

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #12 on: January 04, 2017, 11:29:34 pm »
Can anyone help?  ;) %) ;)
Yes! But damn it was a nasty one.  :o
The fundamental reason is that RTL already has a unit named "dl" in rtl/unix/dl.pp.
Just rename your unit to "mydl" or whatever and it starts to work. After renaming you can test by adding "dl" again to uses section. Ctrl-Click it and see where it jumps. :)
Thank you sooooo much! It compiles now! :) :D :)

I will take a look at your project notes and correct them.

Quote
[Edit] I looked at your commit history. "dl.pas" was added with commit message :
 "removed CodeTyphon specific components"
although it looks like a refactoring change where code was moved out of main unit into 2 new units.
Yes. To make it work with just Lazarus components I had to replace some CT only visuals, and completely rewrite downloading and recursive file search to use only what's available in FCL. That was also the reason for refactoring code.

Quote
A question comes to mind: why was the error message so misleading?
It did not say anything about unit "dl" or the units used by "dl".
The problem was especially difficult to find because clean build (Shift-F9) apparently did not clean everything. I commented out units, also "dl" but the same error still came. By luck I happened to delete the whole project lib folder.
How could such errors be found easier?
Anyway, in this case the name "dl" was a bad choice because UNIX systems have libdl.
Indeed it was so misleading that I think I would not have found the error myself in million years. Especially since it compiled well under windows. I really felt like a dummy throwing myself at it in many ways without any progress at all. I will certainly think more careful about naming in the future, but it can be tough sometimes. I mean, I have renamed dl to downloader now but it may also conflict in the future. I guess namespaces will come to the rescue one day...

In fact, that's the only "error" before the project builds on Linux. Fork cancelled %)
Thanks a lot for your time and effort!

Since compilation works now with the great help of JuhaManninen, I guess I will try to finally make ct2laz fully work on linux too. Stay tuned...  ::)
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

frakno

  • Jr. Member
  • **
  • Posts: 88
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #13 on: January 05, 2017, 12:57:29 am »
Great, I tried it.

Worked well,
a few packages compiles but dont work

But e.g. Cindy works really well

Tahnk you really much for your effort
Lazarus 1.6 FPC 3.0 Windows 10

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: ct2laz - convertor between CodeTyphon and Lazarus
« Reply #14 on: January 05, 2017, 10:05:27 am »
Worked well,
a few packages compiles but dont work
But e.g. Cindy works really well
Most packages work. There are few specific to Typhon IDE that won't work, there are some that run only on windows, and there are some that require trunk FPC and/or LAZ, but every package that works in CodeTyphon should also work in Lazarus if they run both on the same pc with the same operating system. There are tons of packages, really - and many have nice examples. The only thing you should check manually for every package you want to use is the license of the original package, since that is not always that clear in CodeTyphon it self. I will probably display such warning message in the future, as one of ct2laz users has already suggested.

Tahnk you really much for your effort
You are most welcome  8)
« Last Edit: January 05, 2017, 10:14:29 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018