Skip to content

Comments

Add --bootstrap option#25

Open
eugpermar wants to merge 1 commit intoedenhill:masterfrom
eugpermar:feature/bootstrap
Open

Add --bootstrap option#25
eugpermar wants to merge 1 commit intoedenhill:masterfrom
eugpermar:feature/bootstrap

Conversation

@eugpermar
Copy link
Contributor

If configure script is called with --bootstrap option, and proper
instructions are added to build dep, it will be automatically downloaded
& built under vendor folder.

For example, to build a GIT revision of librd:

LIBRD_GIT_VERSION=73fae1cc0ca378669fa09bcda54b408397f80c18
function make_librd {
  if [[ -d "librd-$LIBRD_GIT_VERSION" && ! -d librd ]]; then
    mv "librd-$LIBRD_GIT_VERSION" librd
  fi

  cd librd
  make libs
}

And in checks function:

...
mkl_lib_check --static=-lrd \
      --bootstrap_url="https://github.com/edenhill/librd/archive/$LIBRD_GIT_VERSION.zip" \
      --bootstrap_makefn=make_librd \
      --bootstrap_cc_flags="-I./vendor/librd" \
      --bootstrap_static_lib=vendor/librd/librd/librd.a \
        "librd" "" fail CC "-lrd -lpthread -lrt" \
        "#include <librd/rdlog.h>

        void f() { rdlog(LOG_ERR, \"TEST\"); }"
...

Other configurations could use installation under local folder with
--prefix or DESTDIR and include that one.

@eugpermar
Copy link
Contributor Author

Please review it carefully, your knowledge of bash are far more advanced than mine and I'm sure that a lot of stuff can be done in a better way, but I think this PR could be a good base :)

Copy link
Owner

@edenhill edenhill left a comment

Choose a reason for hiding this comment

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

Great stuff!

# Arguments:
# [--static=<lib>] (allows static linking (--enable-static) for the
# library provided, e.g.: --static=-lrdkafka "librdkafka"..)
# [--bootstrap_url=<url> (Automatic download of library to vendor/ folder if
Copy link
Owner

@edenhill edenhill May 10, 2017

Choose a reason for hiding this comment

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

This gets a little noisy, what do you think of adding just a function reference?


function bootstrap_librd {
   mkl_lib_bootstrap $URL $my_ccflags ....
}

Or maybe automatically resolve the bootstrapper so that if mkl_bootstrap__<confname> is available it is called automatically from mkl_lib_check() if configure --bootstrap ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In a first step I though in add them as you said, but then I had problems with recursion, since mkl_lib_check will call itself for bootstrap forever. It needs a break condition, maybe another flag, or internally delete the variable once we have called bootstrap as fallback.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently it goes via mkl meta bootstrap_fn, but if you prefer it could be with `bootstrap_${config_name}" and let it auto-discovery. We will save one mkl_meta_set that way.

fi

if ! mkl_compile_check "$1" "$2" "$3" "$4" "$libs" "$6"; then
local action="$3"
Copy link
Owner

Choose a reason for hiding this comment

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

refactor this into separate functions

@eugpermar eugpermar force-pushed the feature/bootstrap branch from 0b08c88 to e7003b2 Compare May 11, 2017 19:49
If `configure` script is called with `--bootstrap` option, and proper
instructions are added to build dep, it will be automatically downloaded
& built under `vendor` folder.

For example, to build a GIT revision of librd:

```
LIBRD_GIT_VERSION=73fae1cc0ca378669fa09bcda54b408397f80c18
function make_librd {
  if [[ -d "librd-$LIBRD_GIT_VERSION" && ! -d librd ]]; then
    mv "librd-$LIBRD_GIT_VERSION" librd
  fi

  cd librd
  make libs
}
```

And in `checks` function:

```
...
mkl_meta_set librd bootstrap_url "https://github.com/eugpermar/librd/archive/$LIBRD_GIT_VERSION.zip"
mkl_meta_set librd bootstrap_makefn make_librd
mkl_meta_set librd bootstrap_cppflags "-I./vendor/librd"
mkl_meta_set librd bootstrap_static_lib "vendor/librd/librd/librd.a"
mkl_lib_check --static=-lrd \
        "librd" "" fail CC "-lrd -lpthread -lrt" \
        "#include <librd/rdlog.h>

        void f() { rdlog(LOG_ERR, \"TEST\"); }"
...
```

Other configurations could use installation under local folder with
--prefix or DESTDIR and include that one.
@eugpermar eugpermar force-pushed the feature/bootstrap branch from e7003b2 to a4c85c3 Compare May 11, 2017 19:51
@eugpermar
Copy link
Contributor Author

Hi! I've updated with dependency meta variables. Could you please check the changes?

Thanks!

@eugpermar
Copy link
Contributor Author

Hi, Magnus! Were you able to check this? I can try the bootstrap_<conf_name> approach if you see it more convenient, but I think that meta variables give more flexibility than that. In the future, they can install dependencies with apt-get or dnf, for example, and stuff like that. ¿What do you think?

Thanks!

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