Skip to contentSkip to conversation

(no subject)

RFC PATCH In review Ronald Rojas 3 participants 6 messages Nov 28, 2016 – Dec 1, 2016

lore
Share & tools
lore
#0 lore raw

Create a Makefile for the golang xenlight project, which will allow users to access libxl functionality in Golang. Makefile rules were also added to tools/Makefile for the project to be built and installed. A template Golang file was also created for the project to be properly built.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw

RFC PATCH 1/1 tools/xenlight: Create xenlight Makefile

Created basic Makfele for the Golang xenlight
project so that the project is built and
installed. A template template is alo added.

---
 tools/Makefile                    | 15 +++++++++++++++
 tools/golang/xenlight/Makefile    | 29 +++++++++++++++++++++++++++++
 tools/golang/xenlight/xenlight.go |  7 +++++++
 3 files changed, 51 insertions(+)
 create mode 100644 tools/golang/xenlight/Makefile
 create mode 100644 tools/golang/xenlight/xenlight.go
tools/Makefile +15 -0
index 71515b4..b89f06b 100644
@@ -11,6 +11,7 @@ SUBDIRS-y += misc
 SUBDIRS-y += examples
 SUBDIRS-y += hotplug
 SUBDIRS-y += xentrace
+SUBDIRS-y += golang/xenlight
 SUBDIRS-$(CONFIG_XCUTILS) += xcutils
 SUBDIRS-$(CONFIG_X86) += firmware
 SUBDIRS-y += console
@@ -311,6 +312,20 @@ subdir-install-debugger/gdbsx: .phony
 subdir-all-debugger/gdbsx: .phony
 	$(MAKE) -C debugger/gdbsx all
 
+subdir-all-golang/xenlight: .phony
+	$(MAKE) -C golang/xenlight all
+
+subdir-clean-golang/xenlight: .phony
+	$(MAKE) -C golang/xenlight clean
+
+subdir-install-golang/xenlight: .phony
+	$(MAKE) -C golang/xenlight install
+
+subdir-build-golang/xenlight: .phony
+	$(MAKE) -C golang/xenlight build
+
+subdir-distclean-golang/xenlight: .phony
+	$(MAKE) -C golang/xenlight distclean
 
 subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony
 	$(MAKE) -C debugger/kdd clean
tools/golang/xenlight/Makefile new file +29 -0
new file mode 100644
index 0000000..c723c1d
@@ -0,0 +1,29 @@
+XEN_ROOT=$(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+BINARY = xenlightgo
+GO = go
+
+.PHONY: all
+all: build
+
+.PHONY: build
+build: xenlight
+
+.PHONY: install
+install: build
+	[ -f $(BINARY) ] || $(INSTALL_PROG) xenlight.go $(DESTDIR)$(bindir)
+
+.PHONY: clean
+clean:
+	$(RM) $(BINARY)
+
+.PHONY: distclean
+distclean: clean
+
+
+xenlight: xenlight.go
+	$(GO) build -o $(BINARY) xenlight.go
+
+
+-include $(DEPS)
tools/golang/xenlight/xenlight.go new file +7 -0
new file mode 100644
index 0000000..50e8d8d
@@ -0,0 +1,7 @@
+package main
+
+import "fmt"
+
+func main() {
+	fmt.Println("vim-go")
+}
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH RFC] tools/xenlight: Create xenlight Makefile

Quoted 1 line · Ronald Rojas

Created basic Makfele for the Golang xenlight

Makefile.

Quoted 2 lines

project so that the project is built and
installed. A template template is alo added.

Duplicated "template".

Quoted 13 lines
---
 tools/Makefile                    | 15 +++++++++++++++
 tools/golang/xenlight/Makefile    | 29 +++++++++++++++++++++++++++++
 tools/golang/xenlight/xenlight.go |  7 +++++++
 3 files changed, 51 insertions(+)
 create mode 100644 tools/golang/xenlight/Makefile
 create mode 100644 tools/golang/xenlight/xenlight.go
tools/Makefile +0 -0
index 71515b4..b89f06b 100644

tools/Makefile SUBDIRS-y += misc · line 14

Quoted 4 lines
tools/Makefile +1 -0
@@ -11,6 +11,7 @@ SUBDIRS-y += misc
 SUBDIRS-y += examples
 SUBDIRS-y += hotplug
 SUBDIRS-y += xentrace
+SUBDIRS-y += golang/xenlight

This shouldn't be built unconditionally.

Please use configure to probe for go compiler first.

