Lazarus

Programming => Graphics => Graphics and Multimedia => BGRABitmap and LazPaint => Topic started by: winni on April 22, 2019, 09:50:32 pm

Title: BGRA Version Number
Post by: winni on April 22, 2019, 09:50:32 pm
Hi!

Is the BGRA Version Number somewhere stored inside the units?

I didn't find  anything.

If not, this is a wish for future releases:

Put the Version Number somewhere into BGRA.

Thanx, Winni
Title: Re: BGRA Version Number
Post by: dsiders on April 22, 2019, 10:00:30 pm
Hi!

Is the BGRA Version Number somewhere stored inside the units?

I didn't find  anything.

If not, this is a wish for future releases:

Put the Version Number somewhere into BGRA.

Thanx, Winni

I don't see any version constants defined in source code. But version information is in the update_*.json files for the OPM downloads.
Title: Re: BGRA Version Number
Post by: RAW on April 22, 2019, 10:24:11 pm
https://github.com/bgrabitmap/bgrabitmap/releases

It's easier to see with open eyes ...  :P  :)
Title: Re: BGRA Version Number
Post by: lainz on April 22, 2019, 10:25:34 pm
Hi!

Is the BGRA Version Number somewhere stored inside the units?

I didn't find  anything.

If not, this is a wish for future releases:

Put the Version Number somewhere into BGRA.

Thanx, Winni

You need to read it from code? for some reason?
Title: Re: BGRA Version Number
Post by: dsiders on April 22, 2019, 10:36:06 pm
https://github.com/bgrabitmap/bgrabitmap/releases

It's easier to see with open eyes ...  :P  :)

Well that's certainly nice. But how is it relevant to version numbers in uniits?
Title: Re: BGRA Version Number
Post by: winni on April 22, 2019, 11:11:20 pm
@dsiders: It's as relevant as the version number in Lazarurs/LCL is and as the version number in fpc is.

@ RAW: you didn't understand my question

Thanx
Winni
Title: Re: BGRA Version Number
Post by: winni on April 22, 2019, 11:27:46 pm
@lainz: to write some code like

Code: Pascal  [Select][+][-]
  1. const fpcVersion = {$I %FPCVERSION%};
  2. var s : string;
  3.  
  4. begin
  5. s := 'Made with' + lineEnding +
  6.        'fpc version '+ fpcVersion + LineEnding+
  7.        'Lazarus  version '+ LCLVersion + LineEnding +
  8.        'BGRA Version ' + ??BGRAVersion??;
  9. showMessage (s);
  10. end;    
  11.  
  12.  

Got me?
Title: Re: BGRA Version Number
Post by: lainz on April 22, 2019, 11:38:54 pm
It's a good use.

Maybe you can report a bug so this don't get lost:
https://github.com/bgrabitmap/bgrabitmap/issues

Asking to add version number as a constant in the package.
Title: Re: BGRA Version Number
Post by: dsiders on April 23, 2019, 12:27:49 am
@dsiders: It's as relevant as the version number in Lazarurs/LCL is and as the version number in fpc is.

Glad you think so. Have at it.
Title: Re: BGRA Version Number
Post by: winni on April 23, 2019, 03:32:57 pm
Hi!

Add a new issue to BGRA:

https://github.com/bgrabitmap/bgrabitmap/issues/57

Perhaps it doesn't get lost ....

Winni



Title: Re: BGRA Version Number
Post by: circular on April 24, 2019, 09:00:14 pm
I wonder how to retrieve the package version inside a unit. Is it possible ?

Because I would prefer not to have more litteral copies of the version number.
Title: Re: BGRA Version Number
Post by: winni on April 24, 2019, 10:22:19 pm
As there are the package names with version number in the two listboxes in Package --> Configure installed packages (ger.: Installierte Pakete einrichten) one could reach it with following steps:

1) Inside a BGRA unit is a const like
BGRAversion = {$I BGRAversion.inc};
2) Get the package version from the IDE - no idea how to get.
3) If PackageVersion <> BGRAVersion then
     begin
      delete BGRAVersion.inc
       write PackageVersion to new BGRAversion.inc
    end else exit;

Anybody who knows details about the package names inside the IDE??

Winni
Title: Re: BGRA Version Number
Post by: lainz on April 25, 2019, 12:58:32 am
What you can try to do is execute a program every new release is added.

That program reads the version number from the package and stores it into a BGRAVersion.pas for example.

As well it will be usefull to store the version number in the updates JSON for OPM.

Anyways you need to change the version number when releasing, is just another step that can be automatic with that program.
Title: Re: BGRA Version Number
Post by: lucamar on April 25, 2019, 01:07:11 am
What you can try to do is execute a program every new release is added.

That program reads the version number from the package and stores it into a BGRAVersion.pas for example.

Indeed, since the maintainer has to update the JSON with evry release, it wouldn't be too onerous to write a litle utility to which you pass the version number and which updates both the JSON file and a "bgraversion.inc".

It could then be run automatically before/after a "release" mode compilation, with v.g. a couple switches "--include" and "--json" to know which file to update, so before compilation it may run as "updateversion --include X.Y.Z" and after compilation as "updateversion --json X.Y.Z".

And "updateversion --json" would get the version from the "version.inc" and viceversa ...

And maybe ..

Well, just a thought. Design brainstorming ;)

ETA: Thining about, it could be fully automatic, getting the version from the LPI if you have "Version Info" on in the project options. Is that valid for packages?

Ah ... sorry ... I'm stopping now.
Title: Re: BGRA Version Number
Post by: circular on April 25, 2019, 09:59:53 am
Indeed one could do an update program. One of the reason is the JSON file and there is another reason: there are several BGRABitmap packages which are supposed to have the same version number (regular, for fpGUI and for noGUI).

Though I was hoping some compiler directive like:
Code: Delphi  [Select][+][-]
  1. const MyPackageVersion={$PACKAGEVERSION};

@lucamar
About updating, I see you mention the JSON update to be separate from the rest. In some way I agree because the proper way is:
- first update packages with the new version (and merge with master branch)
- make a release on the repository with the new version to get the zip file
- update the JSON file with version number and zip file (and merge with master branch)
- package manager is aware of new version

As a matter of fact, I did the latest releases like this:
- update package and JSON file with new version (and merge with master branch)
- hope package manager does not read it in the next seconds
- make a release to get the zip file

I wonder if that could be a problem.
Title: Re: BGRA Version Number
Post by: lucamar on April 25, 2019, 01:01:17 pm
As a matter of fact, I did the latest releases like this:
- update package and JSON file with new version (and merge with master branch)
- hope package manager does not read it in the next seconds
- make a release to get the zip file

I wonder if that could be a problem.

It's a classic synchronization problem, isn't it? you change something and pray it's not read until you change something else which depends on it :D

I think it's better to make the release first and announce it (in the json) last.
Title: Re: BGRA Version Number
Post by: circular on April 25, 2019, 02:44:10 pm
Indeed.
Title: Re: BGRA Version Number
Post by: circular on April 25, 2019, 02:57:31 pm
Though there is a problem as well with doing the JSON afterwards.

When publishing the version on Github, it creates the zip file with the current content of the JSON file. So if the JSON has not been updated yet, then in the zip file to be downloaded the JSON file will not be up-to-date.
Title: Re: BGRA Version Number
Post by: lainz on April 25, 2019, 04:30:24 pm
What I do is using the zip file of the master branch. Not of specific release.

https://github.com/bgrabitmap/bgracontrols/blob/master/update_bgracontrols_force.json
So when I merge into master I update all package and json at the same time.

The problem can be that someone is downloading the zip file and I just update it at the same time...  That depends on how works the server of GitHub downloads.
Title: Re: BGRA Version Number
Post by: circular on April 25, 2019, 05:20:31 pm
I added the constant and did a program to update. It is on the dev branch of bgrabitmap.

In BGRABitmapTypes there is constant BGRABitmapVersion and function BGRABitmapVersionStr which formats it.
Code: Delphi  [Select][+][-]
  1. const
  2.   BGRABitmapVersion = 9090300;  // that means 9.09.03.00
  3.  
  4.   function BGRABitmapVersionStr: string;  // which returns 9.9.3

Releaser program
This program update the version of any library. It works with an input file (that I called a logic file) that specifies where version numbers are.

It will create the JSON file if it does not exist but is mentionned in the logic file.

The program is in dev/releaser and can be used as a command line.
https://github.com/bgrabitmap/bgrabitmap/tree/dev-bgrabitmap/dev/releaser

Here is the file bgrabitmap.logic for BGRABitmap:
Code: [Select]
cd ..\..
manager update_BGRABitmap.json
archive https://github.com/bgrabitmap/bgrabitmap/archive/v$(Version).zip
cd bgrabitmap
package bgrabitmappack.lpk
package bgrabitmappack4fpgui.lpk
package bgrabitmappack4nogui.lpk
const bgrabitmaptypes.pas BGRABitmapVersion

@lainz
If I understand, you use the same url for the zip file.

I suppose you're wondering if the transfer would be interrupted. That's a good question.

Alos I guess that could lead to following:
- package manager downloads the JSON
- you release a new version
- package manager downloads the new version but stores that the version number is older
Not sure if it matters


Title: Re: BGRA Version Number
Post by: lainz on April 25, 2019, 06:08:45 pm
Thanks I will try to add to BGRAControls as well.

Edit: I try but seems that we have different JSON format, I asked GetMem here
https://forum.lazarus.freepascal.org/index.php/topic,34297.msg319004.html#msg319004
Title: Re: BGRA Version Number
Post by: lucamar on April 25, 2019, 06:59:22 pm
Though there is a problem as well with doing the JSON afterwards.

When publishing the version on Github, it creates the zip file with the current content of the JSON file. So if the JSON has not been updated yet, then in the zip file to be downloaded the JSON file will not be up-to-date.

Then update the JSON before zipping. :)

I'll have to give a look to that releaser: it may save me the time of writing my own if it can be adapted to my needs. I'm geting tired of clumsy, mostly ad-hoc scripts  ;)
Title: Re: BGRA Version Number
Post by: circular on April 25, 2019, 07:22:35 pm
Thanks I will try to add to BGRAControls as well.

Edit: I try but seems that we have different JSON format, I asked GetMem here
https://forum.lazarus.freepascal.org/index.php/topic,34297.msg319004.html#msg319004
I've added some code to handle both formats. Does it work for you now?
Title: Re: BGRA Version Number
Post by: circular on April 25, 2019, 07:26:09 pm
Though there is a problem as well with doing the JSON afterwards.

When publishing the version on Github, it creates the zip file with the current content of the JSON file. So if the JSON has not been updated yet, then in the zip file to be downloaded the JSON file will not be up-to-date.

Then update the JSON before zipping. :)
The thing is the zip is done by GitHub when releasing the version, which is done on the master branch, which contains the JSON. So indeed I update the JSON before doing the release. So for a few seconds, the link to the zip file doesn't work.

Quote
I'll have to give a look to that releaser: it may save me the time of writing my own if it can be adapted to my needs. I'm geting tired of clumsy, mostly ad-hoc scripts  ;)
Ok. If you have some improvements, I will be happy to hear about it.
Title: Re: BGRA Version Number
Post by: lainz on April 25, 2019, 09:15:32 pm
Thanks, now it works fine =)

BGRAControlsInfo.pas is the unit for BGRAControls version number, exactly the same as in BGRABitmap.
Title: Re: BGRA Version Number
Post by: circular on May 16, 2019, 09:32:29 pm
I've added support for projects (programs or libraries) to the releaser. Also the ($LogicDir) constant can be used, so that you can process the logic file from an current directory.

Here is for example the logic file for LazPaint:
Code: [Select]
cd ($LogicDir)/lazpaint
project lazpaint.lpi
package lazpaintembeddedpack.lpk
const lazpainttype.pas LazPaintVersion
TinyPortal © 2005-2018