go.py :  » Build » Waf » waf-1.5.17 » wafadmin » 3rdparty » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Build » Waf 
Waf » waf 1.5.17 » wafadmin » 3rdparty » go.py
#!/usr/bin/env python
# encoding: utf-8
# go.py - Waf tool for the Go programming language
# By: Tom Wambold <tom5760@gmail.com>

import platform

import Task
import Utils
from TaskGen import feature,extension,after

Task.simple_task_type('gocompile', '${GOC} ${GOCFLAGS} -o ${TGT} ${SRC}', shell=False)
Task.simple_task_type('gopack', '${GOP} grc ${TGT} ${SRC}', shell=False)
Task.simple_task_type('golink', '${GOL} ${GOLFLAGS} -o ${TGT} ${SRC}', shell=False)

def detect(conf):

  def set_def(var, val):
    if not conf.env[var]:
      conf.env[var] = val

  set_def('GO_PLATFORM', platform.machine())

  if conf.env.GO_PLATFORM == 'x86_64':
    set_def('GO_COMPILER', '6g')
    set_def('GO_LINKER', '6l')
    set_def('GO_EXTENSION', '.6')
  elif conf.env.GO_PLATFORM == 'i386':
    set_def('GO_COMPILER', '8g')
    set_def('GO_LINKER', '8l')
    set_def('GO_EXTENSION', '.8')

  if not (conf.env.GO_COMPILER or conf.env.GO_LINKER or conf.env.GO_EXTENSION):
    raise conf.fatal('Unsupported platform ' + platform.machine())

  set_def('GO_PACK', 'gopack')
  set_def('GO_PACK_EXTENSION', '.a')

  conf.find_program(conf.env.GO_COMPILER, var='GOC', mandatory=True)
  conf.find_program(conf.env.GO_LINKER,   var='GOL', mandatory=True)
  conf.find_program(conf.env.GO_PACK,     var='GOP', mandatory=True)

@extension('.go')
def compile_go(self, node):
  try:
    self.go_nodes.append(node)
  except AttributeError:
    self.go_nodes = [node]

@feature('go')
@after('apply_core')
def apply_compile_go(self):
  try:
    nodes = self.go_nodes
  except AttributeError:
    self.go_compile_task = None
  else:
    self.go_compile_task = self.create_task('gocompile',
      nodes,
      [self.path.find_or_declare(self.target + self.env.GO_EXTENSION)])

@feature('gopackage', 'goprogram')
@after('apply_compile_go')
def apply_goinc(self):
  if not getattr(self, 'go_compile_task', None):
    return

  names = self.to_list(getattr(self, 'uselib_local', []))
  for name in names:
    obj = self.name_to_obj(name)
    if not obj:
      raise Utils.WafError('object %r was not found in uselib_local '
          '(required by %r)' % (lib_name, self.name))
    obj.post()
    self.go_compile_task.set_run_after(obj.go_package_task)
    self.go_compile_task.deps_nodes.extend(obj.go_package_task.outputs)
    self.env.append_unique('GOCFLAGS', '-I' + obj.path.abspath(obj.env))
    self.env.append_unique('GOLFLAGS', '-L' + obj.path.abspath(obj.env))

@feature('gopackage')
@after('apply_goinc')
def apply_gopackage(self):
  self.go_package_task = self.create_task('gopack',
      self.go_compile_task.outputs[0],
      self.path.find_or_declare(self.target + self.env.GO_PACK_EXTENSION))
  self.go_package_task.set_run_after(self.go_compile_task)
  self.go_package_task.deps_nodes.extend(self.go_compile_task.outputs)

@feature('goprogram')
@after('apply_goinc')
def apply_golink(self):
  self.go_link_task = self.create_task('golink',
      self.go_compile_task.outputs[0],
      self.path.find_or_declare(self.target))
  self.go_link_task.set_run_after(self.go_compile_task)
  self.go_link_task.deps_nodes.extend(self.go_compile_task.outputs)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.