tools/xenlight: Create xenlight Makefile
RFC PATCH 1/1 tools/xenlight: Create xenlight Makefile
Create a basic Makefile to build and install libxenlight Golang bindings. Also add a template.
---
Eventually this patch will contain the actual bindings package; for now it just includes a stub package.
To Do:
- Have configure detect golang bindings properly
--- tools/Makefile | 16 ++++++++++++++++ tools/golang/Makefile | 33 +++++++++++++++++++++++++++++++++ tools/golang/xenlight/xenlight.go | 7 +++++++ 3 files changed, 56 insertions(+) create mode 100644 tools/golang/Makefile create mode 100644 tools/golang/xenlight/xenlight.go
tools/Makefile +16 -0
@@ -11,6 +11,8 @@ SUBDIRS-y += misc SUBDIRS-y += examples SUBDIRS-y += hotplug SUBDIRS-y += xentrace +SUBDIRS-y += golang +#FIXME: Have golang controlled by a configure variable SUBDIRS-$(CONFIG_XCUTILS) += xcutils SUBDIRS-$(CONFIG_X86) += firmware SUBDIRS-y += console
@@ -311,6 +313,20 @@ subdir-install-debugger/gdbsx: .phony subdir-all-debugger/gdbsx: .phony $(MAKE) -C debugger/gdbsx all +subdir-all-golang/xenlight: .phony + $(MAKE) -C golang all + +subdir-clean-golang/xenlight: .phony + $(MAKE) -C golang clean + +subdir-install-golang/xenlight: .phony + $(MAKE) -C golang install + +subdir-build-golang/xenlight: .phony + $(MAKE) -C golang build + +subdir-distclean-golang/xenlight: .phony + $(MAKE) -C golang distclean subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony $(MAKE) -C debugger/kdd clean
tools/golang/Makefile new file +33 -0
@@ -0,0 +1,33 @@ +XEN_ROOT=$(CURDIR)/../.. +include $(XEN_ROOT)/tools/Rules.mk + +BINARY = xenlight.a +GO ?= go + +.PHONY: all +all: build + +.PHONY: build +build: xenlight/xenlight.a + +.PHONY: install +install: build + if [ ! -f $(BINARY) ]; then \ + mkdir $(GOPATH)/src/xenlight; \ + $(INSTALL_PROG) xenlight/xenlight.go $(GOPATH)/src/xenlight/xenlight.go; \ + echo "this"; \ + fi + +.PHONY: clean +clean: + $(RM) $(BINARY) + +.PHONY: distclean +distclean: clean + + +xenlight/xenlight.a: xenlight/xenlight.go + $(GO) build -o $@ $< + + +-include $(DEPS)
tools/golang/xenlight/xenlight.go new file +7 -0
@@ -0,0 +1,7 @@ +package xenlight + +import "fmt" + +func main() { + fmt.Println("go") +}
Signature · 7 lines
2.7.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 8 lines · Ronald Rojas
Create a basic
Makefileto build and install libxenlight Golang bindings. Also add a template.---
Eventually this patch will contain the actual bindings package; for now it just includes a stub package.
So I'm curious why the interest to include Golang bindings in the tree. Most people are going to expect a Go package to behave like any other go package and be able to grab it with "go get". But by including this in the tree I believe that method will not work.
I say this because when I finally get around to making Rust bindings for Xen, I have no plan to include them in the tree but instead publish them at crates.io so that they work like every other Rust package.
Signature · 1 line
Doug Goldstein
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 2 lines · Ronald Rojas
Create a basic
Makefileto build and install libxenlight Golang bindings. Also add a template.
What's this template again?
Quoted 63 lines
---
Eventually this patch will contain the actual bindings package; for now it just includes a stub package.
To Do:
- Have configure detect golang bindings properlyCC xen-devel <[email protected]>CC Ian Jackson <[email protected]>CC Wei Liu <[email protected]>CC George Dunlap <[email protected]>CC George Dunlap <[email protected]>--- tools/Makefile | 16 ++++++++++++++++ tools/golang/Makefile | 33 +++++++++++++++++++++++++++++++++ tools/golang/xenlight/xenlight.go | 7 +++++++ 3 files changed, 56 insertions(+) create mode 100644 tools/golang/Makefile create mode 100644 tools/golang/xenlight/xenlight.gotools/Makefile +16
-0@@ -11,6 +11,8 @@ SUBDIRS-y += misc SUBDIRS-y += examples SUBDIRS-y += hotplug SUBDIRS-y += xentrace +SUBDIRS-y += golang +#FIXME: Have golang controlled by a configure variable SUBDIRS-$(CONFIG_XCUTILS) += xcutils SUBDIRS-$(CONFIG_X86) += firmware SUBDIRS-y += console@@ -311,6 +313,20 @@ subdir-install-debugger/gdbsx: .phony subdir-all-debugger/gdbsx: .phony $(MAKE) -C debugger/gdbsx all +subdir-all-golang/xenlight: .phony + $(MAKE) -C golang all + +subdir-clean-golang/xenlight: .phony + $(MAKE) -C golang clean + +subdir-install-golang/xenlight: .phony + $(MAKE) -C golang install + +subdir-build-golang/xenlight: .phony + $(MAKE) -C golang build + +subdir-distclean-golang/xenlight: .phony + $(MAKE) -C golang distclean subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony $(MAKE) -C debugger/kdd cleantools/golang/Makefile new file +1
-0@@ -0,0 +1,33 @@ +XEN_ROOT=$(CURDIR)/../..
tools/golang/Makefile line 11
Quoted 10 lines
tools/golang/Makefile new file +10
-0+include $(XEN_ROOT)/tools/Rules.mk + +BINARY = xenlight.a +GO ?= go + +.PHONY: all +all: build + +.PHONY: build +build: xenlight/xenlight.a
I think eventually we'll want to have a makefile in tools/golang which calls the makefiles in tools/golang/xenlight and other directories; but since we have only one at the moment, I think this is probably fine.
tools/golang/Makefile line 19
Quoted 7 lines
tools/golang/Makefile new file +7
-0+.PHONY: install +install: build + if [ ! -f $(BINARY) ]; then \ + mkdir $(GOPATH)/src/xenlight; \ + $(INSTALL_PROG) xenlight/xenlight.go $(GOPATH)/src/xenlight/xenlight.go; \ + echo "this"; \ + fi
A couple of things.
First, as we discussed on IRC, the if[] clause is not necessary -- make will automatically stop if one of the prerequisites isn't available.
Secondly -- this is a bit confusing, but the "install" section of the parts of the tree that actually build things don't install files directly onto the host filesystem. Instead, they install into $(DESTDIR) (which is xen.git/dist/install), and then the final step of "make install" will copy everything from dist/install into the host filesystem.
Also, you shouldn't do a plain mkdir, but should use $(INSTALL_DIR). And since the file you're installing is not going to be executed, you should use $(INSTALL_DATA). (I didn't realize that distinction existed until I looked at tools/libxl/Makefile).
So this should look more like:
install: build
$(INSTALL_DIR) $(DESTDIR)$(GOLANG_SRC) $(INSTALL_DATA) xenlight/xenlight.go $(DESTDIR)$(GOLANG_SRC)
And we want the package name to be "xenproject.org/xenlight", so that we can put up a repo at git://xenproject.org/xenlight and have people download it automatically. So GOLANG_SRC should be set by default to $(GOPATH)/src/xenproject.org/xenlight
With that done I think we might be ready to add some golang code. :-)
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 9 lines · Doug Goldstein
Quoted 5 lines · Ronald Rojas
Create a basic
Makefileto build and install libxenlight Golang bindings. Also add a template.---
Quoted 8 lines
Quoted 3 lines
Eventually this patch will contain the actual bindings package; for now it just includes a stub package.
So I'm curious why the interest to include Golang bindings in the tree. Most people are going to expect a Go package to behave like any other go package and be able to grab it with "go get". But by including this in the tree I believe that method will not work.
My plan was to name the package such that we could have an automatically-mirrored git repo in the expected place; i.e.,
git://xenproject.org/xenlight
The “fetch the tree automatically based on the package name” distribution mechanism might be a decent fit for web-based technologies, but I think it’s a terrible fit for mature software projects like Xen; and I expect that there will be a shift in the next few years as people (re-)discover this. I want to make it work, but I think that should be secondary to actually installing the library as a part of installing a Xen package / “make install”.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 5 lines · George Dunlap
Quoted 2 lines · Ronald Rojas
Create a basic
Makefileto build and install libxenlight Golang bindings. Also add a template.What's this template again?
I use 'template' to mean the same thing as 'stub package'. I can change the wording to say 'stub package' instead if that's more clear.
Quoted 71 lines
Quoted 71 lines
---
Eventually this patch will contain the actual bindings package; for now it just includes a stub package.
To Do:
- Have configure detect golang bindings properlyCC xen-devel <[email protected]>CC Ian Jackson <[email protected]>CC Wei Liu <[email protected]>CC George Dunlap <[email protected]>CC George Dunlap <[email protected]>--- tools/Makefile | 16 ++++++++++++++++ tools/golang/Makefile | 33 +++++++++++++++++++++++++++++++++ tools/golang/xenlight/xenlight.go | 7 +++++++ 3 files changed, 56 insertions(+) create mode 100644 tools/golang/Makefile create mode 100644 tools/golang/xenlight/xenlight.gotools/Makefile +16
-0@@ -11,6 +11,8 @@ SUBDIRS-y += misc SUBDIRS-y += examples SUBDIRS-y += hotplug SUBDIRS-y += xentrace +SUBDIRS-y += golang +#FIXME: Have golang controlled by a configure variable SUBDIRS-$(CONFIG_XCUTILS) += xcutils SUBDIRS-$(CONFIG_X86) += firmware SUBDIRS-y += console@@ -311,6 +313,20 @@ subdir-install-debugger/gdbsx: .phony subdir-all-debugger/gdbsx: .phony $(MAKE) -C debugger/gdbsx all +subdir-all-golang/xenlight: .phony + $(MAKE) -C golang all + +subdir-clean-golang/xenlight: .phony + $(MAKE) -C golang clean + +subdir-install-golang/xenlight: .phony + $(MAKE) -C golang install + +subdir-build-golang/xenlight: .phony + $(MAKE) -C golang build + +subdir-distclean-golang/xenlight: .phony + $(MAKE) -C golang distclean subdir-clean-debugger/kdd subdir-distclean-debugger/kdd: .phony $(MAKE) -C debugger/kdd cleantools/golang/Makefile new file +8
-0@@ -0,0 +1,33 @@ +XEN_ROOT=$(CURDIR)/../.. +include $(XEN_ROOT)/tools/Rules.mk + +BINARY = xenlight.a +GO ?= go + +.PHONY: all +all: build
Quoted 8 lines
tools/golang/Makefile line 11
Quoted 3 lines
tools/golang/Makefile new file +3
-0+ +.PHONY: build +build: xenlight/xenlight.aI think eventually we'll want to have a makefile in
tools/golangwhich calls the makefiles intools/golang/xenlightand other directories; but since we have only one at the moment, I think this is probably fine.
I'll make a list so that if I have time late down the line, I'll remember to do this.
Quoted 9 lines
tools/golang/Makefile line 19
Quoted 8 lines
tools/golang/Makefile new file +7
-0+.PHONY: install +install: build + if [ ! -f $(BINARY) ]; then \ + mkdir $(GOPATH)/src/xenlight; \ + $(INSTALL_PROG) xenlight/xenlight.go $(GOPATH)/src/xenlight/xenlight.go; \ + echo "this"; \ + fi
Quoted 5 lines
A couple of things.
First, as we discussed on IRC, the if[] clause is not necessary -- make will automatically stop if one of the prerequisites isn't available.
ok. I will delete the 'if' clause.
Quoted 13 lines
Secondly -- this is a bit confusing, but the "install" section of the parts of the tree that actually build things don't install files directly onto the host filesystem. Instead, they install into $(DESTDIR) (which is xen.git/dist/install), and then the final step of "make install" will copy everything from dist/install into the host filesystem.
Also, you shouldn't do a plain mkdir, but should use $(INSTALL_DIR). And since the file you're installing is not going to be executed, you should use $(INSTALL_DATA). (I didn't realize that distinction existed until I looked at
tools/libxl/Makefile).
Quoted 5 lines
So this should look more like:
install: build
$(INSTALL_DIR) $(DESTDIR)$(GOLANG_SRC) $(INSTALL_DATA) xenlight/xenlight.go $(DESTDIR)$(GOLANG_SRC)
Ok, I will change the the install rule with the appropriate changes
Quoted 5 lines
And we want the package name to be "xenproject.org/xenlight", so that we can put up a repo at
git://xenproject.org/xenlightand have people download it automatically. SoGOLANG_SRCshould be set by default to $(GOPATH)/src/xenproject.org/xenlight
Fixed
Quoted 4 lines
With that done I think we might be ready to add some golang code. :-)
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel