Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashlink 1.11 (new formula) #53790

Closed
wants to merge 1 commit into from
Closed

Conversation

jdonaldson
Copy link
Contributor

@jdonaldson jdonaldson commented Apr 26, 2020

  • Have you followed the guidelines for contributing?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing brew install <formula>)?

@Bo98 Bo98 changed the title hashlink source build support hashlink 1.11 (new formula) Apr 26, 2020
@Bo98 Bo98 added the new formula PR adds a new formula to Homebrew/homebrew-core label Apr 26, 2020
desc "Virtual machine for Haxe"
homepage "https://hashlink.haxe.org/"
url "https://github.com/HaxeFoundation/hashlink.git",
:tag =>"1.11"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a revision as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change this, but it's strange that :tag is permitted at all in that case, since it could conflict with :revision.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn't, tags can be recreated. The revision makes sure that doesn't happen without us knowing about it.

end

test do
system "hl", "--version"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a test that exercises the some of the functionality of the app. Version checks or usage checks (foo --version or foo --help) are not sufficient, as explained in the formula cookbook.

In most cases, a good test would involve running a simple test case: run #{bin}/foo input.txt.

  • Then you can check that the output is as expected (with assert_equal or assert_match on the output of shell_output)
  • You can also check that an output file was created, if that is expected: assert_predicate testpath/"output.txt", :exist?

Some advice for specific cases:

  • If the formula is a library, compile and run some simple code that links against it. It could be taken from upstream's documentation / source examples.
  • If the formula is for a GUI program, try to find some function that runs as command-line only, like a format conversion, reading or displaying a config file, etc.
  • If the software cannot function without credentials, a test could be to try to connect with invalid credentials (or without credentials) and confirm that it fails as expected.
  • Same if the software requires a virtual machine, docker instance, etc. to be running.

Copy link
Contributor Author

@jdonaldson jdonaldson Apr 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HL is a bytecode runtime, so none of the suggestions apply. I'm also not seeing helpful examples in any of the more popular runtimes. What would be a good test for a bytecode interpreter? I tried embedding bytecode in the ruby file with no luck.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E.g., I could create a small "hello world" example, but it would need to be in a separate file, and I'm not seeing anything analogous to this approach in homebrew-core.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could download an example from somewhere using a resource block

@jdonaldson
Copy link
Contributor Author

Latest update adds a simple "hello world" test

homepage "https://hashlink.haxe.org/"
version "1.11"
url "https://github.com/HaxeFoundation/hashlink.git",
:revision=>"cd269136628a1d445b2253ded9fd10ab9fe2f9be" # v 1.11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to have the tag and the revision.

@SMillerDev
Copy link
Member

You have style issues now.

@jdonaldson
Copy link
Contributor Author

Updated once more.

@jdonaldson
Copy link
Contributor Author

I'm seeing a CI/test failure:

==> FAILED
Error: 1 problem in 1 formula detected
hashlink:
  * Non-libraries were installed to "/usr/local/opt/hashlink/lib"
    Installing non-libraries to "lib" is discouraged.
    The offending files are:
      /usr/local/opt/hashlink/lib/ui.hdll
            /usr/local/opt/hashlink/lib/openal.hdll
            /usr/local/opt/hashlink/lib/ssl.hdll
            /usr/local/opt/hashlink/lib/uv.hdll
            /usr/local/opt/hashlink/lib/sdl.hdll
            /usr/local/opt/hashlink/lib/mysql.hdll
            /usr/local/opt/hashlink/lib/fmt.hdll

Does brew not recognize hdll files as libraries?

@SMillerDev
Copy link
Member

I wouldn't think so. The macOS standard for those is dyld.

@jdonaldson
Copy link
Contributor Author

That seems well intentioned, but overly restrictive, no? Homebrew/brew#2997

In any event, I'll see about trying to change it.

@jdonaldson
Copy link
Contributor Author

After looking into the library extension issue, I'm seeing that the "hdll" is an extension pattern that Hashlink uses pretty extensively. Removing it/renaming it is non-trivial, in fact I think forcing the change is a deal breaker.

