diff mbox

[2/2] go-examples: Add an example, helloworld written in go

Message ID 20161110003935.1858-2-raj.khem@gmail.com
State Superseded
Headers show

Commit Message

Khem Raj Nov. 10, 2016, 12:39 a.m. UTC
This should serve as temlate for writing go recipes

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-extended/go-examples/files/helloworld.go  | 10 ++++++++++
 meta/recipes-extended/go-examples/go-examples.inc      | 10 ++++++++++
 meta/recipes-extended/go-examples/go-helloworld_0.1.bb | 15 +++++++++++++++
 3 files changed, 35 insertions(+)
 create mode 100644 meta/recipes-extended/go-examples/files/helloworld.go
 create mode 100644 meta/recipes-extended/go-examples/go-examples.inc
 create mode 100644 meta/recipes-extended/go-examples/go-helloworld_0.1.bb

Comments

Christopher Larson Nov. 11, 2016, 2:59 a.m. UTC | #1
On Wed, Nov 9, 2016 at 5:39 PM, Khem Raj <raj.khem@gmail.com> wrote:

> diff --git a/meta/recipes-extended/go-examples/go-examples.inc

> b/meta/recipes-extended/go-examples/go-examples.inc

> new file mode 100644

> index 0000000..c632681

> --- /dev/null

> +++ b/meta/recipes-extended/go-examples/go-examples.inc

> @@ -0,0 +1,10 @@

> +DESCRIPTION = "This is a simple example recipe that cross-compiles a Go

> program."

> +SECTION = "examples"

> +HOMEPAGE = "https://golang.org/"

> +

> +LICENSE = "MIT"

> +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=

> 0835ade698e0bcf8506ecda2f7b4f302"

> +

> +S = "${WORKDIR}"

> +

> +inherit go

> diff --git a/meta/recipes-extended/go-examples/go-helloworld_0.1.bb

> b/meta/recipes-extended/go-examples/go-helloworld_0.1.bb

> new file mode 100644

> index 0000000..af9d3b7

> --- /dev/null

> +++ b/meta/recipes-extended/go-examples/go-helloworld_0.1.bb

> @@ -0,0 +1,15 @@

> +require go-examples.inc

> +

> +

> +SRC_URI += " \

> +  file://helloworld.go \

> +"

> +

> +do_compile() {

> +  go build helloworld.go

> +}

>


Under what circumstances would one use the go_do_compile from go.bbclass vs
this?
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Khem Raj Nov. 14, 2016, 2:07 a.m. UTC | #2
On 11/10/16 6:59 PM, Christopher Larson wrote:
> 

> On Wed, Nov 9, 2016 at 5:39 PM, Khem Raj <raj.khem@gmail.com

> <mailto:raj.khem@gmail.com>> wrote:

> 

>     diff --git a/meta/recipes-extended/go-examples/go-examples.inc

>     b/meta/recipes-extended/go-examples/go-examples.inc

>     new file mode 100644

>     index 0000000..c632681

>     --- /dev/null

>     +++ b/meta/recipes-extended/go-examples/go-examples.inc

>     @@ -0,0 +1,10 @@

>     +DESCRIPTION = "This is a simple example recipe that cross-compiles a Go

>     program."

>     +SECTION = "examples"

>     +HOMEPAGE = "https://golang.org/"

>     +

>     +LICENSE = "MIT"

>     +LIC_FILES_CHKSUM =

>     "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

>     +

>     +S = "${WORKDIR}"

>     +

>     +inherit go

>     diff --git a/meta/recipes-extended/go-examples/go-helloworld_0.1.bb

>     <http://go-helloworld_0.1.bb>

>     b/meta/recipes-extended/go-examples/go-helloworld_0.1.bb

>     <http://go-helloworld_0.1.bb>

>     new file mode 100644

>     index 0000000..af9d3b7

>     --- /dev/null

>     +++ b/meta/recipes-extended/go-examples/go-helloworld_0.1.bb

>     <http://go-helloworld_0.1.bb>

>     @@ -0,0 +1,15 @@

>     +require go-examples.inc

>     +

>     +

>     +SRC_URI += " \

>     +  file://helloworld.go \

>     +"

>     +

>     +do_compile() {

>     +  go build helloworld.go

>     +}

> 

> 

> Under what circumstances would one use the go_do_compile from go.bbclass vs this?


I think this is a good point. It would be more appropriate to use
the primitives from go.bbclass in this example. I will try to rework it
-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core
diff mbox

Patch

diff --git a/meta/recipes-extended/go-examples/files/helloworld.go b/meta/recipes-extended/go-examples/files/helloworld.go
new file mode 100644
index 0000000..0253c40
--- /dev/null
+++ b/meta/recipes-extended/go-examples/files/helloworld.go
@@ -0,0 +1,10 @@ 
+// You can edit this code!
+// Click here and start typing.
+// taken from https://golang.org/
+package main
+
+import "fmt"
+
+func main() {
+	fmt.Println("Hello, 世界")
+}
diff --git a/meta/recipes-extended/go-examples/go-examples.inc b/meta/recipes-extended/go-examples/go-examples.inc
new file mode 100644
index 0000000..c632681
--- /dev/null
+++ b/meta/recipes-extended/go-examples/go-examples.inc
@@ -0,0 +1,10 @@ 
+DESCRIPTION = "This is a simple example recipe that cross-compiles a Go program."
+SECTION = "examples"
+HOMEPAGE = "https://golang.org/"
+
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+S = "${WORKDIR}"
+
+inherit go
diff --git a/meta/recipes-extended/go-examples/go-helloworld_0.1.bb b/meta/recipes-extended/go-examples/go-helloworld_0.1.bb
new file mode 100644
index 0000000..af9d3b7
--- /dev/null
+++ b/meta/recipes-extended/go-examples/go-helloworld_0.1.bb
@@ -0,0 +1,15 @@ 
+require go-examples.inc
+
+
+SRC_URI += " \
+  file://helloworld.go \
+"
+
+do_compile() {
+  go build helloworld.go
+}
+
+do_install() {
+  install -d "${D}/${bindir}"
+  install -m 0755 "${S}/helloworld" "${D}/${bindir}"
+}