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

Adds some documentation specific to the make rule. #1050

Merged
merged 1 commit into from
Jun 13, 2023

Conversation

filmil
Copy link
Contributor

@filmil filmil commented May 6, 2023

I learned the hard way that the make build rule does not work out of the box with just any makefile, unlike other rules in this repository.

The single make example does not emphasize this, and it is important for the usability of the rule.

These are the things I learned:

  • the make( targets = [...]) invocation must at least execute an equivalent of make install, since all out_* params are relative to the installation directory, not to either the source or the buidkl directory. So if your default target does not install anything, or you have a install make target, but don't invoke it, bazel will be unable to find your build outputs.
  • The make file must either be able to recognize the PREFIX= env variable and use it, or have a different way of wiring the $$INSTALLDIR$$ make variable through.
  • Finally, the make install recipe must ensure that it does not copy symlinks. This will bite you if you use cp $SOURCE DEST instead of cp -L $SOURCE $DEST since the former will create a bunch of symlinks pointing to the sandbox. Which, of course, is useless once the sandbox is removed. Using -L will ensure that the actual file contents are
    copied.

Issue: #1049

Copy link
Member

@jsharpe jsharpe left a comment

Choose a reason for hiding this comment

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

Thanks!

@jsharpe jsharpe enabled auto-merge (squash) June 13, 2023 22:02
I learned the hard way that the `make` build rule does not work out of the box with just any makefile, unlike other rules
in this repository.

The single `make` example does *not*
emphasize this, and it is important for 
the usability of the rule.

These are the things I learned:

- the `make( targets = [...])` invocation must at least execute an equivalent of `make install`, since all `out_*` params are relative to the *installation* directory, not the source directory.  So if your default target does not install anything, or you have a `install` make target, but don't invoke it, bazel will be unable to find your build outputs.
- The make file must either be able to recognize the `PREFIX=` env variable and use it, or have a different way of wiring the `$$INSTALLDIR$$` make variable through.
- Finally, the `make install` recipe must ensure that it does not copy symlinks. This will bite you if you use `cp $SOURCE DEST` instead of `cp -L $SOURCE $DEST` since the former will create a bunch of symlinks pointing to the sandbox. Which, of course, is useless once the sandbox is removed. Using `-L` will
ensure that the actual file contents are
copied.
@jsharpe jsharpe merged commit d74623f into bazel-contrib:main Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants