Re: [fpc-pascal] Lazarus complains that it cannot find a dependency, why?

2020-09-01 Thread Bo Berglund via fpc-pascal
On Wed, 02 Sep 2020 00:34:23 +0200, Tomas Hajny via fpc-pascal
 wrote:

>On 2020-09-02 00:21, Bo Berglund via fpc-pascal wrote:
>
>  .
>  .
>> Strange because I have read that cthreads must be first in uses in the
>> lpr program files in order to make threads work.
>> How could it work if I add the dependencies, then it would come later
>> or maybe earlier???
>
>The real requirement is that the thread manager needs to be initialized 
>before any threading features are used. If any of the used units uses 
>threading features in its initialization, then such a unit should have 
>cthreads in its own uses section (then this requirement is obviously 
>fulfilled), or cthreads must be listed before that unit in the uses 
>section of your program (and having cthreads as the first unit makes 
>this requirement fulfilled as well).
>

OK, so I made a test by commenting out cthreads in the lpr file and
instead adding it as the first uses in my fpserialport unit, but that
made things even worse...
In this case the application itself would not appear when I started it
from its desktop icon. After trying to see what caused this I started
it from the terminal instead and then I got this:

$ ./SerialTest 
Threading has been used before cthreads was initialized.
Make cthreads one of the first units in your uses clause.
Runtime error 211 at $003958A0
  $003958A0
  $B64FF718

So a different kind of error than the one I had earlier and this
indicates that it really has to be the very first uses in the
application dpr file. Which is what I believed.

Maybe if one has a thread enabled package specified in the project
dependencies, that package's use of cthreads precedes even the lpr
uses clause and therefore the requirement is fulfilled?

Both LazSerial and SdpoSerialLaz uses a read thread, which to me look
identical in their respective source code.
So my read thread is based on theirs with some minor modifications
only...


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Lazarus complains that it cannot find a dependency, why?

2020-09-01 Thread Tomas Hajny via fpc-pascal

On 2020-09-02 00:21, Bo Berglund via fpc-pascal wrote:

 .
 .

Strange because I have read that cthreads must be first in uses in the
lpr program files in order to make threads work.
How could it work if I add the dependencies, then it would come later
or maybe earlier???


The real requirement is that the thread manager needs to be initialized 
before any threading features are used. If any of the used units uses 
threading features in its initialization, then such a unit should have 
cthreads in its own uses section (then this requirement is obviously 
fulfilled), or cthreads must be listed before that unit in the uses 
section of your program (and having cthreads as the first unit makes 
this requirement fulfilled as well).


Tomas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Lazarus complains that it cannot find a dependency, why?

2020-09-01 Thread Bo Berglund via fpc-pascal
On Tue, 01 Sep 2020 23:55:08 +0200, Tomas Hajny via fpc-pascal
 wrote:

>Well, I believe that this supposed mystery may be resolved easily. ;-) 
>First of all - have you tried to find out what does the displayed error 
>number (232) mean? Quick searching reveals that runtime error 232 may 
>signalize that you try to use threads without having a thread manager 
>included in your application. Under Linux/Unix, you can add a thread 
>manager by adding unit cthreads to the uses section of your program. 
>That also provides explanation of your "mystery" - the other 
>dependencies tried by you included this unit by themselves and thus you 
>didn't need to do so in your program.
>
>Hope this helps
>
>Tomas

Yes it does!
Thank you so very much
I can finally go to bed now

This is how it looks like in the dpr file:

program SerialTest;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}

I usually always take out the extra ifdef for UseCThreads so it looks
like this:

uses
  {$IFDEF UNIX}
  cthreads,
  {$ENDIF}

But it was forgotten in this test application

Strange because I have read that cthreads must be first in uses in the
lpr program files in order to make threads work.
How could it work if I add the dependencies, then it would come later
or maybe earlier???

Anyway now working.
THanks again!


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Lazarus complains that it cannot find a dependency, why?

2020-09-01 Thread Tomas Hajny via fpc-pascal

On 2020-09-01 23:44, Bo Berglund via fpc-pascal wrote:

On Tue, 01 Sep 2020 22:46:55 +0200, Bo Berglund via fpc-pascal
 wrote:



Hi,


Further to this mystery:
If I remove LazSerialPort from the dependencies and instead put
SdpoSerialLaz there instead it also solves the problem:
- Program builds fine
- Program does not crash when the read thread is created.

But remove this so the only dependency is LCL then the program builds
but crashes when the read thread is created after the serial port has
been opened.