Hashlink is a cross platform virtual machine, and is a successor to "neko" (that uses a similar pattern of library naming): https://github.com/Homebrew/homebrew-core/blob/2d2aa9cf0d0ba73314a2d04821542667e5712c84/Formula/neko.rb

see neko .ndll library file usage here: https://github.com/HaxeFoundation/neko/blob/ff67a696a718cba0a6bc0ec583e355272b4a5923/CMakeLists.txt

My point is, there's an awful lot of cross-platform best practice learnings incorporated in these projects and their library naming patterns. Is this something that homebrew can adapt to? Perhaps a whitelist of some sort?

:revision => "cd269136628a1d445b2253ded9fd10ab9fe2f9be",
:tag => "1.11"

depends_on "cmake"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a runtime dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The short answer is no. These are (mostly) all lazy loaded for the purposes of FFI.

@vladimyr
Copy link
Contributor

vladimyr commented May 4, 2020

@jdonaldson Here is revised formula without external testing dependencies:

class Hashlink < Formula
  desc "Virtual machine for Haxe"
  homepage "https://hashlink.haxe.org/"
  url "https://github.com/HaxeFoundation/hashlink/archive/1.11.tar.gz"
  sha256 "b087ded7b93c7077f5b093b999f279a37aa1e31df829d882fa965389b5ad1aea"

  depends_on "haxe" => :test
  depends_on "jpeg-turbo"
  depends_on "libogg"
  depends_on "libpng"
  depends_on "libuv"
  depends_on "libvorbis"
  depends_on "mbedtls"
  depends_on "openal-soft"
  depends_on "sdl2"

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

  test do
    haxebin = Formula["haxe"].bin
    (testpath/"HelloWorld.hx").write <<~EOS
      class HelloWorld {
          static function main() trace("Hello world!");
      }
    EOS

    system "#{haxebin}/haxe", "-hl", "out.hl", "-main", "HelloWorld"
    assert_equal "HelloWorld.hx:2: Hello world!\n", shell_output("#{bin}/hl out.hl")

    system "#{haxebin}/haxelib", "newrepo"
    system "#{haxebin}/haxelib", "install", "hashlink"
    system "#{haxebin}/haxe", "-hl", "src/main.c", "-main", "HelloWorld"
    system "cc", "-O3", "-o", "hello-world",
           "-std=c11", "-I", "src", "src/main.c",
           "-L#{lib}", "-lhl"
    assert_equal "HelloWorld.hx:2: Hello world!\n", `./hello-world`
  end
end

Note that you don't really need cmake and you can use haxe as testing dependency. This however doesn't fix dynamic library extension issue but that is just an audit warning an can simply be ignored.

@jdonaldson
Copy link
Contributor Author

Great tip, I'll go with that.

@jdonaldson
Copy link
Contributor Author

Thanks again @vladimyr, this is very elegant and I learned a couple of things.

Let me know if there's something else I can do from my end.

@vladimyr
Copy link
Contributor

vladimyr commented May 4, 2020

Thanks again @vladimyr, this is very elegant and I learned a couple of things.

Then it is a double win 👍 and I'm glad I could help.

I believe this is best you can get from this one but we'll see what @SMillerDev thinks about it 🤞

Copy link
Contributor

@vladimyr vladimyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are really cosmetic changes but swapping trace with Sys.println reduces assertion clutter 🙇

@jdonaldson
Copy link
Contributor Author

Thanks again for the changes, I've merged them in. Is there anything else that is required here?

@vladimyr
Copy link
Contributor

I think this is in a good shape and ready for merge 👍
Let's what @SMillerDev says about that.

@alebcay alebcay requested a review from SMillerDev May 22, 2020 04:22
@jdonaldson
Copy link
Contributor Author

Thanks, I merged the suggestion.

@SMillerDev
Copy link
Member

Can you squash all your commits into one <name> <version> (new formula)

@jdonaldson
Copy link
Contributor Author

squashed/rebased on master

@jdonaldson
Copy link
Contributor Author

amended the name

@vladimyr
Copy link
Contributor

