Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added support for cross compilation and also fixed DEST_CPU to repres…

…ent the canonical symbols dictated by v8
  • Loading branch information...
commit e5a0fbe500fa3b5f3e0c15f8d17a5d8026fac919 1 parent de6e88c
Rasmus Andersson authored October 24, 2010 ry committed November 13, 2010

Showing 32 changed files with 79 additions and 16 deletions. Show diff stats Hide diff stats

  1. 14  Makefile
  2. 0  deps/c-ares/{cygwin-x86 → cygwin-ia32}/ares_build.h
  3. 0  deps/c-ares/{cygwin-x86 → cygwin-ia32}/ares_config.h
  4. 0  deps/c-ares/{cygwin-x86 → cygwin-ia32}/ares_setup.h
  5. 0  deps/c-ares/{darwin-x86 → darwin-ia32}/ares_build.h
  6. 0  deps/c-ares/{darwin-x86 → darwin-ia32}/ares_config.h
  7. 0  deps/c-ares/{darwin-x86 → darwin-ia32}/ares_setup.h
  8. 0  deps/c-ares/{darwin-x86_64 → darwin-x64}/ares_build.h
  9. 0  deps/c-ares/{darwin-x86_64 → darwin-x64}/ares_config.h
  10. 0  deps/c-ares/{darwin-x86_64 → darwin-x64}/ares_setup.h
  11. 0  deps/c-ares/{freebsd-x86 → freebsd-ia32}/ares_build.h
  12. 0  deps/c-ares/{freebsd-x86 → freebsd-ia32}/ares_config.h
  13. 0  deps/c-ares/{freebsd-x86 → freebsd-ia32}/ares_setup.h
  14. 0  deps/c-ares/{freebsd-x86_64 → freebsd-x64}/ares_build.h
  15. 0  deps/c-ares/{freebsd-x86_64 → freebsd-x64}/ares_config.h
  16. 0  deps/c-ares/{freebsd-x86_64 → freebsd-x64}/ares_setup.h
  17. 0  deps/c-ares/{linux-x86 → linux-ia32}/ares_build.h
  18. 0  deps/c-ares/{linux-x86 → linux-ia32}/ares_config.h
  19. 0  deps/c-ares/{linux-x86 → linux-ia32}/ares_setup.h
  20. 0  deps/c-ares/{linux-x86_64 → linux-x64}/ares_build.h
  21. 0  deps/c-ares/{linux-x86_64 → linux-x64}/ares_config.h
  22. 0  deps/c-ares/{linux-x86_64 → linux-x64}/ares_setup.h
  23. 0  deps/c-ares/{openbsd-x86 → openbsd-ia32}/ares_build.h
  24. 0  deps/c-ares/{openbsd-x86 → openbsd-ia32}/ares_config.h
  25. 0  deps/c-ares/{openbsd-x86 → openbsd-ia32}/ares_setup.h
  26. 0  deps/c-ares/{openbsd-x86_64 → openbsd-x64}/ares_build.h
  27. 0  deps/c-ares/{openbsd-x86_64 → openbsd-x64}/ares_config.h
  28. 0  deps/c-ares/{openbsd-x86_64 → openbsd-x64}/ares_setup.h
  29. 0  deps/c-ares/{sunos-x86 → sunos-ia32}/ares_build.h
  30. 0  deps/c-ares/{sunos-x86 → sunos-ia32}/ares_config.h
  31. 0  deps/c-ares/{sunos-x86 → sunos-ia32}/ares_setup.h
  32. 81  wscript
14  Makefile
... ...
@@ -1,11 +1,19 @@
1 1
 WAF=python tools/waf-light
2 2
 
3  
-all:
4  
-	@$(WAF) build
  3
+all: program
5 4
 
6 5
 all-progress:
7 6
 	@$(WAF) -p build
8 7
 
  8
+program:
  9
+	@$(WAF) --product-type=program build
  10
+
  11
+staticlib:
  12
+	@$(WAF) --product-type=cstaticlib build
  13
+
  14
+dynamiclib:
  15
+	@$(WAF) --product-type=cshlib build
  16
+
9 17
 install:
10 18
 	@$(WAF) install
11 19
 
@@ -91,4 +99,4 @@ bench-idle:
91 99
 	./node benchmark/idle_clients.js &
92 100
 
93 101
 
94  
-.PHONY: bench clean docclean dist distclean check uninstall install all test test-all website-upload
  102
+.PHONY: bench clean docclean dist distclean check uninstall install all program staticlib dynamiclib test test-all website-upload
0  deps/c-ares/cygwin-x86/ares_build.h → deps/c-ares/cygwin-ia32/ares_build.h
File renamed without changes
0  deps/c-ares/cygwin-x86/ares_config.h → deps/c-ares/cygwin-ia32/ares_config.h
File renamed without changes
0  deps/c-ares/cygwin-x86/ares_setup.h → deps/c-ares/cygwin-ia32/ares_setup.h
File renamed without changes
0  deps/c-ares/darwin-x86/ares_build.h → deps/c-ares/darwin-ia32/ares_build.h
File renamed without changes
0  deps/c-ares/darwin-x86/ares_config.h → deps/c-ares/darwin-ia32/ares_config.h
File renamed without changes
0  deps/c-ares/darwin-x86/ares_setup.h → deps/c-ares/darwin-ia32/ares_setup.h
File renamed without changes
0  deps/c-ares/darwin-x86_64/ares_build.h → deps/c-ares/darwin-x64/ares_build.h
File renamed without changes
0  deps/c-ares/darwin-x86_64/ares_config.h → deps/c-ares/darwin-x64/ares_config.h
File renamed without changes
0  deps/c-ares/darwin-x86_64/ares_setup.h → deps/c-ares/darwin-x64/ares_setup.h
File renamed without changes
0  deps/c-ares/freebsd-x86/ares_build.h → deps/c-ares/freebsd-ia32/ares_build.h
File renamed without changes
0  deps/c-ares/freebsd-x86/ares_config.h → deps/c-ares/freebsd-ia32/ares_config.h
File renamed without changes
0  deps/c-ares/freebsd-x86/ares_setup.h → deps/c-ares/freebsd-ia32/ares_setup.h
File renamed without changes
0  deps/c-ares/freebsd-x86_64/ares_build.h → deps/c-ares/freebsd-x64/ares_build.h
File renamed without changes
0  deps/c-ares/freebsd-x86_64/ares_config.h → deps/c-ares/freebsd-x64/ares_config.h
File renamed without changes
0  deps/c-ares/freebsd-x86_64/ares_setup.h → deps/c-ares/freebsd-x64/ares_setup.h
File renamed without changes
0  deps/c-ares/linux-x86/ares_build.h → deps/c-ares/linux-ia32/ares_build.h
File renamed without changes
0  deps/c-ares/linux-x86/ares_config.h → deps/c-ares/linux-ia32/ares_config.h
File renamed without changes
0  deps/c-ares/linux-x86/ares_setup.h → deps/c-ares/linux-ia32/ares_setup.h
File renamed without changes
0  deps/c-ares/linux-x86_64/ares_build.h → deps/c-ares/linux-x64/ares_build.h
File renamed without changes
0  deps/c-ares/linux-x86_64/ares_config.h → deps/c-ares/linux-x64/ares_config.h
File renamed without changes
0  deps/c-ares/linux-x86_64/ares_setup.h → deps/c-ares/linux-x64/ares_setup.h
File renamed without changes
0  deps/c-ares/openbsd-x86/ares_build.h → deps/c-ares/openbsd-ia32/ares_build.h
File renamed without changes
0  deps/c-ares/openbsd-x86/ares_config.h → deps/c-ares/openbsd-ia32/ares_config.h
File renamed without changes
0  deps/c-ares/openbsd-x86/ares_setup.h → deps/c-ares/openbsd-ia32/ares_setup.h
File renamed without changes
0  deps/c-ares/openbsd-x86_64/ares_build.h → deps/c-ares/openbsd-x64/ares_build.h
File renamed without changes
0  deps/c-ares/openbsd-x86_64/ares_config.h → deps/c-ares/openbsd-x64/ares_config.h
File renamed without changes
0  deps/c-ares/openbsd-x86_64/ares_setup.h → deps/c-ares/openbsd-x64/ares_setup.h
File renamed without changes
0  deps/c-ares/sunos-x86/ares_build.h → deps/c-ares/sunos-ia32/ares_build.h
File renamed without changes
0  deps/c-ares/sunos-x86/ares_config.h → deps/c-ares/sunos-ia32/ares_config.h
File renamed without changes
0  deps/c-ares/sunos-x86/ares_setup.h → deps/c-ares/sunos-ia32/ares_setup.h
File renamed without changes
81  wscript
@@ -13,13 +13,21 @@ import js2c
13 13
 
14 14
 srcdir = '.'
15 15
 blddir = 'build'
16  
-
  16
+supported_archs = ('arm', 'ia32', 'x64') # 'mips' supported by v8, but not node
17 17
 
18 18
 jobs=1
19 19
 if os.environ.has_key('JOBS'):
20 20
   jobs = int(os.environ['JOBS'])
21 21
 
22 22
 
  23
+def canonical_cpu_type(arch):
  24
+  m = {'i386':'ia32', 'x86_64':'x64', 'amd64':'x64'}
  25
+  if arch in m: arch = m[arch]
  26
+  if not arch in supported_archs:
  27
+    raise Exception("supported architectures are "+', '.join(supported_archs)+\
  28
+                    " but NOT '" + arch + "'.")
  29
+  return arch
  30
+
23 31
 def set_options(opt):
24 32
   # the gcc module provides a --debug-level option
25 33
   opt.tool_options('compiler_cxx')
@@ -126,6 +134,23 @@ def set_options(opt):
126 134
                 )
127 135
 
128 136
 
  137
+  opt.add_option( '--product-type'
  138
+                , action='store'
  139
+                , default='program'
  140
+                , help='What kind of product to produce (program, cstaticlib '\
  141
+                       'or cshlib) [default: %default]'
  142
+                , dest='product_type'
  143
+                )
  144
+
  145
+  opt.add_option( '--dest-cpu'
  146
+                , action='store'
  147
+                , default=None
  148
+                , help='CPU architecture to build for. Valid values are: '+\
  149
+                       ', '.join(supported_archs)
  150
+                , dest='dest_cpu'
  151
+                )
  152
+
  153
+
129 154
 
130 155
 
131 156
 def configure(conf):
@@ -189,6 +214,14 @@ def configure(conf):
189 214
   else:
190 215
     Options.options.use_openssl = conf.env["USE_OPENSSL"] = False
191 216
 
  217
+  # normalize DEST_CPU from --dest-cpu, DEST_CPU or built-in value
  218
+  if Options.options.dest_cpu and Options.options.dest_cpu:
  219
+    conf.env['DEST_CPU'] = canonical_cpu_type(Options.options.dest_cpu)
  220
+  elif 'DEST_CPU' in os.environ and os.environ['DEST_CPU']:
  221
+    conf.env['DEST_CPU'] = canonical_cpu_type(os.environ['DEST_CPU'])
  222
+  elif 'DEST_CPU' in conf.env and conf.env['DEST_CPU']:
  223
+    conf.env['DEST_CPU'] = canonical_cpu_type(conf.env['DEST_CPU'])
  224
+
192 225
   conf.check(lib='rt', uselib_store='RT')
193 226
 
194 227
   if sys.platform.startswith("sunos"):
@@ -265,6 +298,27 @@ def configure(conf):
265 298
   if sys.platform.startswith("darwin"):
266 299
     # used by platform_darwin_*.cc
267 300
     conf.env.append_value('LINKFLAGS', ['-framework','Carbon'])
  301
+    # cross compile for architecture specified by DEST_CPU
  302
+    if 'DEST_CPU' in conf.env:
  303
+      arch = conf.env['DEST_CPU']
  304
+      # map supported_archs to GCC names:
  305
+      arch_mappings = {'ia32': 'i386', 'x64': 'x86_64'}
  306
+      if arch in arch_mappings:
  307
+        arch = arch_mappings[arch]
  308
+      flags = ['-arch', arch]
  309
+      conf.env.append_value('CCFLAGS', flags)
  310
+      conf.env.append_value('CXXFLAGS', flags)
  311
+      conf.env.append_value('LINKFLAGS', flags)
  312
+  if 'DEST_CPU' in conf.env:
  313
+    arch = conf.env['DEST_CPU']
  314
+    # TODO: -m32 is only available on 64 bit machines, so check host type
  315
+    flags = None
  316
+    if arch == 'ia32':
  317
+      flags = '-m32'
  318
+    if flags:
  319
+      conf.env.append_value('CCFLAGS', flags)
  320
+      conf.env.append_value('CXXFLAGS', flags)
  321
+      conf.env.append_value('LINKFLAGS', flags)
268 322
 
269 323
   # Needed for getaddrinfo in libeio
270 324
   conf.env.append_value("CPPFLAGS", "-DX_STACKSIZE=%d" % (1024*64))
@@ -325,15 +379,10 @@ def v8_cmd(bld, variant):
325 379
   # executable is statically linked together...
326 380
 
327 381
   # XXX Change this when v8 defaults x86_64 to native builds
  382
+  # Possible values are (arm, ia32, x64, mips).
328 383
   arch = ""
329  
-  if bld.env['DEST_CPU'] == 'x86':
330  
-    arch = ""
331  
-  elif bld.env['DEST_CPU'] == 'x86_64':
332  
-    arch = "arch=x64"
333  
-  elif bld.env['DEST_CPU'] == 'arm':
334  
-    arch = "arch=arm"
335  
-  else:
336  
-    raise Exception("supported architectures are 'x86', 'x86_64', and 'arm', but NOT '" + bld.env['DEST_CPU'] + "'.")
  384
+  if bld.env['DEST_CPU']:
  385
+    arch = "arch="+bld.env['DEST_CPU']
337 386
 
338 387
   if variant == "default":
339 388
     mode = "release"
@@ -397,10 +446,13 @@ def build(bld):
397 446
   Build.BuildContext.exec_command = exec_command
398 447
 
399 448
   Options.options.jobs=jobs
  449
+  product_type = Options.options.product_type
  450
+  product_type_is_lib = product_type != 'program'
400 451
 
401 452
   print "DEST_OS: " + bld.env['DEST_OS']
402 453
   print "DEST_CPU: " + bld.env['DEST_CPU']
403 454
   print "Parallel Jobs: " + str(Options.options.jobs)
  455
+  print "Product type: " + product_type
404 456
 
405 457
   bld.add_subdirs('deps/libeio')
406 458
 
@@ -471,16 +523,17 @@ def build(bld):
471 523
   native_cc.rule = javascript_in_c
472 524
 
473 525
   ### node lib
474  
-  node = bld.new_task_gen("cxx", "program")
  526
+  node = bld.new_task_gen("cxx", product_type)
475 527
   node.name         = "node"
476 528
   node.target       = "node"
477 529
   node.uselib = 'RT EV OPENSSL CARES EXECINFO DL KVM SOCKET NSL'
478 530
   node.add_objects = 'eio http_parser'
479  
-  node.install_path = '${PREFIX}/lib'
480  
-  node.install_path = '${PREFIX}/bin'
  531
+  if product_type_is_lib:
  532
+    node.install_path = '${PREFIX}/lib'
  533
+  else:
  534
+    node.install_path = '${PREFIX}/bin'
481 535
   node.chmod = 0755
482 536
   node.source = """
483  
-    src/node_main.cc
484 537
     src/node.cc
485 538
     src/node_buffer.cc
486 539
     src/node_javascript.cc
@@ -499,6 +552,8 @@ def build(bld):
499 552
     src/node_timer.cc
500 553
     src/node_script.cc
501 554
   """
  555
+  if not product_type_is_lib:
  556
+    node.source = 'src/node_main.cc '+node.source
502 557
 
503 558
   platform_file = "src/platform_%s.cc" % bld.env['DEST_OS']
504 559
   if os.path.exists(join(cwd, platform_file)):

0 notes on commit e5a0fbe

Please sign in to comment.
Something went wrong with that request. Please try again.