[llvm-commits] [hlvm] r38159 - in /hlvm/trunk/build: bytecode.py configfile.py hlvm.py

Reid Spencer reid at x10sys.com
Sat Jul 7 17:00:34 PDT 2007


Author: reid
Date: Sat Jul  7 19:00:34 2007
New Revision: 38159

URL: http://llvm.org/viewvc/llvm-project?rev=38159&view=rev
Log:
Provide an accessor for the ConfigFile builder.
Allow the options cache to be stored under different build names
Make sure some common variables are initialized.

Added:
    hlvm/trunk/build/configfile.py
Modified:
    hlvm/trunk/build/bytecode.py
    hlvm/trunk/build/hlvm.py

Modified: hlvm/trunk/build/bytecode.py
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/build/bytecode.py?rev=38159&r1=38158&r2=38159&view=diff

==============================================================================
--- hlvm/trunk/build/bytecode.py (original)
+++ hlvm/trunk/build/bytecode.py Sat Jul  7 19:00:34 2007
@@ -3,10 +3,29 @@
 from string import join as sjoin
 from os.path import join as pjoin
 
-def BytecodeMessage(target,source,env):
-  return "Generating Bytecode From C++ Source"
+def AsmFromBytecodeMessage(target,source,env):
+  return "Generating Native Assembly From LLVM Bytecode" + source[0].path
 
-def BytecodeAction(target,source,env):
+def AsmFromBytecodeAction(target,source,env):
+  theAction = env.Action(env['with_llc'] + ' -f -fast -o ' + target[0].path +
+      ' ' + source[0].path)
+  env.Depends(target,env['with_llc'])
+  return env.Execute(theAction)
+
+def BytecodeFromAsmMessage(target,source,env):
+  return "Generating Bytecode From LLVM Assembly " + source[0].path
+
+def BytecodeFromAsmAction(target,source,env):
+  theAction = env.Action(env['with_llvmas'] + 
+      ' -f -o ' + target[0].path + ' ' + source[0].path + ' ' + 
+      env['LLVMASFLAGS'])
+  env.Depends(target,env['with_llvmas'])
+  return env.Execute(theAction);
+
+def BytecodeFromCppMessage(target,source,env):
+  return "Generating Bytecode From C++ Source " + source[0].path
+
+def BytecodeFromCppAction(target,source,env):
   includes = ""
   for inc in env['CPPPATH']:
     if inc[0] == '#':
@@ -21,8 +40,8 @@
   src = source[0].path
   tgt = target[0].path
   theAction = env.Action(
-    "PATH='" + env['LLVM_bin'] + "' " + env['with_llvmgxx'] + ' -Wall' +
-      includes + defines + " -c -x c++ " + src + " -o " + tgt )
+    "PATH='" + env['LLVM_bin'] + "' " + env['with_llvmgxx'] + ' $CXXFLAGS ' + 
+    includes + defines + " -c -x c++ " + src + " -o " + tgt )
   env.Depends(target,env['with_llvmgxx'])
   return env.Execute(theAction);
 
@@ -38,12 +57,21 @@
   env.Depends(target[0],env['with_llvmar'])
   return env.Execute(theAction);
 
-
 def Bytecode(env):
-  bc = env.Action(BytecodeAction,BytecodeMessage)
+  bc2s = env.Action(AsmFromBytecodeAction,AsmFromBytecodeMessage)
+  ll2bc = env.Action(BytecodeFromAsmAction,BytecodeFromAsmMessage)
+  cpp2bc = env.Action(BytecodeFromCppAction,BytecodeFromCppMessage)
   arch = env.Action(BytecodeArchiveAction,BytecodeArchiveMessage)
-  bc_bldr = env.Builder(action=bc,suffix='bc',src_suffix='cpp',single_source=1)
-  arch_bldr = env.Builder(
-    action=arch,suffix='bca',src_suffix='bc',src_builder=bc_bldr)
-  env.Append(BUILDERS = {'Bytecode':bc_bldr, 'BytecodeArchive':arch_bldr})
+  bc2s_bldr = env.Builder(action=bc2s,suffix='s',src_suffix='bc',
+              single_source=1)
+  ll2bc_bldr  = env.Builder(action=ll2bc,suffix='bc',src_suffix='ll',
+              single_source=1)
+  cpp2bc_bldr = env.Builder(action=cpp2bc,suffix='bc',src_suffix='cpp',
+              single_source=1)
+  arch_bldr = env.Builder(action=arch,suffix='bca',src_suffix='bc',
+      src_builder=[ cpp2bc_bldr,ll2bc_bldr])
+  env.Append(BUILDERS = {
+      'll2bc':ll2bc_bldr, 'cpp2bc':cpp2bc_bldr, 'bc2s':bc2s_bldr, 
+      'BytecodeArchive':arch_bldr
+  })
   return 1

Added: hlvm/trunk/build/configfile.py
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/build/configfile.py?rev=38159&view=auto

==============================================================================
--- hlvm/trunk/build/configfile.py (added)
+++ hlvm/trunk/build/configfile.py Sat Jul  7 19:00:34 2007
@@ -0,0 +1,28 @@
+from SCons.Environment import Environment as Environment
+import re,fileinput,os
+from string import join as sjoin
+from os.path import join as pjoin
+
+def BytecodeMessage(target,source,env):
+  return "Generating Bytecode From C++ Source"
+
+def BytecodeAction(target,source,env):
+  includes = ""
+  for inc in env['CPPPATH']:
+    if inc[0] == '#':
+      inc = env['AbsSrcRoot'] + inc[1:]
+    includes += " -I" + inc
+  defines = ""
+  for d in env['CPPDEFINES'].keys():
+    if env['CPPDEFINES'][d] == None:
+      defines += " -D" + d
+    else:
+      defines += " -D" + d + "=" + env['CPPDEFINES'][d]
+  src = source[0].path
+  tgt = target[0].path
+  theAction = env.Action(
+    "PATH='" + env['LLVM_bin'] + "' " + env['with_llvmgxx'] + ' -Wall' +
+      includes + defines + " -g -c -x c++ " + src + " -o " + tgt )
+  env.Depends(target,env['with_llvmgxx'])
+  return env.Execute(theAction);
+

Modified: hlvm/trunk/build/hlvm.py
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/build/hlvm.py?rev=38159&r1=38158&r2=38159&view=diff

==============================================================================
--- hlvm/trunk/build/hlvm.py (original)
+++ hlvm/trunk/build/hlvm.py Sat Jul  7 19:00:34 2007
@@ -10,6 +10,7 @@
 from string import join as sjoin
 from string import replace as strrepl
 import glob
+import datetime
 
 def GetFiles(env,pat):
   prefix = env.Dir('.').abspath
@@ -39,6 +40,10 @@
   from build import bytecode
   return bytecode.Bytecode(env)
 
+def GetConfigFile(env):
+  from build import filterbuilders
+  return filterbuilders.ConfigFile(env)
+
 def Dirs(env,dirlist=[]):
   dir = env.Dir('.').path
   if (dir == env.Dir('#').path):
@@ -75,7 +80,12 @@
   env.EnsureSConsVersion(0,96)
   env.SetOption('implicit_cache',1)
   env.TargetSignatures('build')
-  opts = Options('.options_cache',arguments)
+  if 'mode' in arguments:
+    buildname = arguments['mode']
+  else:
+    buildname = 'default'
+  options_file = '.' + buildname + '_options'
+  opts = Options(options_file)
   opts.AddOptions(
     BoolOption('assertions','Include assertions in the code',1),
     BoolOption('debug','Build with debug options turned on',1),
@@ -85,11 +95,11 @@
     BoolOption('small','Generate smaller code rather than faster',0),
   )
   opts.Add('prefix','Specify where to install HLVM','/usr/local')
-  opts.Add('confpath','Specify additional configuration dirs to search',''),
-  opts.Add('with_llvm','Specify where LLVM is located','/usr/local'),
-  opts.Add('with_apr','Specify where apr is located','/usr/local/apr'),
-  opts.Add('with_apru','Specify where apr-utils is located','/usr/local/apr'),
-  opts.Add('with_xml2','Specify where LibXml2 is located','/usr/local'),
+  opts.Add('confpath','Specify additional configuration dirs to search','')
+  opts.Add('with_llvm','Specify where LLVM is located','/usr/local')
+  opts.Add('with_apr','Specify where apr is located','/usr/local/apr')
+  opts.Add('with_apru','Specify where apr-utils is located','/usr/local/apr')
+  opts.Add('with_xml2','Specify where LibXml2 is located','/usr/local')
   opts.Add('with_gperf','Specify where the gperf program is located',
            '/usr/local/bin/gperf')
   opts.Add('with_llc','Specify where the LLVM compiler is located',
@@ -181,6 +191,10 @@
   env.Prepend(CPPPATH=['#'])
   env['LIBPATH'] = []
   env['BINPATH'] = []
+  env['LLVMASFLAGS'] = ''
+  env['LLVM2CPPFLAGS'] = ''
+  env['LLVMGXXFLAGS'] = ''
+  env['LLVMGCCFLAGS'] = ''
   env.BuildDir(BuildDir,'#',duplicate=0)
   env.SConsignFile(pjoin(BuildDir,'sconsign'))
   if 'install' in COMMAND_LINE_TARGETS:
@@ -200,8 +214,8 @@
 
 Options:
 """ + opts.GenerateHelpText(env,sort=cmp))
-  print "HLVM BUILD MODE:", VariantName
+  print "HLVM BUILD MODE: " + VariantName + " (" + buildname + ")"
   ConfigureHLVM(env)
-  opts.Save('.options_cache',env)
+  opts.Save(options_file,env)
   return env
 





More information about the llvm-commits mailing list