vladimyr commented Jun 2, 2020

I changed the formula as @MikeMcQuaid suggested and it failed (as expected) because there is also libhl.dylib that needs to be symlinked to /usr/local/lib:

Does it work/how does it work if Homebrew is not installed into /usr/local?

Actually I was wrong. The real requirement here is that it is located inside #{prefix}/lib because here is how hl loads it:

homebrew-core on  hashlink [$!] 
➜ otool -l `which hl` | grep LC_LOAD_DYLIB -A2
          cmd LC_LOAD_DYLIB
      cmdsize 72
         name /usr/local/Cellar/hashlink/1.11/lib/libhl.dylib (offset 24)
--
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)

OFC that means it will end up symlinked inside /usr/local/lib at the end of the day (or elsewhere depending on HB prefix) but that is completely irrelevant here.
So to summarize, it is completely independent of the actual HB prefix and it should work regardless of your HB install location .

This seems sensible but it's extremely strange that the Makefile doesn't do this by itself.

Honestly, I still haven't seen any example of plain old Makefile having good rpath support so I don't find it that much strange. OTOH, cmake certainly raises the bar here: https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling and there were some discussions about supporting that in hashlink's cmake powered build HaxeFoundation/hashlink#221 (comment) but as far as I know that didn't materialize yet. (No traces of rpath stuff inside 1.11 or master)

In case it seems like I'm being a bit anal: both of the above sound likely to break on Linux, too.

First of all, it didn't sound like that! Anyway, the former is independent of HB's install location so it shouldn't break on Linux and later - well it isn't cross-platform by definition 🙃 But I knew I could do better so I did...

Before I proceed let me just thank both of you @MikeMcQuaid and @jdonaldson for your kind words! It means a lot to me!

Ok, back to the track. Instead of tweaking rpath after compilation (which is platform-specific), I decided to use cross-platform/toolchain linker directive:
-Wl,-rpath,<target location> (docs: clang, gcc). The real troubles are:

  1. There isn't any exposed makefile variable able to accept that
  2. Which location to pick

Here is how I addressed them:

  1. There is actually a variable called LFLAGS used during hl binary compilation but it hasn't been exposed which is perfect use-case for inreplace:

    inreplace "Makefile", /^LFLAGS\s*=\s*/, "LFLAGS = -Wl,-rpath,#{target_location} "

    Essentially what I did here is prefixing LFLAGS with -rpath directive thus ensuring it gets applied without unwanted side-effects.

  2. All my previous exploration revolved around Mike's libexec idea and that libraries should reside inside libexec/lib. But there was something subconsciously wrong about that. Those dynamic libraries are global and used by every compiled hashlink binary. Living mostly in a node world it reminded me of global node_modules so I went to see how node formula implements those. As expected, global node_modules live inside lib/node_modules. Now when I translated that to our hdll situation it became clear to me they should end up inside lib/hashlink. But that was a bitter-sweet revelation because I knew I already heard that somewhere → hashlink 1.11 (new formula) #53790 (comment) So there you go @SMillerDev I should have listened to you from the start.
    Finally LFLAGS becomes:

    inreplace "Makefile", /^LFLAGS\s*=\s*/, "LFLAGS = -Wl,-rpath,#{lib}/hashlink "

That resolves the issue with libraries because now we:

  1. Can alter rpath in a cross-platform fashion which enables us to move dynamic libs out of /usr/local/lib
  2. Know where to put them by reusing prior art done by other runtimes

There is also an issue with placing include directory and the logical path forward is to use #{include}/hashlink.

Finally, it results with following directory layout:

➜ brew unlink --dry-run hashlink | grep local | xargs -n1 ls -l | cut -d' ' -f13-
/usr/local/bin/hl -> ../Cellar/hashlink/1.11/bin/hl
/usr/local/include/hashlink -> ../Cellar/hashlink/1.11/include/hashlink
/usr/local/lib/hashlink -> ../Cellar/hashlink/1.11/lib/hashlink
/usr/local/lib/libhl.dylib -> ../Cellar/hashlink/1.11/lib/libhl.dylib

Global lib and include folders aren't cluttered and the only thing that still gets symlinked at the root level is libhl.dylib due to reasons explained at the start. (Its search path is hardcoded inside hl and can't be easily altered during compilation.)

Full installation procedure looks like this:

  def install
    inreplace "Makefile", /^LFLAGS\s*=\s*/, "LFLAGS = -Wl,-rpath,#{lib}/hashlink "
    system "make"

    bin.install "hl"
    (lib/"hashlink").install Dir["*.dylib"], Dir["*.hdll"]
    (include/"hashlink").install "src/hl.h", "src/hlc.h", "src/hlc_main.c"
    lib.install_symlink Dir[lib/"hashlink/*.dylib"]
  end

You may ask why I'm doing so many #install invocations instead of using make install but believe me it is actually easier and faster this way. There is no point in instructing make to move things around just so we could do that again and you can't fine-tune lib and include locations anyway. So I just went and rewrote that in pure ruby.

But then I noticed that HEAD version of makefile introduced some goodies and altered it to its final form:

  def install
    inreplace "Makefile", /^LFLAGS\s*=\s*/, "LFLAGS = -Wl,-rpath,#{lib}/hashlink "
    system "make"

    if build.head?
      system "make", "install",
             "INSTALL_DIR=#{prefix}",
             "INSTALL_BIN_DIR=#{bin}",
             "INSTALL_LIB_DIR=#{lib}/hashlink",
             "INSTALL_INCLUDE_DIR=#{include}/hashlink"
    else
      bin.install "hl"
      (lib/"hashlink").install Dir["*.dylib"], Dir["*.hdll"]
      (include/"hashlink").install "src/hl.h", "src/hlc.h", "src/hlc_main.c"
    end

    lib.install_symlink Dir[lib/"hashlink/*.dylib"]
  end

Presumably, the next version will have those make vars and else block goes away for good leaving nice and descriptive install command in place.

I've shown you global side of things here is how it looks from cellar perspective:

homebrew-core on  hashlink [$!] 
➜ tree /usr/local/Cellar/hashlink/1.11 
/usr/local/Cellar/hashlink/1.11
├── INSTALL_RECEIPT.json
├── LICENSE
├── README.md
├── bin
│   └── hl
├── include
│   └── hashlink
│       ├── hl.h
│       ├── hlc.h
│       └── hlc_main.c
└── lib
    ├── hashlink
    │   ├── fmt.hdll
    │   ├── libhl.dylib
    │   ├── mysql.hdll
    │   ├── openal.hdll
    │   ├── sdl.hdll
    │   ├── ssl.hdll
    │   ├── ui.hdll
    │   └── uv.hdll
    └── libhl.dylib -> hashlink/libhl.dylib

5 directories, 16 files

Let's look inside hl to verify it loads dynamic libs from correct locations:

➜ otool -l `which hl` | rg 'LC_LOAD_DYLIB|LC_RPATH' -A2
277:          cmd LC_LOAD_DYLIB
278-      cmdsize 72
279-         name /usr/local/Cellar/hashlink/1.11/lib/libhl.dylib (offset 24)
--
284:          cmd LC_LOAD_DYLIB
285-      cmdsize 56
286-         name /usr/lib/libSystem.B.dylib (offset 24)
--
291:          cmd LC_RPATH
292-      cmdsize 64
293-         path /usr/local/Cellar/hashlink/1.11/lib/hashlink (offset 12)

Yup, no global paths, strictly cellar ones! And global libs are loaded from /lib/hashlink as expected.

Let me now finish this journey by presenting you with the updated formula: https://gist.github.com/vladimyr/ba6f3f8396910a7399450f8f5fd1c099#file-hashlink-rb 🎉

PS I've deleted previous review suggestions because I no longer recommend libexec and binary relative rpath solution due to reasons mentioned above and all those test suite updates can be c/p from linked gist.

PSS @jdonaldson

It would be nice having a simple config pattern for "keep these libraries out of /usr/local/lib, but make them available for dynamic loading for this application". I bet something similar also exists for linux environments.

Both MachO and ELF binaries support (multiple) rpath entries in .dynamic section of an executable so there you have it. You just need to bake in the correct library search path at link time which is exactly what I just did/explained. 😃

@MikeMcQuaid
Copy link
Member

Actually I was wrong. The real requirement here is that it is located inside #{prefix}/lib because here is how hl loads it:

If you set the prefix to libexec: why does that not work?

Presumably, the next version will have those make vars and else block goes away for good leaving nice and descriptive install command in place.

Would you be able to submit the Makefile inreplace upstream too? If something that allows us to specify that lands there then I think that's all the problems solved.

Great work @vladimyr 👏

@vladimyr
Copy link
Contributor

vladimyr commented Jun 2, 2020

Actually I was wrong. The real requirement here is that it is located inside #{prefix}/lib because here is how hl loads it:

If you set the prefix to libexec: why does that not work?

You got me thinking there for a while but I finally figured out what is happening. First, I compiled hashlink manually without HB and got a consistent result regardless of INSTALL_DIR used:

hashlink on  master
➜ otool -l hl | grep 'LOAD_DYLIB' -A2
          cmd LC_LOAD_DYLIB
      cmdsize 40
         name libhl.dylib (offset 24)
--
          cmd LC_LOAD_DYLIB
      cmdsize 56
         name /usr/lib/libSystem.B.dylib (offset 24)

That makes sense because Makefile says the following:

LFLAGS = -L. -lhl

where the dot is build directory and hl is just a shorthand for libhl.dylib.

So where does prefix/lib come from and why it doesn't get applied if I use libexec as INSTALL_DIR? 🤔

It turns out --debug flag is a really useful thing...

I've reverted my #install procedure to use libexec:

  def install
    system "make"
    system "make", "install", "INSTALL_DIR=#{libexec}"
    bin.install_symlink libexec/"bin/hl"
  end

and re-ran installation. Here is a trimmed (debug) log output:

==> Cleaning
==> Finishing up
ln -s ../Cellar/hashlink/1.11/bin/hl hl
Warning: Could not fix libhl.dylib in /usr/local/Cellar/hashlink/1.11/libexec/bin/hl
==> Changing dylib ID of /usr/local/Cellar/hashlink/1.11/libexec/lib/fmt.hdll
  from fmt.hdll
    to /usr/local/opt/hashlink/libexec/lib/fmt.hdll
==> Changing install name in /usr/local/Cellar/hashlink/1.11/libexec/lib/fmt.hdll
  from libhl.dylib
    to @loader_path/libhl.dylib

I've changed it once again to use prefix:

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

and got this:

==> Finishing up
ln -s ../Cellar/hashlink/1.11/bin/hl hl
ln -s ../Cellar/hashlink/1.11/include/hl.h hl.h
ln -s ../Cellar/hashlink/1.11/include/hlc.h hlc.h
ln -s ../Cellar/hashlink/1.11/include/hlc_main.c hlc_main.c
ln -s ../Cellar/hashlink/1.11/lib/fmt.hdll fmt.hdll
ln -s ../Cellar/hashlink/1.11/lib/libhl.dylib libhl.dylib
ln -s ../Cellar/hashlink/1.11/lib/mysql.hdll mysql.hdll
ln -s ../Cellar/hashlink/1.11/lib/openal.hdll openal.hdll
ln -s ../Cellar/hashlink/1.11/lib/sdl.hdll sdl.hdll
ln -s ../Cellar/hashlink/1.11/lib/ssl.hdll ssl.hdll
ln -s ../Cellar/hashlink/1.11/lib/ui.hdll ui.hdll
ln -s ../Cellar/hashlink/1.11/lib/uv.hdll uv.hdll
==> Changing install name in /usr/local/Cellar/hashlink/1.11/bin/hl
  from libhl.dylib
    to /usr/local/Cellar/hashlink/1.11/lib/libhl.dylib
==> Changing dylib ID of /usr/local/Cellar/hashlink/1.11/lib/fmt.hdll
  from fmt.hdll
    to /usr/local/opt/hashlink/lib/fmt.hdll
