sciapp / gr

GR framework: a graphics library for visualisation applications
Other
328 stars 54 forks source link

Update homebrew formula? #98

Closed kojix2 closed 4 years ago

kojix2 commented 4 years ago

https://github.com/Homebrew/homebrew-core/blob/master/Formula/libgr.rb v0.37.0

@brodock added gr to homebrew in in February 2019. https://github.com/SciRuby/rubyplot/issues/39

FlorianRhiem commented 4 years ago

It looks like this isn't something we can fix on our end, but an issue with homebrew. Perhaps @brodock or a homebrew maintainer can fix this?

As far as I'm aware none of the core GR developers uses homebrew and in general we recommend using our binaries, e.g. for v0.44.1 on macOS. We upload binaries for macOS, Windows and several Linux distributions to GitHub with each release.

brodock commented 4 years ago

I can upgrade the formula... it's actually quite easy now that it is there, it's a matter of pointing to a new binary and updating the hash (and submitting to homebrew)

brodock commented 4 years ago

I will document the process here, and perhaps this can be added as part of gr development documentation for future need.

FlorianRhiem commented 4 years ago

I can upgrade the formula... it's actually quite easy now that it is there, it's a matter of pointing to a new binary and updating the hash (and submitting to homebrew)

Ah, so the make self call is just a fallback?

brodock commented 4 years ago

Here is a little walkthrough of the steps:

  1. brew edit libgr
  2. In your editor: remove sha256 and bottled block, point to the new version in url line
  3. Try to run brew install --verbose --debug libgr and see if anything breaks
  4. Add sha256 again
  5. Run brew test libgr (which will execute the embedded test)
  6. Run audit command (probably brew audit --strict --online libgr and fix any violation there)
  7. Submit a new PR

Few important documentation:

for this version it seems to require openh264 as I got an error:

ERROR: openh264 not found using pkg-config

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "ffbuild/config.log" produced by configure as this will help
solve the problem.
make[2]: *** [/private/tmp/libgr-20191210-90052-1s8dowd/gr-0.44.1/3rdparty/build/src/ffmpeg-4.2.1/Makefile] Error 1
make[1]: *** [extras] Error 2
make: *** [self] Error 2
/usr/bin/curl --version
/usr/libexec/java_home --xml --failfast
/usr/libexec/java_home --xml --failfast
/usr/local/Homebrew/Library/Homebrew/debrew.rb:13:in `raise'
BuildError: Failed executing: make self GRDIR=/usr/local/Cellar/libgr/0.44.1
1. raise
2. ignore
3. backtrace
4. irb
5. shell
Choose an action:

is it an optional dependency ? another cool thing you can do with the homebrew formula is to offer optional flags when installing it. So you can them translate the flags into different ways you can build it.

brodock commented 4 years ago

I'm trying to rebuild including openh264 as a dependency 🤞

brodock commented 4 years ago
cd /private/tmp/libgr-20191210-40748-1lscrr8/gr-0.44.1/3rdparty/build/src/ && tar -xf libopenh264-2.0.0.tar.gz && mv openh264-2.0.0 libopenh264-2.0.0
touch /private/tmp/libgr-20191210-40748-1lscrr8/gr-0.44.1/3rdparty/build/src/libopenh264-2.0.0/Makefile
/Applications/Xcode.app/Contents/Developer/usr/bin/make -j4 -C /private/tmp/libgr-20191210-40748-1lscrr8/gr-0.44.1/3rdparty/build/src/libopenh264-2.0.0 install-static USE_ASM=No PREFIX=/private/tmp/libgr-20191210-40748-1lscrr8/gr-0.44.1/3rdparty/build  CFLAGS=-mmacosx-version-min=10.11
make[3]: warning: -jN forced in submake: disabling jobserver mode.
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/au_set.o codec/encoder/core/src/au_set.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/deblocking.o codec/encoder/core/src/deblocking.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/decode_mb_aux.o codec/encoder/core/src/decode_mb_aux.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/encode_mb_aux.o codec/encoder/core/src/encode_mb_aux.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/encoder.o codec/encoder/core/src/encoder.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/encoder_data_tables.o codec/encoder/core/src/encoder_data_tables.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/encoder_ext.o codec/encoder/core/src/encoder_ext.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/get_intra_predictor.o codec/encoder/core/src/get_intra_predictor.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/md.o codec/encoder/core/src/md.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/mv_pred.o codec/encoder/core/src/mv_pred.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/nal_encap.o codec/encoder/core/src/nal_encap.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/paraset_strategy.o codec/encoder/core/src/paraset_strategy.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/picture_handle.o codec/encoder/core/src/picture_handle.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/ratectl.o codec/encoder/core/src/ratectl.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/ref_list_mgr_svc.o codec/encoder/core/src/ref_list_mgr_svc.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/sample.o codec/encoder/core/src/sample.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/set_mb_syn_cabac.o codec/encoder/core/src/set_mb_syn_cabac.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/set_mb_syn_cavlc.o codec/encoder/core/src/set_mb_syn_cavlc.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/slice_multi_threading.o codec/encoder/core/src/slice_multi_threading.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/svc_base_layer_md.o codec/encoder/core/src/svc_base_layer_md.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/svc_enc_slice_segment.o codec/encoder/core/src/svc_enc_slice_segment.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/svc_encode_mb.o codec/encoder/core/src/svc_encode_mb.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/svc_encode_slice.o codec/encoder/core/src/svc_encode_slice.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/svc_mode_decision.o codec/encoder/core/src/svc_mode_decision.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/svc_motion_estimate.o codec/encoder/core/src/svc_motion_estimate.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/svc_set_mb_syn_cabac.o codec/encoder/core/src/svc_set_mb_syn_cabac.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/svc_set_mb_syn_cavlc.o codec/encoder/core/src/svc_set_mb_syn_cavlc.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/wels_preprocess.o codec/encoder/core/src/wels_preprocess.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/wels_task_base.o codec/encoder/core/src/wels_task_base.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/wels_task_encoder.o codec/encoder/core/src/wels_task_encoder.cpp
clang++ -mmacosx-version-min=10.11  -I./codec/api/svc -I./codec/common/inc -Icodec/common/inc  -I./codec/encoder/core/inc -I./codec/encoder/plus/inc -I./codec/processing/interface -c -o codec/encoder/core/src/wels_task_management.o codec/encoder/core/src/wels_task_management.cpp
sh ./codec/common/generate_version.sh ./
fatal: not a git repository (or any of the parent directories): .git

this needs a patch: sh ./codec/common/generate_version.sh ./

I'm trying to avoid using the bundled 3rdparty and have homebrew handle them to see if it helps

kojix2 commented 4 years ago

Great! Please go on.

brodock commented 4 years ago

there seems to be some issue with lacking 64bits symbols somewhere:

cc -o cairoplugin.so -shared -L/private/tmp/libgr-20191211-11240-hradtz/gr-0.44.1/3rdparty/build/lib -mmacosx-version-min=10.11 cairoplugin.o ../libGKS.a /private/tmp/libgr-20191211-11240-hradtz/gr-0.44.1/3rdparty/build/lib/libcairo.a /private/tmp/libgr-20191211-11240-hradtz/gr-0.44.1/3rdparty/build/lib/libpixman-1.a /private/tmp/libgr-20191211-11240-hradtz/gr-0.44.1/3rdparty/build/lib/libfreetype.a /private/tmp/libgr-20191211-11240-hradtz/gr-0.44.1/3rdparty/build/lib/libjpeg.a /private/tmp/libgr-20191211-11240-hradtz/gr-0.44.1/3rdparty/build/lib/libpng.a -ltiff /private/tmp/libgr-20191211-11240-hradtz/gr-0.44.1/3rdparty/build/lib/libz.a -liconv -DNO_X11
2019-12-11 18:24:19.254 xcodebuild[43464:228265]  iOSSimulator: [SimServiceContext sharedServiceContextForDeveloperDir:error:] returned nil (Error Domain=DVTCoreSimulatorAdditionsErrorDomain Code=3 "CoreSimulator is out of date. Current version (681.15.0) is older than build version (681.17.0)." UserInfo={NSLocalizedDescription=CoreSimulator is out of date. Current version (681.15.0) is older than build version (681.17.0).}). Simulator device support disabled.
clang++ -o quartzplugin.so -shared quartzplugin.o ../libGKS.a -liconv  \
    -lobjc -framework Foundation -framework ApplicationServices -framework AppKit
Undefined symbols for architecture x86_64:
  "_zmq_close", referenced from:
      _gksterm_communicate in quartzplugin.o
  "_zmq_connect", referenced from:
      _gksterm_communicate in quartzplugin.o
  "_zmq_ctx_new", referenced from:
      _gksterm_communicate in quartzplugin.o
  "_zmq_ctx_term", referenced from:
      _gksterm_communicate in quartzplugin.o
  "_zmq_msg_close", referenced from:
      _gksterm_communicate in quartzplugin.o
  "_zmq_msg_data", referenced from:
      _gksterm_communicate in quartzplugin.o
  "_zmq_msg_init", referenced from:
      _gksterm_communicate in quartzplugin.o
  "_zmq_msg_init_size", referenced from:
      _gksterm_communicate in quartzplugin.o
  "_zmq_msg_recv", referenced from:
      _gksterm_communicate in quartzplugin.o
  "_zmq_msg_send", referenced from:
      _gksterm_communicate in quartzplugin.o
  "_zmq_setsockopt", referenced from:
      _gksterm_communicate in quartzplugin.o
  "_zmq_socket", referenced from:
      _gksterm_communicate in quartzplugin.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[5]: *** [quartzplugin.so] Error 1
make[4]: *** [default] Error 2
make[3]: *** [plugins] Error 2
make[3]: *** Waiting for unfinished jobs....
note: Using new build system
note: Planning build
note: Constructing build description

I will push what I've got so far to a branch and see if someone can point me to the right direction

brodock commented 4 years ago

https://github.com/Homebrew/homebrew-core/compare/master...brodock:upgrade-libgr-formula-0.44.1?expand=1#diff-6952b333b951ad94c0a675e9df126579

you can try locally by simply editing your local version of the Formula (brew edit libgr)

brodock commented 4 years ago

I'm using https://github.com/sciapp/gr/blob/master/.gitlab-ci.yml#L627-L666 as base to try to build it in different ways...

to try to execute the build manually you can brew install --interactive libgr and that will drop you into a contained environment where you can execute the same commands as the formula would and inspect any intermediate state you need to debug.

brodock commented 4 years ago

there are a some major differences from the formula and what is there:

brodock commented 4 years ago

Adding back zeromq to EXTRA made it pass, I still can't skip QT build, any idea?

kojix2 commented 4 years ago

Thanks @brodock . I'm afraid that I don't know how to build C source code. But when I tried to do it myself, I got the following error:

class Libgr < Formula
   desc "GR framework: a graphics library for visualisation applications"
   homepage "https://gr-framework.org/"
   url "https://github.com/sciapp/gr/archive/v0.41.1.tar.gz"

   depends_on :xcode => :build
   depends_on "cairo"
   depends_on "pkg-config"

   def install
     system "make", "self", "GRDIR=#{prefix}"
   end

   test do
     (testpath/"test.c").write <<~EOS
       #include <stdio.h>
       #include <gr.h>

       int main(void) {
           gr_opengks();
           gr_openws(1, "test.png", 140);
           double x[] = {0, 0.2, 0.4, 0.6, 0.8, 1.0};
           double y[] = {0.3, 0.5, 0.4, 0.2, 0.6, 0.7};
           gr_polyline(6, x, y);
           gr_axes(gr_tick(0, 1), gr_tick(0, 1), 0, 0, 1, 1, -0.01);
           gr_updatews();
           gr_emergencyclosegks();
           return 0;
       }
     EOS

     system ENV.cc, "test.c", "-o", "test", "-I#{include}", "-L#{lib}", "-lGR"
     system "./test"

     assert_predicate testpath/"test.png", :exist?
   end
 end

Error

/Applications/Xcode.app/Contents/Developer/usr/bin/make -C lib/gks GRDIR=/usr/local/Cellar/libgr/0.41.1 install
cp -p libGKS.* /usr/local/Cellar/libgr/0.41.1/lib
cp -p plugin/*plugin.so /usr/local/Cellar/libgr/0.41.1/lib
cp -p gksm /usr/local/Cellar/libgr/0.41.1/bin
cp -a fonts/* /usr/local/Cellar/libgr/0.41.1/fonts
cp -p gks.h /usr/local/Cellar/libgr/0.41.1/include
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C qt -f makefile.mak install
ditto: can't get real path for source 'gksqt.app'
make[3]: *** [install] Error 1
make[2]: *** [install] Error 2
make[1]: *** [install] Error 2
make: *** [self] Error 2
/usr/bin/curl --version
/usr/libexec/java_home --xml --failfast
/usr/libexec/java_home --xml --failfast
/usr/local/Homebrew/Library/Homebrew/debrew.rb:13:in `raise'
BuildError: Failed executing: make self GRDIR=/usr/local/Cellar/libgr/0.41.1
1. raise
2. ignore
3. backtrace
4. irb
5. shell
kojix2 commented 4 years ago

Sorry. It's not very informative. I just want to do something.

brodock commented 4 years ago

I am stuck there as well...

this lines are important:

/Applications/Xcode.app/Contents/Developer/usr/bin/make -C qt -f makefile.mak install
ditto: can't get real path for source 'gksqt.app'
make[3]: *** [install] Error 1
make[2]: *** [install] Error 2
make[1]: *** [install] Error 2
make: *** [self] Error 2

make is the "build/task runner", it is passing option qt to makefile.mak while asking it to run "install" target...

this suggests we are still trying to install something that was built with qt, even though QT was skipped by the makefile before as it didn't find it as an available dependency.

brodock commented 4 years ago

if you go back into your build log you should see this:

/Applications/Xcode.app/Contents/Developer/usr/bin/make -C ../.. Makedefs

Building GR Framework
---------------------
           C: yes [Apple clang version 11.0.0 (clang-1100.0.33.16)]
         C++: yes [Apple clang version 11.0.0 (clang-1100.0.33.16)]
      Python: yes [version 2.7.17 (default, Nov 20 2019, 06:53:26) ]
       LaTeX:  no [not found]
      dvipng:  no [not found]
         Qt4:  no [Qt4 API not found]
         Qt5:  no [Qt5 API not found]
   wxWidgets: yes [version 3.0.4]
        GTK+:  no [disabled]
         X11:  no [disabled]
         Xft:  no [disabled]
 Ghostscript:  no [disabled]
        GLFW: yes [version 3.1.1]
         0MQ: yes [version 4.0.4]
