[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-API] [PATCH] Enable native/bytecode compilation choices, and some Makefile simplification


  • To: xen-api@xxxxxxxxxxxxxxxxxxx
  • From: Zheng Li <dev@xxxxxxxx>
  • Date: Fri, 23 Apr 2010 18:34:09 -0000
  • Delivery-date: Fri, 23 Apr 2010 11:35:15 -0700
  • List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>

* Enable the independent bytecode compilation mode.

Previously this was unfortunately blocked by the hard wired xapi-client.cmxa in 
the Makefile. Now we should be able to load the bytecode version of xapi client 
lib in the OCaml interpreter for interactive development with instant feedback. 
Use $(COMPILE_NATIVE) and $(COMPILE_BYTE) to control these options.

* Change a few "XXX_TARGET = $(if $(equal $(XXX_CONF), yes), $(XXX_OBJ), none)" 
to "XXX_TARGET = $(if $(XXX_CONF), $(XXX_OBJ))"

The judge conditions are not strictly equivalent in semantics. The former holds 
only if XXX_CONF equals to "yes", the later condition holds when XXX_CONF is 
set to any non-negative string (not "no", "false", "0", none etc.). But I think 
it should be the same regarding XAPI's current Makefiles, and with more 
simplicity and tolerance. A lot more simplication and optimization can be done 
to these Makefiles, it's just a matter of time. Moreover XAPI should consider 
to update to new version of OMake (which should be better, but unfortunately 
not fully compatible with the old one).


Signed-off-by: Zheng Li <dev@xxxxxxxx>


 OMakefile                         |  62 ++++++++++++++-----------------
 ocaml/idl/ocaml_backend/META.in   |   1 +
 ocaml/idl/ocaml_backend/OMakefile |   2 +-
 3 files changed, 30 insertions(+), 35 deletions(-)


diff -r 09806785f1ae -r 7b6380fd1068 OMakefile
--- a/OMakefile Tue Apr 20 19:18:53 2010 +0100
+++ b/OMakefile Fri Apr 23 18:54:31 2010 +0100
@@ -10,16 +10,16 @@
   LIBDIR = lib64
   export
 
-# Default to native code unless COMPILE_NATIVE is defined otherwise
-if $(not $(defined-env COMPILE_NATIVE))
-  COMPILE_NATIVE = yes
-  export
-BYTE_ENABLED = false
-NATIVE_ENABLED = $(if $(equal $(COMPILE_NATIVE), yes), true, false)
+# By default compile to native code but not byte code unless specified 
otherwise
+NATIVE_ENABLED=$(getenv COMPILE_NATIVE, true)
+BYTE_ENABLED=$(getenv COMPILE_BYTE, false)
+if $(not $(or $(NATIVE_ENABLED), $(BYTE_ENABLED)))
+  eprintln(At least one of native and bytecode compilation modes should be 
enabled)
+  exit(1)
+export
 
-if $(not $(defined-env CARBON_DISTFILES))
-  CARBON_DISTFILES = /usr/groups/linux/distfiles
-  export
+CARBON_DISTFILES=$(getenv CARBON_DISTFILES, /usr/groups/linux/distfiles)
+export
 
 USE_OCAMLFIND = true
 
@@ -29,7 +29,7 @@
 OCAMLCFLAGS += -g
 OCAMLOPTFLAGS = -ccopt -fPIC
 CFLAGS+=-g -O2
-if $(defined-env COMPILE_NATIVE)
+if $(NATIVE_ENABLED)
   CFLAGS+=-DCOMPILE_NATIVE
   export
 
@@ -59,29 +59,23 @@
 #clean:
 #      rm -rf doc/
 
-if $(not $(defined-env COMPILE_OCAML))
-  COMPILE_OCAML = yes
-  export
-if $(not $(defined-env COMPILE_JS))
-  COMPILE_JS = yes
-  export
-if $(not $(defined-env COMPILE_JAVA))
-  COMPILE_JAVA = yes
-  export
+COMPILE_OCAML=$(getenv COMPILE_OCAML, yes)
+COMPILE_JS=$(getenv COMPILE_JS, yes)
+COMPILE_JAVA=$(getenv COMPILE_JAVA, yes)
+export
 
-.SUBDIRS: ocaml scripts $(if $(equal $(COMPILE_JAVA), yes), java) $(if $(equal 
$(COMPILE_JS), yes), javascript)
+.SUBDIRS: ocaml scripts $(if $(COMPILE_JAVA), java) $(if $(COMPILE_JS), 
javascript)
 
 # inherits COMPILE_XENSTUFF from the Makefile (NB don't set it here or else
 # you can't build the fakeserver etc on a machine without Xen, e.g. an Apple)
-if $(not $(defined-env COMPILE_XENSTUFF))
-  COMPILE_XENSTUFF = no
-  export
+COMPILE_XENSTUFF=$(getenv COMPILE_XENSTUFF, no)
+export
 
 .PHONY: none
 
 # Ocaml 
#############################################################################
 OCAML_PHASE1=
-OCAML_PHASE2= autogen_idl ocaml/idl/ocaml_backend/xapi_client.cmxa
+OCAML_PHASE2= autogen_idl $(if $(BYTE_ENABLED), 
ocaml/idl/ocaml_backend/xapi_client.cma) $(if $(NATIVE_ENABLED), 
ocaml/idl/ocaml_backend/xapi_client.cmxa)
 
 # JS 
################################################################################
 JS_PHASE1=
@@ -93,13 +87,13 @@
 JAVA_PHASE2=
 JAVA_PHASE3=
 
-JS_PHASE1_TARGETS = $(if $(equal $(COMPILE_JS), yes), $(JS_PHASE1), none)
-JS_PHASE2_TARGETS = $(if $(equal $(COMPILE_JS), yes), $(JS_PHASE2), none)
-JS_PHASE3_TARGETS = $(if $(equal $(COMPILE_JS), yes), $(JS_PHASE3), none)
+JS_PHASE1_TARGETS = $(if $(COMPILE_JS), $(JS_PHASE1))
+JS_PHASE2_TARGETS = $(if $(COMPILE_JS), $(JS_PHASE2))
+JS_PHASE3_TARGETS = $(if $(COMPILE_JS), $(JS_PHASE3))
 
-JAVA_PHASE1_TARGETS = $(if $(equal $(COMPILE_JAVA), yes), $(JAVA_PHASE1), none)
-JAVA_PHASE2_TARGETS = $(if $(equal $(COMPILE_JAVA), yes), $(JAVA_PHASE2), none)
-JAVA_PHASE3_TARGETS = $(if $(equal $(COMPILE_JAVA), yes), $(JAVA_PHASE3), none)
+JAVA_PHASE1_TARGETS = $(if $(COMPILE_JAVA), $(JAVA_PHASE1))
+JAVA_PHASE2_TARGETS = $(if $(COMPILE_JAVA), $(JAVA_PHASE2))
+JAVA_PHASE3_TARGETS = $(if $(COMPILE_JAVA), $(JAVA_PHASE3))
 
 # Phase 3 targets divided into two depending on whether we're building the Xen 
stuff or not:
 OCAML_PHASE3_XEN = \
@@ -154,11 +148,11 @@
        ocaml/multipathrt/multipathrt
 
 
-OCAML_PHASE3 = $(if $(equal $(COMPILE_XENSTUFF), yes), $(OCAML_PHASE3_XEN) 
$(OCAML_PHASE3_NOXEN), $(OCAML_PHASE3_NOXEN))
+OCAML_PHASE3 = $(if $(COMPILE_XENSTUFF),$(OCAML_PHASE3_XEN)) 
$(OCAML_PHASE3_NOXEN)
 
-OCAML_PHASE1_TARGETS = $(if $(equal $(COMPILE_OCAML), yes), $(OCAML_PHASE1), 
none)
-OCAML_PHASE2_TARGETS = $(if $(equal $(COMPILE_OCAML), yes), $(OCAML_PHASE2), 
none)
-OCAML_PHASE3_TARGETS = $(if $(equal $(COMPILE_OCAML), yes), $(OCAML_PHASE3), 
none)
+OCAML_PHASE1_TARGETS = $(if $(COMPILE_OCAML), $(OCAML_PHASE1))
+OCAML_PHASE2_TARGETS = $(if $(COMPILE_OCAML), $(OCAML_PHASE2))
+OCAML_PHASE3_TARGETS = $(if $(COMPILE_OCAML), $(OCAML_PHASE3))
 
 
#####################################################################################
 
diff -r 09806785f1ae -r 7b6380fd1068 ocaml/idl/ocaml_backend/META.in
--- a/ocaml/idl/ocaml_backend/META.in   Tue Apr 20 19:18:53 2010 +0100
+++ b/ocaml/idl/ocaml_backend/META.in   Fri Apr 23 18:54:31 2010 +0100
@@ -1,4 +1,5 @@
 version = "@VERSION@"
 description = "XenAPI client bindings for OCaml"
 requires = "xml-light2,stdext,stunnel,http-svr,log"
+archive(byte) = "xapi_client.cma"
 archive(native) = "xapi_client.cmxa"
diff -r 09806785f1ae -r 7b6380fd1068 ocaml/idl/ocaml_backend/OMakefile
--- a/ocaml/idl/ocaml_backend/OMakefile Tue Apr 20 19:18:53 2010 +0100
+++ b/ocaml/idl/ocaml_backend/OMakefile Fri Apr 23 18:54:31 2010 +0100
@@ -142,7 +142,7 @@
 
 lib-install: META
        mkdir -p $(INSTALL_PATH)
-       ocamlfind install -destdir $(INSTALL_PATH) -ldconf ignore xapi-client 
META xapi_client.{cmxa,a} $(addsuffixes .cmi .cmx, $(XAPI_CLIENT_OBJS))
+       ocamlfind install -destdir $(INSTALL_PATH) -ldconf ignore xapi-client 
META $(addsuffixes .cmi, $(XAPI_CLIENT_OBJS)) $(if $(BYTE_ENABLED), 
xapi_client.cma) $(if $(NATIVE_ENABLED), xapi_client.cmxa xapi_client.a 
$(addsuffixes .cmx, $(XAPI_CLIENT_OBJS)))
 
 .PHONY: lib-uninstall
 lib-uninstall:

Attachment: xen-api.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.