==> Changing install name in /usr/local/Cellar/hashlink/1.11/lib/fmt.hdll
  from libhl.dylib
    to @loader_path/libhl.dylib

So HB itself alters install names inside binaries (and libraries) thus inserting phantom prefix/lib. It fails to do so in libexec case because once you install hl binary from libexec/bin to bin it can't find libhl.dylib anymore. IDK why it can't locate it inside libexec/lib but verified my assumptions by altering #install method once again:

  def install
    system "make"
    system "make", "install", "INSTALL_DIR=#{libexec}"
    lib.install_symlink libexec/"lib/libhl.dylib"
    bin.install_symlink libexec/"bin/hl"
  end

This produces the correct result:

==> Cleaning
==> Finishing up
ln -s ../Cellar/hashlink/1.11/bin/hl hl
ln -s ../Cellar/hashlink/1.11/lib/libhl.dylib libhl.dylib
==> Changing install name in /usr/local/Cellar/hashlink/1.11/libexec/bin/hl
  from libhl.dylib
    to /usr/local/Cellar/hashlink/1.11/lib/libhl.dylib
==> Changing dylib ID of /usr/local/Cellar/hashlink/1.11/libexec/lib/fmt.hdll
  from fmt.hdll
    to /usr/local/opt/hashlink/libexec/lib/fmt.hdll
==> Changing install name in /usr/local/Cellar/hashlink/1.11/libexec/lib/fmt.hdll
  from libhl.dylib
    to @loader_path/libhl.dylib

@MikeMcQuaid
Copy link
Member

So HB itself alters install names inside binaries (and libraries) thus inserting phantom prefix/lib. It fails to do so in libexec case because once you install hl binary from libexec/bin to bin it can't find libhl.dylib anymore. IDK why it can't locate it inside libexec/lib but verified my assumptions by altering #install method once again:

Again: good catch. I've opened Homebrew/brew#7679 which should mean that this is unnecessary.

@vladimyr
Copy link
Contributor

vladimyr commented Jun 2, 2020

which should mean that this is unnecessary.

What do you mean by this? HB's magic works only if dynamic libraries are known upfront i.e. if their load paths are baked inside binary. In hashlink's case, only libhl's path is resolved at link time - other modules are resolved at run time.

@MikeMcQuaid
Copy link
Member

What do you mean by this? HB's magic works only if dynamic libraries are known upfront i.e. if their load paths are baked inside binary. In hashlink's case, only libhl's path is resolved at link time - other modules are resolved at run time.

It should mean the lib.install_symlink libexec/"lib/libhl.dylib" is unnecessary.

@vladimyr
Copy link
Contributor

vladimyr commented Jun 2, 2020

What do you mean by this? HB's magic works only if dynamic libraries are known upfront i.e. if their load paths are baked inside binary. In hashlink's case, only libhl's path is resolved at link time - other modules are resolved at run time.

It should mean the lib.install_symlink libexec/"lib/libhl.dylib" is unnecessary.

Yup, thanks for the clarification! 👍

@vladimyr
Copy link
Contributor

vladimyr commented Jun 2, 2020

As per your other point:

Would you be able to submit the Makefile inreplace upstream too? If something that allows us to specify that lands there then I think that's all the problems solved.

I've slightly changed it to mimic existence of additional EXTRA_LFLAGS:

  def install
    inreplace "Makefile", /\$\{LFLAGS\}/, "${LFLAGS} ${EXTRA_LFLAGS}"
    system "make", "EXTRA_LFLAGS=-Wl,-rpath,#{lib}/hashlink"
    # ...
  end

The next thing I'm gonna do is to create upstream PR that adds this new variable. If it gets accepted inreplace can just get deleted without any other changes required. 🎉

@MikeMcQuaid
Copy link
Member

The next thing I'm gonna do is to create upstream PR that adds this new variable. If it gets accepted inreplace can just get deleted without any other changes required. 🎉

Sounds great, thanks!

@vladimyr
Copy link
Contributor