Well, I believe that this supposed mystery may be resolved easily. ;-) 
First of all - have you tried to find out what does the displayed error 
number (232) mean? Quick searching reveals that runtime error 232 may 
signalize that you try to use threads without having a thread manager 
included in your application. Under Linux/Unix, you can add a thread 
manager by adding unit cthreads to the uses section of your program. 
That also provides explanation of your "mystery" - the other 
dependencies tried by you included this unit by themselves and thus you 
didn't need to do so in your program.


Hope this helps

Tomas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Lazarus complains that it cannot find a dependency, why?

2020-09-01 Thread Bo Berglund via fpc-pascal
On Tue, 01 Sep 2020 22:46:55 +0200, Bo Berglund via fpc-pascal
 wrote:

>STRANGE "SOLUTION", BUT WHY?
>
>So even though I am not really using *anything* in LazSerial I added
>LazSerialPort back to the dependencies and rebuilt the application.
>Now the thread creation does no longer show any such exception!
>And the application runs properly.
>
>But I REALLY do not want to specify LazSerialPort as a dependency when
>it is the point of my work to *remove* LazSerial and Synapse from the
>project.
>
>What is going on and how can I find where it really goes astray?
>And what can LazSerial bring into this?

Further to this mystery:
If I remove LazSerialPort from the dependencies and instead put
SdpoSerialLaz there instead it also solves the problem:
- Program builds fine
- Program does not crash when the read thread is created.

But remove this so the only dependency is LCL then the program builds
but crashes when the read thread is created after the serial port has
been opened.


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Lazarus complains that it cannot find a dependency, why?

2020-09-01 Thread Bo Berglund via fpc-pascal
On Tue, 01 Sep 2020 21:07:56 +0200, Bo Berglund via fpc-pascal
 wrote:

>I get an error message when building a project after updating from SVN
>to get the sources that build fine on another RPi4 identical in
>configuration.
>
>"Fatal: Cannot find LazSerial used by RemoteIO. Check if package
>LazSerialPort is in the dependencies."
>
>The LazSerial dependency has been *removed*, that was the whole point
>of this excercise.
>There is no longer any mention in the source files of lazserial and I
>have removed the dependencies for LazSerial in the project inspector.
>
>Where can Lazarus have stored this bogus information?
>
>In Project inspector are only 3 items:
>Files
>  SerialTest.lpr
>  formmain.pas
>Required packages:
>  LCL
>
>I have even searched the files in the project for LazSerial and it
>only finds the word in comments

Further debugging leads to the following:

1) I deleted the lib dir below the project so that Lazarus will
recompile everything.

2) Now Lazarus succeeds in building the application!
So there must have been some artifact left in the old lib dir from
earlier tests.

3) But when I run it, it disappears when I use the Open Comm button,
which is opening the serial port for communications!

4) So I stepped through the code below the button and reached this
after the serial commands actually completed successfully:
This is where the read thread is created and started:

  if Assigned(FOnRxData) then
  begin
FReadThread := TComPortReadThread.Create(true); //<= Exception
FReadThread.Owner := Self;
FReadThread.MustDie := false;
FReadThread.ReadPacketSize := FReadPacketSize;
FReadThread.ReadTimeout := (FReadThread.ReadPacketSize * 1)
div FBaudRate + 1;
FReadThread.FreeOnTerminate := false;
FReadThread.Start;
  end;


The error message that pops up on the first line in the block is this:

||
| Debugger exception notification|
||
| Project SerialTest raised exception class 'RunError(232)'. |
| At address 6B  |
||

Note that the thread type is declared like this:

  TComPortReadThread=class(TThread)

So it is using TThread, which AFAIK is a general type of class and not
from LazSerial.

So the TThread creation is now throwing an exception whereas with the
LazSerial in the dependencies it did not..

STRANGE "SOLUTION", BUT WHY?

So even though I am not really using *anything* in LazSerial I added
LazSerialPort back to the dependencies and rebuilt the application.
Now the thread creation does no longer show any such exception!
And the application runs properly.

But I REALLY do not want to specify LazSerialPort as a dependency when
it is the point of my work to *remove* LazSerial and Synapse from the
project.

What is going on and how can I find where it really goes astray?
And what can LazSerial bring into this?

-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] x86-linux-gnu cross

2020-09-01 Thread Marco van de Voort via fpc-pascal


Op 2020-09-01 om 20:28 schreef Adriaan van Os via fpc-pascal:
On Mac OS X 10.8, I have built an fpc-3.0.4  runtime-library for 
CPU_TARGET=x86_64 OS_TARGET=linux BINUTILSPREFIX=x86_64-linux-gnu- 
after building gnu binutils-2.34 for  --target=x86_64-linux-gnu 
--host=i686-apple-darwin --build=i686-apple-darwin --prefix=/usr/local.


It's been a while since I did crosscompiling regularly, but usually the 
key is comparing a ppas.sh/link.res  natively and cross.  FPC tries to 
be smart in the t_ detecting things that might not be there "cross".   
Add a -k to make LD verbose and then run both, comparing output afterwards.


Also the linker might have some defaults natively that it doesn't have 
cross.



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Lazarus complains that it cannot find a dependency, why?

2020-09-01 Thread Bo Berglund via fpc-pascal
I get an error message when building a project after updating from SVN
to get the sources that build fine on another RPi4 identical in
configuration.

"Fatal: Cannot find LazSerial used by RemoteIO. Check if package
LazSerialPort is in the dependencies."

The LazSerial dependency has been *removed*, that was the whole point
of this excercise.
There is no longer any mention in the source files of lazserial and I
have removed the dependencies for LazSerial in the project inspector.

Where can Lazarus have stored this bogus information?

In Project inspector are only 3 items:
Files
  SerialTest.lpr
  formmain.pas
Required packages:
  LCL

I have even searched the files in the project for LazSerial and it
only finds the word in comments


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using built-in serial instead of synaser and the like for Linux console app?

2020-09-01 Thread Michael Van Canneyt via fpc-pascal



On Tue, 1 Sep 2020, Bo Berglund via fpc-pascal wrote:


On Tue, 1 Sep 2020 14:21:44 +0200 (CEST), Michael Van Canneyt via
fpc-pascal
 wrote:


You must still set the default value in the constructor.



Note that the thread itself has no idea what is the baudrate in use so
it cannot calculate the proper value at the start of Execute...
And there is no Create method either that I can use.


The constructor can always be overridden.



I did this:
 TComPortReadThread=class(TThread)
 private
   FBuffer: TBytes;
   FReadPacketSize: integer;
   FReadTimeout: integer;
 public
   MustDie: boolean;
   Owner: TFpSerialPort;
   constructor Create; override; //<= THIS ADDED, GIVES ERROR
   property ReadPacketSize: integer read FReadPacketSize write
FReadPacketSize; //How many bytes to read in each operation
   property ReadTimeout: integer read FReadTimeout write
FReadTimeout;//Max time to wait for data in thread
 protected
   procedure CallEvent;
   procedure Execute; override;
 published
   property Terminated;
 end;


and the code will not compile:

fpserialport.pas(41,17) Error: There is no method in an ancestor class
to be overridden: "constructor Create;"

So, does TThread not have a constructor
I thought all objects had.


Yes, but you can only override a virtual constructor. The TThread
constructor is not virtual.

If you want to introduce a new one just leave away the ; override;

Michael.




--
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] x86-linux-gnu cross

2020-09-01 Thread Adriaan van Os via fpc-pascal
On Mac OS X 10.8, I have built an fpc-3.0.4  runtime-library for CPU_TARGET=x86_64 OS_TARGET=linux 
BINUTILSPREFIX=x86_64-linux-gnu- after building gnu binutils-2.34 for  --target=x86_64-linux-gnu 
--host=i686-apple-darwin --build=i686-apple-darwin --prefix=/usr/local.


Now the following program crashes when compiled on OSX and executed on 64-bit 
debian 6.0.7.

{$linklib libgcc_s.so}
program Hello;
  uses
cmem;
  begin
writeln
  ( 'Hello');
  end.

but this runs fine

{$linklib libgcc.a}
{$linklib libgcc_eh.a}
{$linklib libc.a}
program Hello;
  uses
cmem;
  begin
writeln
  ( 'Hello');
  end.

Linking with other shared libs (maybe dependent on libgcc_so?) also causes a segmentation fault on 
start. All the libs are from .


