Source

SCons_X10 / __init__.py

# -*- mode:python; coding:utf-8 -*-

#  A SCons tool to enable compilation of X10 code using SCons.
#
#  Copyright © 2010 Russel Winder
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import os

from SCons.Builder import Builder
from SCons.Script import WhereIs
from SCons.Util import CLVar

def javaModeEmitter ( target , source , env ) :
    for f in source :
        root , x10Extension =  os.path.splitext ( f.path )
        if x10Extension == env[ 'X10SUFFIX' ] :
            env.SideEffect ( [ root + '.' + extension  for extension in [ 'java' ] ] , f )
    classTargets = [ f.path + '.class' for f in target ]
    return classTargets , source

def cppModeEmitter ( target , source , env ) :
    for f in source :
        root , x10Extension =  os.path.splitext ( f.path )
        if x10Extension == env[ 'X10SUFFIX' ] :
            env.SideEffect ( [ root + '.' + extension  for extension in [ 'cc' , 'h' , 'inc' ] ] , f )
    return target , source

def exists ( env ) :
    return WhereIs ( 'x10c' ) and WhereIs ( 'x10c++' )

def generate ( env ) :
    env[ 'X10C' ] = 'x10c' 
    env[ 'X10CPP' ] = 'x10c++' 
    env[ 'X10FLAGS' ] = CLVar ( '' )
    env[ 'X10LINKFLAGS' ] = CLVar ( '' )
    env[ 'JAVACLASSSUFFIX' ] = '.class'
    env[ 'X10SUFFIX' ] = '.x10'
    x10JavaBuilder = Builder (
        action = '$X10C $X10FLAGS $SOURCE' ,
        emitter = javaModeEmitter , 
        src_suffix = [ '.x10' ] ,
        single_source = True ,
        )
    x10CppBuilder = Builder (
        action = '$X10CPP $X10FLAGS -o $TARGET $SOURCE' ,
        emitter = cppModeEmitter , 
        src_suffix = [ '.x10' ] ,
        single_source = True ,
        )
    env.Append ( BUILDERS = {
        'X10Classes' : x10JavaBuilder ,
        'X10Program' : x10CppBuilder ,
        } )
    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.