vladimyr commented Jun 3, 2020

HaxeFoundation/hashlink#387 got merged and @MikeMcQuaid asked to change lib location from lib/hashlink to libexec/lib so here is the new version: https://gist.github.com/vladimyr/ba6f3f8396910a7399450f8f5fd1c099/1b62a022c251f3e04674c861072d475c4fdd6a87#file-hashlink-rb

⚠️ It won't work until Homebrew/brew#7683 lands. But after that, I think we are finally good to go. 🚀
/cc @jdonaldson

@sjackman
Copy link
Contributor

sjackman commented Jun 3, 2020

@vladimyr Thank you for sticking with this PR and troubleshooting this issue, Dario! 🏆

Note that if you're relying on a new feature of Homebrew/brew that is required to install the bottle/formula, this PR must wait until a new release of Homebrew/brew is tagged and released.

@alebcay alebcay added do not merge and removed upstream issue An upstream issue report is needed labels Jun 3, 2020
@jdonaldson
Copy link
Contributor Author

I updated the formula again with @vladimyr's suggestions. I feel like he deserves all the credit at this point, but I'd really like to hang on to this thread since I'm getting such a positive vibe off of it (And that's in short supply these days!)

@vladimyr
Copy link
Contributor

vladimyr commented Jun 3, 2020

Thank you for your kind words and at risk of sounding cheap, this really was and still is teamwork. Everyone did their part, from the one who created PR in the first place, folks asking questions and providing constructive criticism, the one who altered Github labels, the one who did research, the one who altered HB itself to support it, Hashlink author theyself for adjusting Makefile to our needs... Many roles listed, yet without any of those, we wouldn't be anywhere near the end of this journey. Today it was me, tomorrow will be someone else...
We are living through some harsh and quite inhumane times but what our future will look like is upon us to decide. Just like we do with HB and opensource in general, we could do the same with any aspect of our lives. Acting together with love, care, creativity, and mutual respect makes yesterday's dealbreaker into tomorrow's resolved issue. Sometimes I would love to have a magic wand to fix some wrongs out there but the world doesn't work that way. At the same time, there is one thing I can do and that is to empower as much as I can. Oddly enough, I'm not really a Haxe dev, but I can't wait to see what would people do with hashlink. Maybe nobody will really notice, maybe people will just use it for learning and shortlived toy projects, maybe there is someone out there who will create something that will stick and become tomorrow's standard, who knows... My only mission here is to make sure people get the opportunity to do something creative that makes them feel good and I'm more than honored if I somehow managed to produce and/or be part of positive vibes on the way. ❤️

@MikeMcQuaid
Copy link
Member

Lovely words @vladimyr. I've had a shitty 24 hours and this has made it much better ❤️

hashlink : use :revision instead of :tag

hashlink: add hello world test using resource

address style issues, add tag back

hashlink : use the testing configuration from vladimyr

Update Formula/hashlink.rb

Co-authored-by: Dario Vladović <[email protected]>

Update Formula/hashlink.rb

Co-authored-by: Dario Vladović <[email protected]>

Update Formula/hashlink.rb

Co-authored-by: Dario Vladović <[email protected]>

Update Formula/hashlink.rb

Co-authored-by: Sean Molenaar <[email protected]>
MikeMcQuaid
MikeMcQuaid previously approved these changes Jun 10, 2020
@BrewTestBot
Copy link
Member

:shipit: @MikeMcQuaid has triggered a merge.

@BrewTestBot
Copy link
Member

⚠️ @MikeMcQuaid bottle publish failure.

@BrewTestBot BrewTestBot dismissed MikeMcQuaid’s stale review June 10, 2020 08:18

bottle publish failed

@BrewTestBot
Copy link
Member

:shipit: @MikeMcQuaid has triggered a merge.

@MikeMcQuaid
Copy link
Member

Thanks so much for your contribution and patience! Without people like you submitting PRs we couldn't run this project. You rock, @jdonaldson!

Also thanks to @vladimyr, @SMillerDev and others for all the help here ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new formula PR adds a new formula to Homebrew/homebrew-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants