Advertisement
Guest User

sconscript2

a guest
Dec 17th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.15 KB | None | 0 0
  1. Import('envService')
  2. import os
  3.  
  4. #Need java environment because we are using SIDE to compile our grammar.  SIDE is a JAVA component.
  5. env = envService.get_envJava().Clone()
  6.  
  7. ########################################################################
  8. # Return all source files needed for grammar compilation
  9. # sideLibrary.jar is needed to compile grammar with verbyx
  10. ########################################################################
  11. def _get_source_files():
  12.     return  env.Glob(os.path.join(env['GRAMMAR_SRC_DIR'], '*.grammar')) + \
  13.             env.Glob(os.path.join(env['GRAMMAR_SRC_DIR'],'*.dictionary'))
  14.  
  15. ########################################################################
  16. # Get files generated by grammar compilation.
  17. # They will be removed when calling scons -c
  18. ########################################################################
  19. def _get_verbyx_files_to_clean():
  20.     return env.getAbsolutePath([
  21.         'LINK/data/SOURCES'])
  22.  
  23. ########################################################################
  24. # Get target generated by grammar compilation.
  25. # They will be removed when calling scons -c
  26. ########################################################################
  27. def _get_verbyx_target():
  28.     return  env.getAbsolutePath([
  29.         'LINK/data/Grammars/abnf/bin/'  + env['LANGUAGE'] + '/' + env['GRAMMAR_NAME'] + '/autopron',
  30.         'LINK/data/Grammars/abnf/bin/'  + env['LANGUAGE'] + '/' + env['GRAMMAR_NAME'] + '/grammar',
  31.         'LINK/data/Grammars/abnf/bin/'  + env['LANGUAGE'] + '/' + env['GRAMMAR_NAME'] + '/lexicon',
  32.         'LINK/data/Grammars/abnf/bin/'  + env['LANGUAGE'] + '/' + env['GRAMMAR_NAME'] + '/package',
  33.         'LINK/data/Grammars/abnf/bin/'  + env['LANGUAGE'] + '/' + env['GRAMMAR_NAME'] + '/semantic',
  34.         'LINK/data/Grammars/abnf/bin/'  + env['LANGUAGE'] + '/' + env['GRAMMAR_NAME'] + '/version.txt'])
  35.  
  36. ########################################################################
  37. # Get files generated by grammar compilation.
  38. # They will be removed when calling scons -c
  39. ########################################################################
  40. def get_nuance_files_to_clean():
  41.     return env.getAbsolutePath([
  42.         'LINK/data/Grammars/bin'])
  43.  
  44. ########################################################################
  45. ############################  MAIN  ####################################
  46. ########################################################################
  47. env['LANGUAGE']       = 'en'
  48. env['LANGUAGE_PACK']  = 'English.America.3.3.0'
  49. env['GRAMMAR_NAME']   = 'faa'
  50. env['GRAMMAR_PRJ']    = 'faa'
  51. env['GRAMMAR_SRC_DIR']= os.path.join(env['LOCALROOT'],'sr','sra','src','grammars',env['LANGUAGE'],env['GRAMMAR_PRJ'])
  52. env['DEPLOY_PATH']    = os.path.join(env['LOCALROOT'],'sr','sra','src','grammars')
  53. env['GRAMMAR_FOLDER_NAME'] = 'grammars'
  54.  
  55. #Compiles the grammar using a scons Command mechanism.
  56. #fuck = _get_verbyx_target()
  57. #for f in fuck:
  58. #    print str(f)
  59. vrxTgt = env.buildGrammarForVrx(_get_verbyx_target(),
  60.                                 _get_source_files())
  61. print 'myTargets:'
  62. for f in vrxTgt:
  63.     print str(f)
  64. print 'endMyTargets'
  65.  
  66. #Invoke with scons -c
  67. env.Clean(vrxTgt, _get_verbyx_files_to_clean())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement