Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Super-Simplified SConstruct to show issue with the scanner running prior to rebuilding the file being scanned.
- # Instructions:
- # Create in folder with three empty files: 'source_1.dat', 'source_2.dat', 'source_3.dat'.
- # Run 'scons' once to create a stable state of files
- # Modify the contents of source_1.dat or source_2.dat to be 'source_3.dat' without quotes.
- # Run 'scons -j2'
- # Notice that a 'building' occurs between 'scanning', and panic!
- import os
- import time
- import SCons
- from SCons.Script import *
- SCons.Defaults.DefaultEnvironment(tools = []) # Block default tools; loads quicker.
- project_file_name = 'project.prj'
- version_file_name = 'derp.txt'
- binary_file_name = 'out.bin'
- def scan_prj(node, env, path):
- print 'scanning ' + str(node)
- time.sleep(1)
- component_file_list = []
- for line in node.get_text_contents().splitlines():
- component_file_list.append(File(line))
- print 'done scanning ' + str(node)
- return component_file_list
- def create_project_file(target, source, env):
- print 'building ' + str(target[0])
- with open(str(target[0]), 'wb') as outfile:
- time.sleep(1)
- for infile in source:
- with open(str(infile)) as file:
- for line in file:
- outfile.write(line)
- print 'done building ' + str(target[0])
- def compiler_action(target, source, env):
- print 'creating ' + str(target[0])
- with open(str(target[0]), 'wb') as outfile:
- outfile.write('abc')
- print 'done creating ' + str(target[0])
- def version_action(target, source, env):
- with open(str(target[0]), 'wb') as version_file:
- version_file.write('version is 5')
- # Create the local environment.
- envBase = Environment(tools = [],
- BUILDERS = {'Compile' : SCons.Builder.Builder(action = compiler_action),
- 'MakeVersion' : SCons.Builder.Builder(action = version_action)},
- SCANNERS = [Scanner(function = scan_prj, skeys = ['.prj'], path_function=FindPathDirs('.'), recursive=False)])
- project_prj = envBase.Command(project_file_name, ['source_1.dat', 'source_2.dat'], create_project_file)
- version_file = envBase.MakeVersion(version_file_name, project_prj)
- binary_file = envBase.Compile(binary_file_name, [project_prj, version_file])
- Alias('release', binary_file)
- Default('release')
Add Comment
Please, Sign In to add comment