benibela / xidel

Command line tool to download and extract data from HTML/XML pages or JSON-APIs, using CSS, XPath 3.0, XQuery 3.0, JSONiq or pattern matching. It can also create new or transformed XML/HTML/JSON documents.
http://www.videlibri.de/xidel.html
GNU General Public License v3.0
681 stars 42 forks source link

Mac Silicon build? #75

Open boticello opened 3 years ago

boticello commented 3 years ago

Could you make a binary available for Mac Silicon (ARM)?

I tried to build from source, but had the following error:

Free Pascal Compiler version 3.2.2 [2021/06/03] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Darwin for x86_64
Compiling xidel.pas
xidel.pas(33,6) Fatal: Can't find unit internetaccess used by xidel
Fatal: Compilation aborted
Error: /opt/homebrew/bin/ppcx64 returned an error exitcode

I had installed fpc--3.2.2.arm64_big_sur.bottle.tar.gzvia homebrew.

Reino17 commented 3 years ago

I tried to build from source...

If that source is only https://github.com/benibela/xidel.git, then the error is expected.
Better to use the SourceForge repository instead, which, except for FLRE, has all the necessary components.

$ hg clone http://hg.code.sf.net/p/videlibri/code videlibri-code_hg
$ git clone https://github.com/benibela/flre.git flre_git

$ cd videlibri-code_hg/

$ echo "writeln('($(hg log -l 1 -T '{date|shortdate}.{rev}.{node|short}' | tr -d '-'))');" > programs/internet/xidel/xidelbuilddata.inc

$ fpc -O3 -Cort -CX -XX -Xs -dUSE_SYNAPSE_WRAPPER \
-FEprograms/internet/xidel \
-Fucomponents/pascal/internet \
-Fucomponents/pascal/data \
-Ficomponents/pascal/data \
-Fu../flre_git/src \
-Fucomponents/pascal/system \
-Fucomponents/pascal/import/synapse \
-Ficomponents/pascal/import/synapse \
-Fuprograms/internet/xidel \
-Fiprograms/internet/xidel \
programs/internet/xidel/xidel.pas

It is possible to compile xidel from all the Github sources, but as the "Synapse OpenSSL initialization" can still only be found on SourceForge, you do still need it. I've asked Benito if he could copy the "Synapse OpenSSL initialization" to Github as well, but he hasn't responded.

$ git clone https://github.com/benibela/xidel.git xidel_git
$ git clone https://github.com/benibela/internettools.git internettools_git
$ git clone https://github.com/benibela/flre.git flre_git
$ git clone https://github.com/benibela/rcmdline.git rcmdline_git
$ hg clone http://hg.code.sf.net/p/videlibri/code videlibri-code_hg

$ cd xidel_git/

Now, the creation of 'xidelbuilddata.inc' is personal and a matter of taste. I use this exotic command...

$ echo -e "writeln('$(git describe --tags | sed 's/_/ /')-openssl    ($(git log -1 --date=format:%Y%m%d --pretty=format:%cd))');\nwriteln('  $(git --git-dir=../internettools_git/.git describe --tags | sed 's/VIDELIBRI_/internettools /') ($(git --git-dir=../internettools_git/.git log -1 --date=format:%Y%m%d --pretty=format:%cd))');\nwriteln('  $(git --git-dir=../rcmdline_git/.git describe --tags | sed 's/Xidel_/rcmdline         /') ($(git --git-dir=../rcmdline_git/.git log -1 --date=format:%Y%m%d --pretty=format:%cd))');\nwriteln('  flre                    g$(git --git-dir=../flre_git/.git rev-parse --short HEAD) ($(git --git-dir=../flre_git/.git log -1 --date=format:%Y%m%d --pretty=format:%cd))');" > xidelbuilddata.inc

$ cat xidelbuilddata.inc
writeln('Xidel 0.9.8-97-g6d3b344-openssl    (20210720)');
writeln('  internettools 2.180-219-g57263ab (20210720)');
writeln('  rcmdline         0.7-21-gd8b69ae (20201228)');
writeln('  flre                    g0dfdae7 (20210412)');

...and apply the following change...

$ cat ../remove_getVersionString.diff
diff --git a/xidelbase.pas b/xidelbase.pas
index 42773be..f76af2a 100644
--- a/xidelbase.pas
+++ b/xidelbase.pas
@@ -3331,21 +3331,12 @@ begin
   end;
 end;

-function getVersionString: string;
-begin
-  result := IntToStr(majorVersion)+'.'+IntToStr(minorVersion);
-  if buildVersion <> 0 then result += '.'+IntToStr(buildVersion);
-  if Result = '0.8.4' then result += ' (Balisage edition)'
-end;
-
 procedure printVersion;
 begin
-  writeln('Xidel '+getVersionString);
   {$I xidelbuilddata.inc} //more version information to print. if you do not have the file, just create an empty one or remove this line
-  writeln('');
+  writeln();
   writeln('http://www.videlibri.de/xidel.html');
   writeln('by Benito van der Zander <benito@benibela.de>');
-  writeln();
 end;

 procedure printUsage;
@@ -3643,7 +3634,7 @@ begin
   mycmdline.declareFlag('deprecated-string-options', 'Replaces the old $foo; variables with the new {$foo} in arguments');
   mycmdline.declareFlag('deprecated-trim-nodes', 'Removes all surrounding white space of all nodes.');

-  mycmdLine.declareFlag('version','Print version number ('+getVersionString+')');
+  mycmdLine.declareFlag('version','Print version number');
   mycmdLine.declareFlag('usage','Print help, examples and usage information');
   mycmdLine.declareFlag('quiet','-quiet,-q is outdated. Use --silent,-s', 'q');
patch -p1 < ../remove_getVersionString.diff
$ fpc -O3 -Cort -CX -XX -Xs -dUSE_SYNAPSE_WRAPPER \
-FE. \
-Fu../internettools_git/internet \
-Fu../internettools_git/data \
-Fi../internettools_git/data \
-Fu../rcmdline_git \
-Fu../flre_git/src \
-Fu../videlibri-code_hg/components/pascal/import/synapse \
-Fi../videlibri-code_hg/components/pascal/import/synapse \
xidel.pas

[...]

$ ./xidel --version
Xidel 0.9.8-97-g6d3b344-openssl    (20210720)
  internettools 2.180-219-g57263ab (20210720)
  rcmdline         0.7-21-gd8b69ae (20201228)
  flre                    g0dfdae7 (20210412)

http://www.videlibri.de/xidel.html
by Benito van der Zander <benito@benibela.de>
benibela commented 3 years ago

I've asked Benito if he could copy the "Synapse OpenSSL initialization" to Github as well, but he hasn't responded.

I had put it here: https://github.com/benibela/ararat-synapse/

Now, the creation of 'xidelbuilddata.inc' is personal and a matter of taste. I use this exotic command...

Now that will just confuse people

Reino17 commented 3 years ago

I'd disagree. It perfectly sums up the snapshots of the integrated / required components. And the g in front of the commit hash means Github of course.

What actually is confusing in my opinion is the fact that you build / release xidel from a private repository, resulting in a different revision number and commit hash compared to http://hg.code.sf.net/p/videlibri/code.

$ xidel --version
Xidel 0.9.9
(20210720.7961.2e0374a546a6)

$ hg -R videlibri-code_hg log -l 1 -T '{date|shortdate}.{rev}.{node|short}' | tr -d '-'
20210720.6547.5041ce265dac