lib/Preflight: line 517: 23647 Abort trap: 6           $tmpout > $tmpver 2>&1
      ffmpeg:  no [required APIs not found]
       Cairo: yes [version 1.14.6]
     libtiff: yes [version 4.0.10]

the idea behind make and a Makefile is that you can programatically include/exclude things that will be compiled as part of your final build... usually a Makefile will have some code that will choose between compatible dependencies and deal with differences related with OS type OS versions / architecture etc... it's a bit convoluted but it works in the end.

kojix2 commented 4 years ago

https://github.com/Homebrew/homebrew-core/pull/40214 @igas and @fxcoudert tried to update libgr several months ago. But not merged.

kojix2 commented 4 years ago

Good figure. https://gr-framework.org/about.html image

kojix2 commented 4 years ago

@kou created the pull request for libgr. Thanks!! https://github.com/Homebrew/homebrew-core/pull/48190

kou commented 4 years ago

It has been merged. @kojix2 Could you close this?

kojix2 commented 4 years ago

Thanks @kou @brodock Finally, the libgr formula has been updated. This will be very helpful for Mac users.

@FlorianRhiem The formula will be updated by someone in the user community...

kojix2 commented 4 years ago

Updated homebrew formulae to 0.46.0 https://github.com/Homebrew/homebrew-core/pull/49508

Some people told me that zeromq is a bit old and can cause problems when the new version of libsodium is installed on Mac. So, please consider upgrading zeromq if you like.

Thank you.

kou commented 4 years ago

I think that we should not reuse closed issue. How about opening a new issue for new request?

kojix2 commented 4 years ago

@kou OK... But I don't have a clear understanding of this problem.

kojix2 commented 3 years ago

I made a pull request to homebrew-core to change it to use cmake. https://github.com/Homebrew/homebrew-core/pull/60750