"GNU autotools" is the term to google for. But I guess it wouldn't be too hard to follow existing examples.

Don't hesitate to ask questions.

Quoted 12 lines
tools/Makefile +5 -0
 SUBDIRS-$(CONFIG_XCUTILS) += xcutils
 SUBDIRS-$(CONFIG_X86) += firmware
 SUBDIRS-y += console
@@ -311,6 +312,20 @@ subdir-install-debugger/gdbsx: .phony
 subdir-all-debugger/gdbsx: .phony
 	$(MAKE) -C debugger/gdbsx all
 
+subdir-all-golang/xenlight: .phony
+	$(MAKE) -C golang/xenlight all
+
+subdir-clean-golang/xenlight: .phony
+	$(MAKE) -C golang/xenlight clean

tools/Makefile subdir-install-debugger/gdbsx: .phony · line 329

Quoted 10 lines
tools/Makefile +9 -0
+
+subdir-install-golang/xenlight: .phony
+	$(MAKE) -C golang/xenlight install
+
+subdir-build-golang/xenlight: .phony
+	$(MAKE) -C golang/xenlight build
+
+subdir-distclean-golang/xenlight: .phony
+	$(MAKE) -C golang/xenlight distclean
 

I think I would prefer to organise this like python bindings. That is, to have a dedicated Makefile under $LANG (python or golang) directory.

What do you think?

tools/golang/xenlight/Makefile line 5

Quoted 13 lines
tools/Makefile +0 -0
 subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony
 	$(MAKE) -C debugger/kdd clean
tools/golang/xenlight/Makefile new file +5 -0
new file mode 100644
index 0000000..c723c1d
@@ -0,0 +1,29 @@
+XEN_ROOT=$(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+BINARY = xenlightgo
+GO = go

This should probably be:

GO ?= go

Quoted 4 lines
tools/golang/xenlight/Makefile new file +4 -0
+
+.PHONY: all
+all: build
+

tools/golang/xenlight/Makefile line 19

Quoted 10 lines
tools/golang/xenlight/Makefile new file +10 -0
+.PHONY: build
+build: xenlight
+
+.PHONY: install
+install: build
+	[ -f $(BINARY) ] || $(INSTALL_PROG) xenlight.go $(DESTDIR)$(bindir)
+
+.PHONY: clean
+clean:
+	$(RM) $(BINARY)

If there are other intermediate files generated, they should be deleted, too.

tools/golang/xenlight/Makefile line 25

Quoted 6 lines
tools/golang/xenlight/Makefile new file +6 -0
+
+.PHONY: distclean
+distclean: clean
+
+
+xenlight: xenlight.go

xenlightgo: xenlight.go and delete BINARY

or

$(BINARY): xenlight.go

tools/golang/xenlight/Makefile line 26

Quoted 1 line
tools/golang/xenlight/Makefile new file +1 -0
+	$(GO) build -o $(BINARY) xenlight.go

Use $@ instead of $(BINARY). Use $< instead of xenlight.go.

But before we spend too much time on details, let's sort out some higher level issues first. My golang knowledge is rather rusted, please bear with me. :-)

I have a question: how does golang build a package that has multiple files? Presumably it has some sort of file that acts like Makefile. If so, you should probably introduce that now and use that to build this package.

Otherwise in order to avoid repetition you probably need something like the %.o: %.c rule in tools/Rules.mk.

If you need more information about GNU Make, please use info make on your system or ask questions here.

Quoted 9 lines
tools/golang/xenlight/Makefile new file +3 -0
+
+
+-include $(DEPS)
tools/golang/xenlight/xenlight.go new file +0 -0
new file mode 100644
index 0000000..50e8d8d

tools/golang/xenlight/xenlight.go line 6

Quoted 6 lines
tools/golang/xenlight/xenlight.go new file +6 -0
@@ -0,0 +1,7 @@
+package main
+
+import "fmt"
+
+func main() {
+	fmt.Println("vim-go")

vim-go ?

Quoted 4 lines
tools/golang/xenlight/xenlight.go new file +1 -0
+}
Signature · 1 line
2.7.4

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw

Re: [PATCH RFC] tools/xenlight: Create xenlight Makefile

Quoted 13 lines · Wei Liu

tools/Makefile SUBDIRS-y += misc · line 14

Quoted 9 lines · Ronald Rojas
tools/Makefile +1 -0
index 71515b4..b89f06b 100644
@@ -11,6 +11,7 @@ SUBDIRS-y += misc
 SUBDIRS-y += examples
 SUBDIRS-y += hotplug
 SUBDIRS-y += xentrace
+SUBDIRS-y += golang/xenlight

This shouldn't be built unconditionally.

Quoted 6 lines

Please use configure to probe for go compiler first.

"GNU autotools" is the term to google for. But I guess it wouldn't be too hard to follow existing examples.

Don't hesitate to ask questions.

BTW I suggested that Ronald start with enabling it unconditionally, so that he could get something straightforward related to his project (golang bindings) accomplished before having to dive right into something complicated and unrelated (autoconf).

But it's probably worth communicating that here with a comment. I'll respond directly to his mail.

Quoted 26 lines
Quoted 12 lines
tools/Makefile +5 -0
 SUBDIRS-$(CONFIG_XCUTILS) += xcutils
 SUBDIRS-$(CONFIG_X86) += firmware
 SUBDIRS-y += console
@@ -311,6 +312,20 @@ subdir-install-debugger/gdbsx: .phony
 subdir-all-debugger/gdbsx: .phony
      $(MAKE) -C debugger/gdbsx all
 
+subdir-all-golang/xenlight: .phony
+     $(MAKE) -C golang/xenlight all
+
+subdir-clean-golang/xenlight: .phony
+     $(MAKE) -C golang/xenlight clean

tools/Makefile subdir-install-debugger/gdbsx: .phony · line 329

Quoted 10 lines
tools/Makefile +9 -0
+
+subdir-install-golang/xenlight: .phony
+     $(MAKE) -C golang/xenlight install
+
+subdir-build-golang/xenlight: .phony
+     $(MAKE) -C golang/xenlight build
+
+subdir-distclean-golang/xenlight: .phony
+     $(MAKE) -C golang/xenlight distclean
 

I think I would prefer to organise this like python bindings. That is, to have a dedicated Makefile under $LANG (python or golang) directory.

Quoted 1 line

What do you think?

That's what I had in mind as well.

Quoted 17 lines
Quoted 9 lines
tools/Makefile +0 -0
 subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony
      $(MAKE) -C debugger/kdd clean
tools/golang/xenlight/Makefile new file +0 -0
new file mode 100644
index 0000000..c723c1d

tools/golang/xenlight/Makefile line 5

Quoted 5 lines
tools/golang/xenlight/Makefile new file +5 -0
@@ -0,0 +1,29 @@
+XEN_ROOT=$(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+BINARY = xenlightgo
+GO = go

This should probably be:

Quoted 1 line

GO ?= go

With an additional comment above it:

# FIXME Use autoconf to find this?

Quoted 9 lines
Quoted 9 lines
tools/golang/xenlight/Makefile new file +9 -0
+
+.PHONY: all
+all: build
+
+.PHONY: build
+build: xenlight
+
+.PHONY: install
+install: build
Quoted 8 lines

tools/golang/xenlight/Makefile line 19

Quoted 5 lines
tools/golang/xenlight/Makefile new file +5 -0
+     [ -f $(BINARY) ] || $(INSTALL_PROG) xenlight.go $(DESTDIR)$(bindir)
+
+.PHONY: clean
+clean:
+     $(RM) $(BINARY)

If there are other intermediate files generated, they should be deleted, too.

At the moment there won't be any intermediate files -- "go build" creates a temporary directory for those and deletes them after it's done automatically.

Quoted 16 lines

tools/golang/xenlight/Makefile line 25

Quoted 5 lines
tools/golang/xenlight/Makefile new file +5 -0
+.PHONY: distclean
+distclean: clean
+
+
+xenlight: xenlight.go

xenlightgo: xenlight.go and delete BINARY

or

$(BINARY): xenlight.go

tools/golang/xenlight/Makefile line 26

Quoted 1 line
tools/golang/xenlight/Makefile new file +1 -0
+     $(GO) build -o $(BINARY) xenlight.go

Use $@ instead of $(BINARY). Use $< instead of xenlight.go.

Quoted 8 lines

But before we spend too much time on details, let's sort out some higher level issues first. My golang knowledge is rather rusted, please bear with me. :-)

I have a question: how does golang build a package that has multiple files? Presumably it has some sort of file that acts like Makefile. If so, you should probably introduce that now and use that to build this package.

Not really -- you either hand it all the files it needs (like you would a C compiler), or you hand it some of the files it needs and also give it a directory to the source code for your packages, or you do things entirely its way and just type "go build" and it figures out what to do. If you want Makefile-like functionality you probably want make. :-)

In our case we'll probably end up doing the first for building the xenlight package, and the second for building the test tool.

But there's no point in getting into the nitty-gritty now because what Ronald has here isn't a package (meant to be linked against), but a program (meant to be run). So we'll have to wait until we have basic package stuff to figure out the best way to link it.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw

Re: [PATCH RFC] tools/xenlight: Create xenlight Makefile

In reply to Ronald Rojas
Quoted 3 lines · Ronald Rojas

Created basic Makfele for the Golang xenlight
project so that the project is built and
installed. A template template is alo added.

Thanks Ronald! Not a bad first submission, but a lot of things that need tightening up.

First, the normal style of most commit messages is more direct; usually in the form "Do X" (like a recipe), or in the form "We do Y".

So to translate the comment above, I'd probably say something like this:

"Create a basic Makefile to build and install libxenlight Golang bindings. Also add a template." (Or, as an example of the second form, "We also add a template so that we have something to build.")

But in the final patch, we'll probably be introducing all the libxl golang bindings in one go (not first the makefile, then the bindings, &c), so it probably makes sense to have your mock-up start with that assumption, then explain that it's still a work in progress.

The best way to do this is to put comments for the reviewers under a line with three dashes ("---") in the commit message.

So something like this:

8<--------

tools: Introduce xenlight golang bindings

Create tools/golang/xenlight and hook it into the main tools Makefile.

---

Eventually this patch will contain the actual bindings package; for now just include a stub package.

To do:
- Make a real package
- Have configure detect golang bindings properly

-------------->8

Quoted 12 lines
 tools/Makefile                    | 15 +++++++++++++++
 tools/golang/xenlight/Makefile    | 29 +++++++++++++++++++++++++++++
 tools/golang/xenlight/xenlight.go |  7 +++++++
 3 files changed, 51 insertions(+)
 create mode 100644 tools/golang/xenlight/Makefile
 create mode 100644 tools/golang/xenlight/xenlight.go
tools/Makefile +0 -0
index 71515b4..b89f06b 100644

tools/Makefile SUBDIRS-y += misc · line 14

Quoted 4 lines
tools/Makefile +1 -0
@@ -11,6 +11,7 @@ SUBDIRS-y += misc
 SUBDIRS-y += examples
 SUBDIRS-y += hotplug
 SUBDIRS-y += xentrace
+SUBDIRS-y += golang/xenlight

As Wei said, you should follow the python model, and put another Makefile in tools/golang.

And you should add a comment here saying that you plan to use autotools to do this eventually:

# FIXME: Have this controlled by a configure variable

Quoted 35 lines
tools/Makefile +14 -0
 SUBDIRS-$(CONFIG_XCUTILS) += xcutils
 SUBDIRS-$(CONFIG_X86) += firmware
 SUBDIRS-y += console
@@ -311,6 +312,20 @@ subdir-install-debugger/gdbsx: .phony
 subdir-all-debugger/gdbsx: .phony
        $(MAKE) -C debugger/gdbsx all
 
+subdir-all-golang/xenlight: .phony
+       $(MAKE) -C golang/xenlight all
+
+subdir-clean-golang/xenlight: .phony
+       $(MAKE) -C golang/xenlight clean
+
+subdir-install-golang/xenlight: .phony
+       $(MAKE) -C golang/xenlight install
+
+subdir-build-golang/xenlight: .phony
+       $(MAKE) -C golang/xenlight build
+
+subdir-distclean-golang/xenlight: .phony
+       $(MAKE) -C golang/xenlight distclean
 
 subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony
        $(MAKE) -C debugger/kdd clean
tools/golang/xenlight/Makefile new file +5 -0
new file mode 100644
index 0000000..c723c1d
@@ -0,0 +1,29 @@
+XEN_ROOT=$(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+BINARY = xenlightgo
+GO = go

tools/golang/xenlight/Makefile line 15

Quoted 10 lines
tools/golang/xenlight/Makefile new file +10 -0
+
+.PHONY: all
+all: build
+
+.PHONY: build
+build: xenlight
+
+.PHONY: install
+install: build
+       [ -f $(BINARY) ] || $(INSTALL_PROG) xenlight.go $(DESTDIR)$(bindir)

Is there a reason you decided to make this a binary (and to install it as a binary), rather than making a stub package?

Thanks,
-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#5 lore raw

Re: [PATCH RFC] tools/xenlight: Create xenlight Makefile

Quoted 8 lines · George Dunlap
Quoted 3 lines · Ronald Rojas

Created basic Makfele for the Golang xenlight
project so that the project is built and
installed. A template template is alo added.

Thanks Ronald! Not a bad first submission, but a lot of things that need tightening up.

Quoted 8 lines

First, the normal style of most commit messages is more direct; usually in the form "Do X" (like a recipe), or in the form "We do Y".

So to translate the comment above, I'd probably say something like this:

"Create a basic Makefile to build and install libxenlight Golang bindings. Also add a template." (Or, as an example of the second form, "We also add a template so that we have something to build.")

Alright, I can change the commit message. I'm still getting used to how to write patches but I'll keep it in mind of next time.

Quoted 21 lines

But in the final patch, we'll probably be introducing all the libxl golang bindings in one go (not first the makefile, then the bindings, &c), so it probably makes sense to have your mock-up start with that assumption, then explain that it's still a work in progress.

The best way to do this is to put comments for the reviewers under a line with three dashes ("---") in the commit message.

So something like this:

8<--------

tools: Introduce xenlight golang bindings

Create tools/golang/xenlight and hook it into the main tools Makefile.

---

Quoted 8 lines

Eventually this patch will contain the actual bindings package; for now just include a stub package.

To do:
- Make a real package
- Have configure detect golang bindings properly

-------------->8

Understood :). I will do this in the next iteration of the patch

Quoted 8 lines
Quoted 8 lines
 tools/Makefile                    | 15 +++++++++++++++
 tools/golang/xenlight/Makefile    | 29 +++++++++++++++++++++++++++++
 tools/golang/xenlight/xenlight.go |  7 +++++++
 3 files changed, 51 insertions(+)
 create mode 100644 tools/golang/xenlight/Makefile
 create mode 100644 tools/golang/xenlight/xenlight.go
Quoted 12 lines

tools/Makefile SUBDIRS-y += misc · line 14

Quoted 9 lines
tools/Makefile +1 -0
index 71515b4..b89f06b 100644
@@ -11,6 +11,7 @@ SUBDIRS-y += misc
 SUBDIRS-y += examples
 SUBDIRS-y += hotplug
 SUBDIRS-y += xentrace
+SUBDIRS-y += golang/xenlight

As Wei said, you should follow the python model, and put another Makefile in tools/golang.

Sorry but I don't really I don't really understand how the python Makefile works. In particular I don't really understand how the build rule and setup.py works( maybe because I haven't written any python). Would you mind giving me some intuition on how it works?

Quoted 5 lines

And you should add a comment here saying that you plan to use autotools to do this eventually:

# FIXME: Have this controlled by a configure variable

Understood.

Quoted 41 lines
Quoted 41 lines
tools/Makefile +14 -0
 SUBDIRS-$(CONFIG_XCUTILS) += xcutils
 SUBDIRS-$(CONFIG_X86) += firmware
 SUBDIRS-y += console
@@ -311,6 +312,20 @@ subdir-install-debugger/gdbsx: .phony
 subdir-all-debugger/gdbsx: .phony
        $(MAKE) -C debugger/gdbsx all
 
+subdir-all-golang/xenlight: .phony
+       $(MAKE) -C golang/xenlight all
+
+subdir-clean-golang/xenlight: .phony
+       $(MAKE) -C golang/xenlight clean
+
+subdir-install-golang/xenlight: .phony
+       $(MAKE) -C golang/xenlight install
+
+subdir-build-golang/xenlight: .phony
+       $(MAKE) -C golang/xenlight build
+
+subdir-distclean-golang/xenlight: .phony
+       $(MAKE) -C golang/xenlight distclean
 
 subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony
        $(MAKE) -C debugger/kdd clean
tools/golang/xenlight/Makefile new file +10 -0
new file mode 100644
index 0000000..c723c1d
@@ -0,0 +1,29 @@
+XEN_ROOT=$(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+BINARY = xenlightgo
+GO = go
+
+.PHONY: all
+all: build
+
+.PHONY: build
Quoted 8 lines

tools/golang/xenlight/Makefile line 15

Quoted 5 lines
tools/golang/xenlight/Makefile new file +5 -0
+build: xenlight
+
+.PHONY: install
+install: build
+       [ -f $(BINARY) ] || $(INSTALL_PROG) xenlight.go $(DESTDIR)$(bindir)

Is there a reason you decided to make this a binary (and to install it as a binary), rather than making a stub package?

I'm not sure what you mean here. Doesn't this install the go file xenlight.go, not a binary file?
Or do you want me to create a package and install that instead package? Sorry, I'm a little lost here.

Quoted 3 lines

Thanks,
-George

Thanks,
Ronald

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel