diff mbox

add a build.sh helper to allow for a one-stop build

Message ID 20161010164758.GB1796@obsidianresearch.com (mailing list archive)
State Accepted
Headers show

Commit Message

Jason Gunthorpe Oct. 10, 2016, 4:47 p.m. UTC
On Mon, Oct 10, 2016 at 09:17:11AM -0700, Bart Van Assche wrote:
> On 10/10/16 08:59, Christoph Hellwig wrote:
> >On Mon, Oct 10, 2016 at 08:56:33AM -0700, Bart Van Assche wrote:
> >>Have you considered to make this script stop immediately if one of the
> >>steps fails, e.g. as follows?
> >
> >How about just ading a
> >
> >set -e
> >
> >to the beginning to get this automatically?
> 
> That would also work. But if there is a space anywhere in the path in which
> the rdma-core repository exists, mkdir $BUILDDIR will have to be changed
> into mkdir "$BUILDDIR".

Is this OK?

From 6362ec4c1ddec0f6b2a1bf052cdfde63cbf73d90 Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Date: Mon, 10 Oct 2016 10:46:47 -0600
Subject: [PATCH] Add a build.sh helper to allow for a one-stop build

This allows for a quick build instead of typing the whole mkdir, cd,
cmake and ninja sequence.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
 README.md | 17 +----------------
 build.sh  | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 16 deletions(-)
 create mode 100755 build.sh

Comments

Christoph Hellwig Oct. 10, 2016, 4:51 p.m. UTC | #1
On Mon, Oct 10, 2016 at 10:47:58AM -0600, Jason Gunthorpe wrote:
> Is this OK?

Looks fine to me.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bart Van Assche Oct. 10, 2016, 5:46 p.m. UTC | #2
On 10/10/2016 09:51 AM, Christoph Hellwig wrote:
> On Mon, Oct 10, 2016 at 10:47:58AM -0600, Jason Gunthorpe wrote:
>> Is this OK?
>
> Looks fine to me.

This looks fine to me too.

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Leon Romanovsky Oct. 12, 2016, 9:30 a.m. UTC | #3
On Mon, Oct 10, 2016 at 10:47:58AM -0600, Jason Gunthorpe wrote:
> On Mon, Oct 10, 2016 at 09:17:11AM -0700, Bart Van Assche wrote:
> > On 10/10/16 08:59, Christoph Hellwig wrote:
> > >On Mon, Oct 10, 2016 at 08:56:33AM -0700, Bart Van Assche wrote:
> > >>Have you considered to make this script stop immediately if one of the
> > >>steps fails, e.g. as follows?
> > >
> > >How about just ading a
> > >
> > >set -e
> > >
> > >to the beginning to get this automatically?
> >
> > That would also work. But if there is a space anywhere in the path in which
> > the rdma-core repository exists, mkdir $BUILDDIR will have to be changed
> > into mkdir "$BUILDDIR".
>
> Is this OK?
>
> From 6362ec4c1ddec0f6b2a1bf052cdfde63cbf73d90 Mon Sep 17 00:00:00 2001
> From: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> Date: Mon, 10 Oct 2016 10:46:47 -0600
> Subject: [PATCH] Add a build.sh helper to allow for a one-stop build
>
> This allows for a quick build instead of typing the whole mkdir, cd,
> cmake and ninja sequence.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> ---
>  README.md | 17 +----------------
>  build.sh  | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+), 16 deletions(-)
>  create mode 100755 build.sh
>
> diff --git a/README.md b/README.md
> index 98ec5a7d695f..66aee3f49f00 100644
> --- a/README.md
> +++ b/README.md
> @@ -36,10 +36,7 @@ Additional service daemons are provided for:
>  This project uses a cmake based build system. Quick start:
>
>  ```sh
> -$ mkdir build
> -$ cd build
> -$ cmake -GNinja ..
> -$ ninja
> +$ bash build.sh
>  ```
>
>  *build/bin* will contain the sample programs and *build/lib* will contain the
> @@ -76,16 +73,6 @@ Install required packages:
>  $ yum install cmake gcc libnl3-devel make pkgconfig valgrind-devel
>  ```
>
> -For end users, the package can be built using GNU Make and the old cmake
> -included with the distro:
> -
> -```sh
> -$ mkdir build
> -$ cd build
> -$ cmake  ..
> -$ make
> -```
> -
>  Developers are suggested to install more modern tooling for the best experience.
>
>  ```sh
> @@ -96,8 +83,6 @@ $ unzip ninja-linux.zip
>  $ install -m755 ninja /usr/local/bin/ninja
>  ```
>
> -Use the 'cmake3' program in place of `cmake` in the above instructions.
> -
>  # Reporting bugs
>
>  Bugs should be reported to the <linux-rdma@vger.kernel.org> mailing list
> diff --git a/build.sh b/build.sh
> new file mode 100755
> index 000000000000..76205e6af921
> --- /dev/null
> +++ b/build.sh
> @@ -0,0 +1,33 @@
> +#!/bin/bash
> +set -e
> +
> +SRCDIR=`dirname $0`
> +BUILDDIR="$SRCDIR/build"
> +
> +if [ ! -d "$BUILDDIR" ]; then
> +    mkdir "$BUILDDIR"
> +fi

What do you think about following code, instead of 3 lines above?

+ mkdir -p "$BUILDDIR"
Christoph Hellwig Oct. 12, 2016, 10:52 a.m. UTC | #4
[full quote deleted, sigh..]

> What do you think about following code, instead of 3 lines above?
> 
> + mkdir -p "$BUILDDIR"

Fine with me.  Feel free to send an incremental patch.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Leon Romanovsky Oct. 12, 2016, 12:18 p.m. UTC | #5
On Wed, Oct 12, 2016 at 12:52:08PM +0200, Christoph Hellwig wrote:
> [full quote deleted, sigh..]
>
> > What do you think about following code, instead of 3 lines above?
> >
> > + mkdir -p "$BUILDDIR"
>
> Fine with me.  Feel free to send an incremental patch.

https://github.com/linux-rdma/rdma-core/pull/17

I'll apply it once travis will finish.

Thanks
Leon Romanovsky Oct. 12, 2016, 12:22 p.m. UTC | #6
On Wed, Oct 12, 2016 at 03:18:45PM +0300, Leon Romanovsky wrote:
> On Wed, Oct 12, 2016 at 12:52:08PM +0200, Christoph Hellwig wrote:
> > [full quote deleted, sigh..]
> >
> > > What do you think about following code, instead of 3 lines above?
> > >
> > > + mkdir -p "$BUILDDIR"
> >
> > Fine with me.  Feel free to send an incremental patch.
>
> https://github.com/linux-rdma/rdma-core/pull/17
>
> I'll apply it once travis will finish.

Done, applied.

>
> Thanks
Jason Gunthorpe Oct. 12, 2016, 4:38 p.m. UTC | #7
On Wed, Oct 12, 2016 at 03:22:20PM +0300, Leon Romanovsky wrote:

> Done, applied.

Are you going to sweep up the rest of the list patches too?

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Leon Romanovsky Oct. 12, 2016, 5:31 p.m. UTC | #8
On Wed, Oct 12, 2016 at 10:38:34AM -0600, Jason Gunthorpe wrote:
> On Wed, Oct 12, 2016 at 03:22:20PM +0300, Leon Romanovsky wrote:
>
> > Done, applied.
>
> Are you going to sweep up the rest of the list patches too?

Yes, I'll do it tomorrow.
Thanks

>
> Jason
diff mbox

Patch

diff --git a/README.md b/README.md
index 98ec5a7d695f..66aee3f49f00 100644
--- a/README.md
+++ b/README.md
@@ -36,10 +36,7 @@  Additional service daemons are provided for:
 This project uses a cmake based build system. Quick start:
 
 ```sh
-$ mkdir build
-$ cd build
-$ cmake -GNinja ..
-$ ninja
+$ bash build.sh
 ```
 
 *build/bin* will contain the sample programs and *build/lib* will contain the
@@ -76,16 +73,6 @@  Install required packages:
 $ yum install cmake gcc libnl3-devel make pkgconfig valgrind-devel
 ```
 
-For end users, the package can be built using GNU Make and the old cmake
-included with the distro:
-
-```sh
-$ mkdir build
-$ cd build
-$ cmake  ..
-$ make
-```
-
 Developers are suggested to install more modern tooling for the best experience.
 
 ```sh
@@ -96,8 +83,6 @@  $ unzip ninja-linux.zip
 $ install -m755 ninja /usr/local/bin/ninja
 ```
 
-Use the 'cmake3' program in place of `cmake` in the above instructions.
-
 # Reporting bugs
 
 Bugs should be reported to the <linux-rdma@vger.kernel.org> mailing list
diff --git a/build.sh b/build.sh
new file mode 100755
index 000000000000..76205e6af921
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,33 @@ 
+#!/bin/bash
+set -e
+
+SRCDIR=`dirname $0`
+BUILDDIR="$SRCDIR/build"
+
+if [ ! -d "$BUILDDIR" ]; then
+    mkdir "$BUILDDIR"
+fi
+
+if hash cmake3 2>/dev/null; then
+    # CentOS users are encouraged to install cmake3 from EPEL
+    CMAKE=cmake3
+else
+    CMAKE=cmake
+fi
+
+if hash ninja-build 2>/dev/null; then
+    # Fedora uses this name
+    NINJA=ninja-build
+elif hash ninja 2>/dev/null; then
+    NINJA=ninja
+fi
+
+cd "$BUILDDIR"
+
+if [ "x$NINJA" == "x" ]; then
+    cmake ..
+    make
+else
+    cmake -GNinja ..
+    $NINJA
+fi