My impression is that somehow linking-in the c-libs causes the entry-point of the program to be 
wrong. Maybe there is a linker option (I don't know of) to prevent this ?


Regards,

Adriaan van Os
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using built-in serial instead of synaser and the like for Linux console app?

2020-09-01 Thread Bo Berglund via fpc-pascal
On Tue, 1 Sep 2020 14:21:44 +0200 (CEST), Michael Van Canneyt via
fpc-pascal
 wrote:

>You must still set the default value in the constructor.
>
>>
>> Note that the thread itself has no idea what is the baudrate in use so
>> it cannot calculate the proper value at the start of Execute...
>> And there is no Create method either that I can use.
>
>The constructor can always be overridden.
>

I did this:
  TComPortReadThread=class(TThread)
  private
FBuffer: TBytes;
FReadPacketSize: integer;
FReadTimeout: integer;
  public
MustDie: boolean;
Owner: TFpSerialPort;
constructor Create; override; //<= THIS ADDED, GIVES ERROR
property ReadPacketSize: integer read FReadPacketSize write
FReadPacketSize; //How many bytes to read in each operation
property ReadTimeout: integer read FReadTimeout write
FReadTimeout;//Max time to wait for data in thread
  protected
procedure CallEvent;
procedure Execute; override;
  published
property Terminated;
  end;


and the code will not compile:

fpserialport.pas(41,17) Error: There is no method in an ancestor class
to be overridden: "constructor Create;"

So, does TThread not have a constructor
I thought all objects had.


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux GTK-2 GUI app

2020-09-01 Thread Michael Van Canneyt via fpc-pascal



On Tue, 1 Sep 2020, Adriaan van Os via fpc-pascal wrote:


Michael Van Canneyt wrote:

Normally a zip file with a the binary and supporing files, plus a README 
file should be enough.


Can you refer me to an example ?


You can't get more simple than this I think:

https://github.com/gohugoio/hugo/releases/download/v0.74.3/hugo_0.74.3_Linux-64bit.tar.gz

It's a golang binary, but that's equivalent to an FPC binary.

For example Gitea just makes available the binary:

https://dl.gitea.io/gitea/1.12.3

There is nothing to it really, unless I misunderstand what you need...

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux GTK-2 GUI app

2020-09-01 Thread Adriaan van Os via fpc-pascal

Michael Van Canneyt wrote:

Normally a zip file with a the binary and supporing files, plus a README 
file should be enough.


Can you refer me to an example ?

Thanks,

Adriaan van Os

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpcmake packaging

2020-09-01 Thread Tony Whyman via fpc-pascal


On 01/09/2020 14:29, Ryan Joseph via fpc-pascal wrote:



On Sep 1, 2020, at 7:46 PM, Tony Whyman via fpc-pascal 
 wrote:

fpcmake is a pre-processor that generates makefiles for fpc projects. You can 
use it to do just about anything a standard makefile can do, including 
including resource files and running scripts. I use it all the time for 
building production versions of lazarus programs and prior to packaging the 
programs and resources in .deb and .rpm files.

On 01/09/2020 13:37, Ryan Joseph via fpc-pascal wrote:


Apparently there is fpmake and fpcmake, which I didn't know.

I guess what you're saying is that I start with fpcmake and get makefiles which 
I can then use to do packing and all the stuff I need? I've thought of using 
makefiles before but I ran into the problem of have all this logic that I need 
to duplicate for each project. What I'm really after is something more like 
lazbuild that takes a config file and does all the commands for you. I guess I 
could even use lazbuild but again, the packaging doesn't seem possible since 
lazbuild is so Lazarus focused (obviously).

Regards,
Ryan Joseph


My primary motivation for going with fpcmake is that it is a very good 
fit with the debian package management system (and rpmbuild). My normal 
build target is Ubuntu and hence I want to generate .deb files in order 
to distribute my application. The Debian Package Manager does not 
actually mandate use of makefiles - but it is built around the makefile 
concept and I have only ever seen examples of use based on makefiles.


I would position fpcmake as similar to autoconf/ automake in the C/C++ 
work. With automake, you need a Makefile.am in every directory of your 
project that contains something to compile or include in your package. 
With fpcmake you need a Makefile.fpc instead. This file contains the 
directives needed to generate the makefile and looks like an ini file.


An example follows taken from a simple application I have for 
Requirements Management.


The Makefile.fpc uses external environment variables, such as 
"INTERFACE". An external script (or a Debian rules file) that calls 
"make" itself to compile the project would define


export INTERFACE=gtk2

assuming you want gtk2 for your GUI.

Otherwise, the [compiler] section defines the fpc options, and 
directories to search. Most of these are part of my project. I have also 
used environment variables to define the build target and where to find 
the lazarus units. The [install] section is where I tell it  to install 
resource files. This includes an icon for the program and Firebird 
resource files. My project also requires that a .res file is built 
before the program is linked and there is a [prerules] section for this. 
"mkversioninfo" is my own utility, which generates the input to the 
windres utility for .res file generation.


Finally, there is an extra [rules] section to ensure that my resources 
are built when a "make all" is called.


[requires]
packages=fcl-res
libc=y

[compiler]
options= -MDelphi -Scghi -O3 -CX -Xs -vewnhi -l -dUseCThreads -dLCL 
-dLCL$(INTERFACE)

unittargetdir=units/$(CPU_TARGET)-$(OS_TARGET)
includedir=$(LZINCLUDE)
unitdir=$(LAZUNITDIR)/*  $(LAZUNITDIR)/*/$(INTERFACE) \
../frames \
../forms \
../dlg \
../reports \
../ole \
../ \
.


[target]
programs=RequirementsManagerPersonal

[install]
datadir=$(INSTALL_PREFIX)/share/RequirementsManager
files=RequirementsManagerPersonal.xpm firebird.conf firebird.msg

[prerules]
resources:
    rm -f RequirementsManagerPersonal.res
    mkversioninfo requirementsmanager-personal RequirementsManager.ico 
| $(WINDRES) -o RequirementsManagerPersonal.res


[rules]
all: resources fpc_all

A debian rules file for use with fpcmake is usually the same for every 
fpc project i.e.


Note this calls fpcmake automatically. A C/C++ build would call 
"configure" at the same point. I have defined the INTERFACE as an 
argument to the call to make.


#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of 
dh-make.

#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)

export FPCDIR=/usr/lib/fpc/$(shell fpc -iV)

configure: configure-stamp
configure-stamp:
    dh_testdir
    # Add here commands to configure the package.
    fpcmake -r Makefile.fpc

    touch configure-stamp

#Architecture
build: build-arch 

Re: [fpc-pascal] fpcmake packaging

2020-09-01 Thread Tomas Hajny via fpc-pascal

On 2020-09-01 15:29, Ryan Joseph via fpc-pascal wrote:
On Sep 1, 2020, at 7:46 PM, Tony Whyman via fpc-pascal 
 wrote:


fpcmake is a pre-processor that generates makefiles for fpc projects. 
You can use it to do just about anything a standard makefile can do, 
including including resource files and running scripts. I use it all 
the time for building production versions of lazarus programs and 
prior to packaging the programs and resources in .deb and .rpm files.


On 01/09/2020 13:37, Ryan Joseph via fpc-pascal wrote:



Apparently there is fpmake and fpcmake, which I didn't know.

I guess what you're saying is that I start with fpcmake and get
makefiles which I can then use to do packing and all the stuff I need?
I've thought of using makefiles before but I ran into the problem of
have all this logic that I need to duplicate for each project. What
I'm really after is something more like lazbuild that takes a config
file and does all the commands for you. I guess I could even use
lazbuild but again, the packaging doesn't seem possible since lazbuild
is so Lazarus focused (obviously).


In case of fpcmake, the file Makefile.fpc is basically equivalent to a 
configuration file:


-
[package]
name=fcl-res
version=3.3.1

[target]
units=acceleratorsresource bitmapresource coffconsts coffreader 
cofftypes \
  coffwriter dfmreader elfconsts elfreader elftypes elfwriter 
externalreader \
  externaltypes externalwriter fpcrestypes groupcursorresource 
groupiconresource \
  groupresource icocurtypes machoconsts machoreader machotypes 
machowriter \
  resdatastream resfactory resmerger resource resourcetree resreader 
reswriter \
  stringtableresource strtable tlbreader versionconsts 
versionresource versiontypes \

  winpeimagereader xcoffwriter
rsts=versiontypes stringtableresource resource resfactory


[compiler]
options=-S2h
sourcedir=src

[install]
fpcpackage=y

[default]
fpcdir=../..

[rules]
.NOTPARALLEL:


You _may_ define additional logic (on top of the prebuilt things known 
to the fpcmake tool / defined in fpcmake.ini) in the [rules] section, 
but that is not strictly necessary as long as you don't have special 
dependencies, don't need to invoke the compiler or other tools with 
special parameters for different targets, etc.


In case of fpmake, the "configuration" is a rather simple pascal program 
(fpmake.pp):


-
{$ifndef ALLPACKAGES}
{$mode objfpc}{$H+}
program fpmake;

uses fpmkunit;

Var
  T : TTarget;
  P : TPackage;
begin
  With Installer do
begin
{$endif ALLPACKAGES}

P:=AddPackage('fcl-res');
P.ShortName:='fcle';
{$ifdef ALLPACKAGES}
P.Directory:=ADirectory;
{$endif ALLPACKAGES}
P.Version:='3.3.1';
P.Dependencies.Add('rtl-objpas');
P.Dependencies.Add('fcl-base');
P.Dependencies.Add('tplylib');
P.Author := 'Giulio Bernardi';
P.License := 'LGPL with modification, ';
P.HomepageURL := 'www.freepascal.org';
P.Email := '';
P.Description := 'Resource handling of Free Component Libraries 
(FCL), FPC''s OOP library.';

P.NeedLibC:= false;

P.OSes:=AllOSes-[embedded,msdos,win16,macosclassic,palmos,zxspectrum,msxdos,amstradcpc];

if Defaults.CPU=jvm then
  P.OSes := P.OSes - [java,android];

P.SourcePath.Add('src');
P.IncludePath.Add('src');

T:=P.Targets.AddUnit('acceleratorsresource.pp');
  with T.Dependencies do
begin
  AddUnit('resource');
  AddUnit('resfactory');
end;
T:=P.Targets.AddUnit('bitmapresource.pp');
  with T.Dependencies do
begin
  AddUnit('resource');
  AddUnit('resfactory');
  AddUnit('resdatastream');
end;
T:=P.Targets.AddUnit('coffconsts.pp');
T:=P.Targets.AddUnit('cofftypes.pp');
T:=P.Targets.AddUnit('coffreader.pp');
  with T.Dependencies do
begin
  AddUnit('resource');
  AddUnit('resourcetree');
  AddUnit('cofftypes');
  AddUnit('coffconsts');
  AddUnit('resdatastream');
end;
T:=P.Targets.AddUnit('coffwriter.pp');
  with T.Dependencies do
begin
  AddUnit('resource');
  AddUnit('resourcetree');
  AddUnit('cofftypes');
  AddUnit('coffconsts');
end;
T:=P.Targets.AddUnit('xcoffwriter.pp');
  with T.Dependencies do
begin
  AddUnit('cofftypes');
  AddUnit('coffwriter');
  AddUnit('coffconsts');
  AddUnit('fpcrestypes');
end;
T:=P.Targets.AddUnit('dfmreader.pp');
  with T.Dependencies do
begin
  AddUnit('resource');
  AddUnit('resdatastream');
  AddUnit('resfactory');
end;
T:=P.Targets.AddUnit('tlbreader.pp');
  with T.Dependencies do
begin
  AddUnit('resource');
  AddUnit('resdatastream');
  AddUnit('resfactory');
end;
T:=P.Targets.AddUnit('elfconsts.pp');

Re: [fpc-pascal] fpcmake packaging

2020-09-01 Thread Ryan Joseph via fpc-pascal


> On Sep 1, 2020, at 7:46 PM, Tony Whyman via fpc-pascal 
>  wrote:
> 
> fpcmake is a pre-processor that generates makefiles for fpc projects. You can 
> use it to do just about anything a standard makefile can do, including 
> including resource files and running scripts. I use it all the time for 
> building production versions of lazarus programs and prior to packaging the 
> programs and resources in .deb and .rpm files.
> 
> On 01/09/2020 13:37, Ryan Joseph via fpc-pascal wrote:
> 

Apparently there is fpmake and fpcmake, which I didn't know.

I guess what you're saying is that I start with fpcmake and get makefiles which 
I can then use to do packing and all the stuff I need? I've thought of using 
makefiles before but I ran into the problem of have all this logic that I need 
to duplicate for each project. What I'm really after is something more like 
lazbuild that takes a config file and does all the commands for you. I guess I 
could even use lazbuild but again, the packaging doesn't seem possible since 
lazbuild is so Lazarus focused (obviously).

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpcmake packaging

2020-09-01 Thread Tony Whyman via fpc-pascal
fpcmake is a pre-processor that generates makefiles for fpc projects. 
You can use it to do just about anything a standard makefile can do, 
including including resource files and running scripts. I use it all the 
time for building production versions of lazarus programs and prior to 
packaging the programs and resources in .deb and .rpm files.


On 01/09/2020 13:37, Ryan Joseph via fpc-pascal wrote:

I've never used fpcmake before and instead relied on my own custom build system 
solutions which are a pain to maintain and non-standard which it makes extra 
work configuring the pascal language server I'm using now.

My first question of fpcmake is, can I package application bundles and copy 
resources using it? For example some things I need to do:

- create a directory structure and copy the executable into it
- copy resource files that may have changed
- run some shell commands which apple provides for compiling various resources 
files
- copy a info.plist text file and replace some patterns in the file to reflect 
the build version

Are those the kind of things fpcmake can do or do I need another build system 
for this?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] fpcmake packaging

2020-09-01 Thread Michael Van Canneyt via fpc-pascal



On Tue, 1 Sep 2020, Ryan Joseph via fpc-pascal wrote:


I've never used fpcmake before and instead relied on my own custom build system 
solutions which are a pain to maintain and non-standard which it makes extra 
work configuring the pascal language server I'm using now.

My first question of fpcmake is, can I package application bundles and copy 
resources using it? For example some things I need to do:

- create a directory structure and copy the executable into it
- copy resource files that may have changed
- run some shell commands which apple provides for compiling various resources 
files
- copy a info.plist text file and replace some patterns in the file to reflect 
the build version

Are those the kind of things fpcmake can do or do I need another build system 
for this?


Are you talking about fpcmake or fpmake ?
The former just generates a Makefile based on a .ini template.

The latter is an environment for compiling, but it is pascal code so you can
do anything you want in it.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] fpcmake packaging

2020-09-01 Thread Ryan Joseph via fpc-pascal
I've never used fpcmake before and instead relied on my own custom build system 
solutions which are a pain to maintain and non-standard which it makes extra 
work configuring the pascal language server I'm using now.

My first question of fpcmake is, can I package application bundles and copy 
resources using it? For example some things I need to do:

- create a directory structure and copy the executable into it
- copy resource files that may have changed
- run some shell commands which apple provides for compiling various resources 
files
- copy a info.plist text file and replace some patterns in the file to reflect 
the build version

Are those the kind of things fpcmake can do or do I need another build system 
for this?

Regards,
Ryan Joseph

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using built-in serial instead of synaser and the like for Linux console app?

2020-09-01 Thread Michael Van Canneyt via fpc-pascal



On Tue, 1 Sep 2020, Bo Berglund via fpc-pascal wrote:


On Tue, 01 Sep 2020 10:22:08 +0200, Bo Berglund via fpc-pascal
 wrote:


Maybe I could tie the timeout to the actual baud used? Slower speeds
use longer timeout etc? Timeout could be set to the time it takes to
transfer the number of bytes to read?

And both arguments could be made properties of the class such that the
user can tweak performance a bit?


I tried to do this:

 TComPortReadThread=class(TThread)
 private
   FBuffer: TBytes;
   FPacketSize: integer; default 10;
   FReadTimeout: integer; default 10;
 public
   MustDie: boolean;
   Owner: TFpSerialPort;
   property ReadPacketSize: integer read FPacketSize write
FPacketSize; //How many bytes to read in each operation
   property ReadTimeout: integer read FReadTimeout write
FReadTimeout;//Max time to wait for data in thread
 protected
   procedure CallEvent;
   procedure Execute; override;
 published
   property Terminated;
 end;

But I cannot set the default value of the two new fields FPacketSize
and FReadTimeout, I get an error in the above code (and variations of
the same).
Is there no way to declare a property to have a default non-zero
value?


You must set it on the property:

Property property ReadPacketSize: integer read FPacketSize write FPacketSize 
default 10;

Note that this does not actually set the property to the indicated value. It
is only a hint for the streaming system:

You must still set the default value in the constructor.



Note that the thread itself has no idea what is the baudrate in use so
it cannot calculate the proper value at the start of Execute...
And there is no Create method either that I can use.


The constructor can always be overridden.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using built-in serial instead of synaser and the like for Linux console app?

2020-09-01 Thread Jean SUZINEAU via fpc-pascal
Ooops, wrong url, I just learn know that property could belong to a 
global block... ;-)


For classes:

https://www.freepascal.org/docs-html/ref/refsu33.html#x86-1080006.7.1

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using built-in serial instead of synaser and the like for Linux console app?

2020-09-01 Thread Jean SUZINEAU via fpc-pascal

Le 01/09/2020 à 10:49, Bo Berglund via fpc-pascal a écrit :

Is there no way to declare a property to have a default non-zero

value?


I'm not sure but I think the syntax is for this something like

property ReadPacketSize: integer read FPacketSize write FPacketSize default 10;

Reference: https://www.freepascal.org/docs-html/ref/refse27.html

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux GTK-2 GUI app

2020-09-01 Thread Michael Van Canneyt via fpc-pascal



On Tue, 1 Sep 2020, Adriaan van Os via fpc-pascal wrote:


leledumbo via fpc-pascal wrote:

Or create different packages for different distros ?


If you can afford the maintenance burden, this is the best that every
specific distro user will love. Otherwise, just provide a compressed 

archive

with README inside.


What about  flatpak or snap-pak packages ?


I may be not a good reference, but I've never installed a flatpack or
snap-pak, nor have I seen a system where this was used.

If your app has not too many requirements, I don't think they are worth the 
effort.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux GTK-2 GUI app

2020-09-01 Thread Adriaan van Os via fpc-pascal

leledumbo via fpc-pascal wrote:

Or create different packages for different distros ?


If you can afford the maintenance burden, this is the best that every
specific distro user will love. Otherwise, just provide a compressed archive
with README inside.


What about  flatpak or snap-pak packages ?

Regards,

Adriaan van Os
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using built-in serial instead of synaser and the like for Linux console app?

2020-09-01 Thread Bo Berglund via fpc-pascal
On Tue, 01 Sep 2020 10:22:08 +0200, Bo Berglund via fpc-pascal
 wrote:

>Maybe I could tie the timeout to the actual baud used? Slower speeds
>use longer timeout etc? Timeout could be set to the time it takes to
>transfer the number of bytes to read?
>
>And both arguments could be made properties of the class such that the
>user can tweak performance a bit?

I tried to do this:

  TComPortReadThread=class(TThread)
  private
FBuffer: TBytes;
FPacketSize: integer; default 10;
FReadTimeout: integer; default 10;
  public
MustDie: boolean;
Owner: TFpSerialPort;
property ReadPacketSize: integer read FPacketSize write
FPacketSize; //How many bytes to read in each operation
property ReadTimeout: integer read FReadTimeout write
FReadTimeout;//Max time to wait for data in thread
  protected
procedure CallEvent;
procedure Execute; override;
  published
property Terminated;
  end;

But I cannot set the default value of the two new fields FPacketSize
and FReadTimeout, I get an error in the above code (and variations of
the same).
Is there no way to declare a property to have a default non-zero
value?

Note that the thread itself has no idea what is the baudrate in use so
it cannot calculate the proper value at the start of Execute...
And there is no Create method either that I can use.

Any ideas?

-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Using built-in serial instead of synaser and the like for Linux console app?

2020-09-01 Thread Bo Berglund via fpc-pascal
On Mon, 31 Aug 2020 12:01:33 +0200, Bo Berglund via fpc-pascal
 wrote:

>Thanks, I was worried about reading more data than specified.
>Now I can let the loop in Execute read say 10 bytes or so with timeout
>ane process these, then loop back after firing off the event.

Just a follow-up for completeness:

I have got it running now and I implemented the fpserialport object
such tghta if it is commanded to open the port without an event
procedure defined it will provide blocking read functions (overloaded
for string vs. TBytes containers).
But if the event is defined it will read the data in the Execute
function in the read thread and provide the data to the user via the
event.

Here is the read thread code (BUFFERSIZE is set to $2000):

TOnRxDataEvent = procedure(Sender: TObject; const Data: TBytes) of
object;

procedure TComPortReadThread.CallEvent;
begin
  if Assigned(Owner.FOnRxData) then
  begin
Owner.FOnRxData(Owner, FBuffer);
  end;
end;

procedure TComPortReadThread.Execute;
var
  Cnt: integer;
begin
  try
SetLength(FBuffer, BUFFERSIZE); //Set buffer size to 8192 bytes.
while not MustDie do
begin
  cnt := SerReadTimeout(Owner.FHandle, FBuffer[0], 10, 10); //Read
10 bytes with timeout of 10 ms
  if  cnt > 0 then
  begin
SetLength(FBuffer, cnt); //Reduce size to fit rx data
Synchronize(CallEvent); //Rx data in FBuffer to caller
SetLength(FBuffer, BUFFERSIZE); //Restore buffer size
  end;
end;
  finally
Terminate;
  end;
end;

So this will fire the event on every 10 bytes received or after the 10
ms timeout, whichever comes first. No event without data, though.

I don't know if this is really OK, my applications are using 38400 and
115200 baud so the 10 bytes will arrive in less than 3 ms at the
slower speed.
But I could not figure out any better way to implement it, save for
firing off the event for every byte arriving, which would cause a lot
of calls...

Maybe I could tie the timeout to the actual baud used? Slower speeds
use longer timeout etc? Timeout could be set to the time it takes to
transfer the number of bytes to read?

And both arguments could be made properties of the class such that the
user can tweak performance a bit?


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal