add scons build
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue Aug 29 17:34:37 2006 +0200 (2006-08-29)
changeset 8cb4ae01ba180
parent 7 e53ac3c458e9
child 9 2c31ae7c94db
add scons build
SConstruct
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/SConstruct	Tue Aug 29 17:34:37 2006 +0200
     1.3 @@ -0,0 +1,660 @@
     1.4 +
     1.5 +import os
     1.6 +import os.path
     1.7 +import shutil
     1.8 +
     1.9 +class Ns3Module:
    1.10 +	def __init__ (self, name, dir):
    1.11 +		self.sources = []
    1.12 +		self.inst_headers = []
    1.13 +		self.headers = []
    1.14 +		self.extra_dist = []
    1.15 +		self.deps = []
    1.16 +		self.external_deps = []
    1.17 +		self.config = []
    1.18 +		self.name = name
    1.19 +		self.dir = dir
    1.20 +		self.executable = False
    1.21 +		self.library = True
    1.22 +	def set_library (self):
    1.23 +		self.library = True
    1.24 +		self.executable = False
    1.25 +	def set_executable (self):
    1.26 +		self.library = False
    1.27 +		self.executable = True
    1.28 +	def add_config (self, config_fn):
    1.29 +		self.config.append (config_fn)
    1.30 +	def add_extra_dist (self, dist):
    1.31 +		self.extra_dist.append (dist)
    1.32 +	def add_external_dep (self, dep):
    1.33 +		self.external_deps.append (dep)
    1.34 +	def add_dep (self, dep):
    1.35 +		self.deps.append (dep)
    1.36 +	def add_deps (self, deps):
    1.37 +		self.deps.extend (deps)
    1.38 +	def add_source (self, source):
    1.39 +		self.sources.append (source)
    1.40 +	def add_sources (self, sources):
    1.41 +		self.sources.extend (sources)
    1.42 +	def add_header (self, header):
    1.43 +		self.headers.append (header)
    1.44 +	def add_headers (self, headers):
    1.45 +		self.headers.extend (headers)
    1.46 +	def add_inst_header (self, header):
    1.47 +		self.inst_headers.append (header)
    1.48 +	def add_inst_headers (self, headers):
    1.49 +		self.inst_headers.extend (headers)
    1.50 +
    1.51 +def MyCopyAction (target, source, env):
    1.52 +	try:
    1.53 +		if len (target) == len (source):
    1.54 +			for i in range (len(target)):
    1.55 +				shutil.copy (source[i].path, target[i].path)
    1.56 +			return 0
    1.57 +		else:
    1.58 +			return 'invalid target/source match'
    1.59 +	except:
    1.60 +		print
    1.61 +		return 'exception'
    1.62 +def MyCopyActionPrint (target, source, env):
    1.63 +	if len (target) == len (source):
    1.64 +		output = ''
    1.65 +		for i in range (len(target)):
    1.66 +			output = output + 'copy \'' + source[i].path + '\' to \'' + target[i].path  + '\''
    1.67 +			if i < len (target) - 1:
    1.68 +				output = output + '\n'
    1.69 +		return output
    1.70 +	else:
    1.71 +		return 'error in copy'
    1.72 +def GcxxEmitter (target, source, env):
    1.73 +	if os.path.exists (source[0].path):
    1.74 +		return [target, source]
    1.75 +	else:
    1.76 +		return [[], []]
    1.77 +def MyRmTree (target, source, env):
    1.78 +	shutil.rmtree (env['RM_DIR'])
    1.79 +	return 0
    1.80 +def MyRmTreePrint (target, source, env):
    1.81 +	return ''
    1.82 +def print_cmd_line(s, target, src, env):
    1.83 +	print 'Building ' + (' and '.join([str(x) for x in target])) + '...'
    1.84 +
    1.85 +class Ns3BuildVariant:
    1.86 +	def __init__ (self):
    1.87 +		self.static = False
    1.88 +		self.gcxx_deps = False
    1.89 +		self.gcxx_root = ''
    1.90 +		self.build_root = ''
    1.91 +		self.env = None
    1.92 +
    1.93 +class Ns3:
    1.94 +	def __init__ (self):
    1.95 +		self.__modules = []
    1.96 +		self.extra_dist = []
    1.97 +		self.build_dir = 'build'
    1.98 +		self.version = '0.0.1'
    1.99 +		self.name = 'noname'
   1.100 +	def add (self, module):
   1.101 +		self.__modules.append (module)
   1.102 +	def add_extra_dist (self, dist):
   1.103 +		self.extra_dist.append (dist)
   1.104 +	def __get_module (self, name):
   1.105 +		for module in self.__modules:
   1.106 +			if module.name == name:
   1.107 +				return module
   1.108 +		return None
   1.109 +	def get_mod_output (self, module, variant):
   1.110 +		if module.executable:
   1.111 +			suffix = variant.env.subst (variant.env['PROGSUFFIX'])
   1.112 +			filename = os.path.join (variant.build_root, 'bin',
   1.113 +						 module.name + suffix)
   1.114 +		else:
   1.115 +			if variant.static:
   1.116 +				prefix = variant.env['LIBPREFIX']
   1.117 +				suffix = variant.env['LIBSUFFIX']
   1.118 +			else:
   1.119 +				prefix = variant.env['SHLIBPREFIX']
   1.120 +				suffix = variant.env['SHLIBSUFFIX']
   1.121 +			prefix = variant.env.subst (prefix)
   1.122 +			suffix = variant.env.subst (suffix)
   1.123 +			filename = os.path.join (variant.build_root, 'lib',
   1.124 +						 prefix + module.name + suffix)
   1.125 +		return filename				
   1.126 +	def get_obj_builders (self, variant, module):
   1.127 +		env = variant.env
   1.128 +		objects = []
   1.129 +		if len (module.config) > 0:
   1.130 +			src_config_file = os.path.join (self.build_dir, 'config', module.name + '-config.h')
   1.131 +			tgt_config_file = os.path.join (variant.build_root, 'include',
   1.132 +							'ns3', module.name + '-config.h')
   1.133 +		
   1.134 +		for source in module.sources:
   1.135 +			obj_file = os.path.splitext (source)[0] + '.o'
   1.136 +			tgt = os.path.join (variant.build_root, module.dir, obj_file)
   1.137 +			src = os.path.join (module.dir, source)
   1.138 +			if variant.static:
   1.139 +				obj_builder = env.StaticObject (target = tgt, source = src)
   1.140 +			else:
   1.141 +				obj_builder = env.SharedObject (target = tgt, source = src)
   1.142 +			if len (module.config) > 0:
   1.143 +				config_file = env.MyCopyBuilder (target = [tgt_config_file],
   1.144 +								 source = [src_config_file])
   1.145 +				env.Depends (obj_builder, config_file)
   1.146 +			if variant.gcxx_deps:
   1.147 +				gcno_tgt = os.path.join (variant.build_root, module.dir, 
   1.148 +							 os.path.splitext (source)[0] + '.gcno')
   1.149 +				gcda_tgt = os.path.join (variant.build_root, module.dir,
   1.150 +							 os.path.splitext (source)[0] + '.gcda')
   1.151 +				gcda_src = os.path.join (variant.gcxx_root, module.dir, 
   1.152 +							 os.path.splitext (source)[0] + '.gcda')
   1.153 +				gcno_src = os.path.join (variant.gcxx_root, module.dir, 
   1.154 +							 os.path.splitext (source)[0] + '.gcno')
   1.155 +				gcno_builder = env.CopyGcxxBuilder (target = gcno_tgt, source = gcno_src)
   1.156 +				gcda_builder = env.CopyGcxxBuilder (target = gcda_tgt, source = gcda_src)
   1.157 +				env.Depends (obj_builder, gcda_builder)
   1.158 +				env.Depends (obj_builder, gcno_builder)
   1.159 +			objects.append (obj_builder)
   1.160 +		return objects
   1.161 +	def get_internal_deps (self, module, hash):
   1.162 +		for dep_name in module.deps:
   1.163 +			dep = self.__get_module (dep_name)
   1.164 +			hash[dep_name] = dep
   1.165 +			self.get_internal_deps (dep, hash)
   1.166 +	def get_external_deps (self, module):
   1.167 +		hash = {}
   1.168 +		self.get_internal_deps (module, hash)
   1.169 +		ext_hash = {}
   1.170 +		for mod in hash.values ():
   1.171 +			for ext_dep in mod.external_deps:
   1.172 +				ext_hash[ext_dep] = 1
   1.173 +		return ext_hash.keys ()
   1.174 +	def get_sorted_deps (self, module):
   1.175 +		h = {}
   1.176 +		self.get_internal_deps (module, h)
   1.177 +		modules = []
   1.178 +		for dep in h.keys ():
   1.179 +			deps_copy = []
   1.180 +			mod = h[dep]
   1.181 +			deps_copy.extend (mod.deps)
   1.182 +			modules.append ([mod, deps_copy])
   1.183 +		sorted = []
   1.184 +		while len (modules) > 0:
   1.185 +			to_remove = []
   1.186 +			for item in modules:
   1.187 +				if len (item[1]) == 0:
   1.188 +					to_remove.append (item[0].name)
   1.189 +			for item in to_remove:
   1.190 +				for i in modules:
   1.191 +					if item in i[1]:
   1.192 +						i[1].remove (item)
   1.193 +			new_modules = []
   1.194 +			for mod in modules:
   1.195 +				found = False
   1.196 +				for i in to_remove:
   1.197 +					if i == mod[0].name:
   1.198 +						found = True
   1.199 +						break
   1.200 +				if not found:
   1.201 +					new_modules.append (mod)
   1.202 +			modules = new_modules
   1.203 +			sorted.extend (to_remove)
   1.204 +		sorted.reverse ()
   1.205 +		# append external deps
   1.206 +		ext_deps = self.get_external_deps (module)
   1.207 +		for dep in ext_deps:
   1.208 +			sorted.append (dep)
   1.209 +		return sorted
   1.210 +			
   1.211 +	def gen_mod_dep (self, variant):
   1.212 +		build_root = variant.build_root
   1.213 +		cpp_path = os.path.join (variant.build_root, 'include')
   1.214 +		env = variant.env
   1.215 +		env.Append (CPPPATH=[cpp_path])
   1.216 +		header_dir = os.path.join (build_root, 'include', 'ns3')
   1.217 +		lib_path = os.path.join (build_root, 'lib')
   1.218 +		module_builders = []
   1.219 +		for module in self.__modules:
   1.220 +			objects = self.get_obj_builders (variant, module)
   1.221 +			libs = self.get_sorted_deps (module)
   1.222 +
   1.223 +			filename = self.get_mod_output (module, variant)
   1.224 +			if module.executable:
   1.225 +				module_builder = env.Program (target = filename, source = objects,
   1.226 +							      LIBPATH=lib_path, LIBS=libs, RPATH=lib_path)
   1.227 +			else:
   1.228 +				if variant.static:
   1.229 +					module_builder = env.StaticLibrary (target = filename, source = objects)
   1.230 +				else:
   1.231 +					module_builder = env.SharedLibrary (target = filename, source = objects,
   1.232 +									    LIBPATH=lib_path, LIBS=libs)
   1.233 +					
   1.234 +			for dep_name in module.deps:
   1.235 +				dep = self.__get_module (dep_name)
   1.236 +				env.Depends (module_builder, self.get_mod_output (dep, variant))
   1.237 +					
   1.238 +			for header in module.inst_headers:
   1.239 +				tgt = os.path.join (header_dir, header)
   1.240 +				src = os.path.join (module.dir, header)
   1.241 +				#builder = env.Install (target = tgt, source = src)
   1.242 +				header_builder = env.MyCopyBuilder (target = tgt, source = src)
   1.243 +				env.Depends (module_builder, header_builder)
   1.244 +				
   1.245 +			module_builders.append (module_builder)
   1.246 +		return module_builders
   1.247 +	def gen_mod_config (self, env):
   1.248 +		config_dir = os.path.join (self.build_dir, 'config')
   1.249 +		for module in self.__modules:
   1.250 +			if len (module.config) > 0:
   1.251 +				config_file = os.path.join (config_dir, module.name + '-config.h')
   1.252 +				config_file_guard = module.name + '_CONFIG_H'
   1.253 +				config_file_guard.upper ()
   1.254 +				if not os.path.isfile (config_file):
   1.255 +					if not os.path.isdir (config_dir):
   1.256 +						os.makedirs (config_dir)
   1.257 +					outfile = open (config_file, 'w')
   1.258 +					outfile.write ('#ifndef ' + config_file_guard + '\n')
   1.259 +					outfile.write ('#define ' + config_file_guard + '\n')
   1.260 +					config = env.Configure ()
   1.261 +					for fn in module.config:
   1.262 +						output = fn (env, config)
   1.263 +						for o in output:
   1.264 +							outfile.write (o)
   1.265 +							outfile.write ('\n')
   1.266 +					outfile.write ('#endif /*' + config_file_guard + '*/\n')
   1.267 +					config.Finish ()
   1.268 +	def generate_dependencies (self):
   1.269 +		env = Environment()
   1.270 +		self.gen_mod_config (env)
   1.271 +		cc = env['CC']
   1.272 +		cxx = env.subst (env['CXX'])
   1.273 +		if cc == 'cl' and cxx == 'cl':
   1.274 +			env = Environment (tools = ['mingw'])
   1.275 +			cc = env['CC']
   1.276 +			cxx = env.subst (env['CXX'])
   1.277 +		if cc == 'gcc' and cxx == 'g++':
   1.278 +			common_flags = ['-g3', '-Wall', '-Werror']
   1.279 +			debug_flags = []
   1.280 +			opti_flags = ['-O3']
   1.281 +		elif cc == 'cl' and cxx == 'cl':
   1.282 +			env = Environment (ENV = os.environ)
   1.283 +			common_flags = []
   1.284 +			debug_flags = ['-W1', '-GX', '-EHsc', '-D_DEBUG', '/MDd']
   1.285 +			opti_flags = ['-O2', '-EHsc', '-DNDEBUG', '/MD']
   1.286 +		env.Append (CCFLAGS=common_flags,
   1.287 +			    CPPDEFINES=['RUN_SELF_TESTS'],
   1.288 +			    TARFLAGS='-c -z')
   1.289 +		verbose = ARGUMENTS.get('verbose', 'n')
   1.290 +		if verbose == 'n':
   1.291 +			env['PRINT_CMD_LINE_FUNC'] = print_cmd_line
   1.292 +		header_builder = Builder (action = Action (MyCopyAction, strfunction = MyCopyActionPrint))
   1.293 +		env.Append (BUILDERS = {'MyCopyBuilder':header_builder})
   1.294 +		gcxx_builder = Builder (action = Action (MyCopyAction, strfunction = MyCopyActionPrint),
   1.295 +					emitter = GcxxEmitter)
   1.296 +		env.Append (BUILDERS = {'CopyGcxxBuilder':gcxx_builder})
   1.297 +		variant = Ns3BuildVariant ()
   1.298 +		builders = []
   1.299 +		
   1.300 +
   1.301 +		gcov_env = env.Copy ()
   1.302 +		gcov_env.Append (CFLAGS=['-fprofile-arcs', '-ftest-coverage'],
   1.303 +				 CXXFLAGS=['-fprofile-arcs', '-ftest-coverage'],
   1.304 +				 LINKFLAGS=['-fprofile-arcs'])
   1.305 +		# code coverage analysis
   1.306 +		variant.static = False
   1.307 +		variant.env = gcov_env
   1.308 +		variant.build_root = os.path.join (self.build_dir, 'gcov')
   1.309 +		builders = self.gen_mod_dep (variant)
   1.310 +		for builder in builders:
   1.311 +			gcov_env.Alias ('gcov', builder)
   1.312 +
   1.313 +
   1.314 +		opt_env = env.Copy ()
   1.315 +		opt_env.Append (CFLAGS=opti_flags,
   1.316 +				CXXFLAGS=opti_flags,
   1.317 +				CPPDEFINES=['NDEBUG'])
   1.318 +		# optimized static support
   1.319 +		variant.static = True
   1.320 +		variant.env = opt_env
   1.321 +		variant.build_root = os.path.join (self.build_dir, 'opt-static')
   1.322 +		builders = self.gen_mod_dep (variant)
   1.323 +		for builder in builders:
   1.324 +			opt_env.Alias ('opt-static', builder)
   1.325 +
   1.326 +
   1.327 +		opt_env = env.Copy ()
   1.328 +		opt_env.Append (CFLAGS=opti_flags,
   1.329 +				CXXFLAGS=opti_flags,
   1.330 +				CPPDEFINES=['NDEBUG'])
   1.331 +		# optimized shared support
   1.332 +		variant.static = False
   1.333 +		variant.env = opt_env
   1.334 +		variant.build_root = os.path.join (self.build_dir, 'opt-shared')
   1.335 +		builders = self.gen_mod_dep (variant)
   1.336 +		for builder in builders:
   1.337 +			opt_env.Alias ('opt-shared', builder)
   1.338 +
   1.339 +
   1.340 +		arc_env = env.Copy ()
   1.341 +		arc_env.Append (CFLAGS=opti_flags,
   1.342 +				CXXFLAGS=opti_flags,
   1.343 +				CPPDEFINES=['NDEBUG'])
   1.344 +		arc_env.Append (CFLAGS=['-frandom-seed=0','-fprofile-generate'],
   1.345 +				CXXFLAGS=['-frandom-seed=0','-fprofile-generate'],
   1.346 +				LINKFLAGS=['-frandom-seed=0', '-fprofile-generate'])
   1.347 +		# arc profiling
   1.348 +		variant.static = False
   1.349 +		variant.env = arc_env
   1.350 +		variant.build_root = os.path.join (self.build_dir, 'opt-arc')
   1.351 +		builders = self.gen_mod_dep (variant)
   1.352 +		for builder in builders:
   1.353 +			arc_env.Alias ('opt-arc', builder)
   1.354 +
   1.355 +
   1.356 +		arcrebuild_env = env.Copy ()
   1.357 +		arcrebuild_env.Append (CFLAGS=opti_flags,
   1.358 +				       CXXFLAGS=opti_flags,
   1.359 +				       CPPDEFINES=['NDEBUG'])
   1.360 +		arcrebuild_env.Append (CFLAGS=['-frandom-seed=0', '-fprofile-use'],
   1.361 +				       CXXFLAGS=['-frandom-seed=0', '-fprofile-use'],
   1.362 +				       LINKFLAGS=['-frandom-seed=0','-fprofile-use'])
   1.363 +		# arc rebuild
   1.364 +		variant.static = False
   1.365 +		variant.env = arcrebuild_env
   1.366 +		variant.gcxx_deps = True
   1.367 +		variant.gcxx_root = os.path.join (self.build_dir, 'opt-arc')
   1.368 +		variant.build_root = os.path.join (self.build_dir, 'opt-arc-rebuild')
   1.369 +		builders = self.gen_mod_dep (variant)
   1.370 +		for builder in builders:
   1.371 +			arcrebuild_env.Alias ('opt-arc-rebuild', builder)
   1.372 +		variant.gcxx_deps = False
   1.373 +
   1.374 +
   1.375 +
   1.376 +
   1.377 +		dbg_env = env.Copy ()
   1.378 +		env.Append (CFLAGS=debug_flags,
   1.379 +			    CXXFLAGS=debug_flags,)
   1.380 +		# debug static support
   1.381 +		variant.static = True
   1.382 +		variant.env = dbg_env
   1.383 +		variant.build_root = os.path.join (self.build_dir, 'dbg-static')
   1.384 +		builders = self.gen_mod_dep (variant)
   1.385 +		for builder in builders:
   1.386 +			dbg_env.Alias ('dbg-static', builder)
   1.387 +
   1.388 +		dbg_env = env.Copy ()
   1.389 +		env.Append (CFLAGS=debug_flags,
   1.390 +			    CXXFLAGS=debug_flags,)
   1.391 +		# debug shared support
   1.392 +		variant.static = False
   1.393 +		variant.env = dbg_env
   1.394 +		variant.build_root = os.path.join (self.build_dir, 'dbg-shared')
   1.395 +		builders = self.gen_mod_dep (variant)
   1.396 +		for builder in builders:
   1.397 +			dbg_env.Alias ('dbg-shared', builder)
   1.398 +
   1.399 +		env.Alias ('dbg', 'dbg-shared')
   1.400 +		env.Alias ('opt', 'opt-shared')
   1.401 +		env.Default ('dbg')
   1.402 +		env.Alias ('all', ['dbg-shared', 'dbg-static', 'opt-shared', 'opt-static'])
   1.403 +
   1.404 +
   1.405 +		# dist support
   1.406 +		dist_env = env.Copy ()
   1.407 +		if dist_env['PLATFORM'] == 'posix':
   1.408 +			dist_list = []
   1.409 +			for module in self.__modules:
   1.410 +				for f in module.sources:
   1.411 +					dist_list.append (os.path.join (module.dir, f))
   1.412 +				for f in module.headers:
   1.413 +					dist_list.append (os.path.join (module.dir, f))
   1.414 +				for f in module.inst_headers:
   1.415 +					dist_list.append (os.path.join (module.dir, f))
   1.416 +				for f in module.extra_dist:
   1.417 +					dist_list.append (os.path.join (module.dir, f))
   1.418 +			for f in self.extra_dist:
   1.419 +				dist_list.append (tag, f)
   1.420 +			dist_list.append ('SConstruct')
   1.421 +
   1.422 +			targets = []
   1.423 +			basename = self.name + '-' + self.version
   1.424 +			for src in dist_list:
   1.425 +				tgt = os.path.join (basename, src)
   1.426 +				targets.append (dist_env.MyCopyBuilder (target = tgt, source = src))
   1.427 +			tar = basename + '.tar.gz'
   1.428 +			zip = basename + '.zip'
   1.429 +			tmp_tar = os.path.join (self.build_dir, tar)
   1.430 +			tmp_zip = os.path.join (self.build_dir, zip)
   1.431 +			dist_tgt = [tar, zip]
   1.432 +			dist_src = [tmp_tar, tmp_zip]
   1.433 +			dist_env.Tar (tmp_tar, targets)
   1.434 +			dist_env.Zip (tmp_zip, targets)
   1.435 +			dist_builder = dist_env.MyCopyBuilder (target = dist_tgt, source = dist_src)
   1.436 +			dist_env.Alias ('dist', dist_builder)
   1.437 +			dist_env.Append (RM_DIR=basename)
   1.438 +			dist_env.AddPostAction (dist_builder, dist_env.Action (MyRmTree,
   1.439 +									       strfunction = MyRmTreePrint))
   1.440 +			dist_builder = dist_env.MyCopyBuilder (target = dist_tgt, source = dist_src)
   1.441 +			dist_env.Alias ('fastdist', dist_tgt)
   1.442 +
   1.443 +			# distcheck
   1.444 +			distcheck_list = []
   1.445 +			for src in dist_list:
   1.446 +				tgt = os.path.join (self.build_dir, basename, src)
   1.447 +				distcheck_list.append (tgt)
   1.448 +			untar = env.Command (distcheck_list, tar,
   1.449 +					     ['cd ' + self.build_dir + ' && tar -zxf ../' + tar])
   1.450 +			scons_dir = os.path.join (self.build_dir, basename)
   1.451 +			distcheck_builder = env.Command ('x',distcheck_list,
   1.452 +							 ['cd ' + scons_dir + ' && scons'])
   1.453 +			env.AlwaysBuild (distcheck_builder)
   1.454 +			env.Alias ('distcheck', distcheck_builder)
   1.455 +
   1.456 +
   1.457 +ns3 = Ns3 ()
   1.458 +ns3.build_dir = 'build-dir'
   1.459 +ns3.version = '0.0.1'
   1.460 +ns3.name = 'ns3'
   1.461 +
   1.462 +
   1.463 +#
   1.464 +# The Core module
   1.465 +#
   1.466 +core = Ns3Module ('core', 'src/core')
   1.467 +ns3.add (core)
   1.468 +core.add_sources ([
   1.469 +        'reference-list-test.cc',
   1.470 +        'callback-test.cc',
   1.471 +        'test.cc'
   1.472 +	])
   1.473 +env = Environment ()
   1.474 +if env['PLATFORM'] == 'posix':
   1.475 +	core.add_external_dep ('pthread')
   1.476 +	core.add_sources ([
   1.477 +		'unix-system-semaphore.cc',
   1.478 +		'unix-system-thread.cc',
   1.479 +		'unix-system-mutex.cc',
   1.480 +		'unix-exec-commands.cc',
   1.481 +		'unix-wall-clock-ms.cc',
   1.482 +		'unix-system-file.cc'
   1.483 +		])
   1.484 +elif env['PLATFORM'] == 'win32':
   1.485 +	core.add_sources ([
   1.486 +		'win32-system-semaphore.cc',
   1.487 +		'win32-system-thread.cc',
   1.488 +		'win32-system-mutex.cc',
   1.489 +		'win32-wall-clock-ms.cc',
   1.490 +		'win32-system-file.cc'
   1.491 +		])
   1.492 +core.add_inst_headers ([
   1.493 +	'system-semaphore.h',
   1.494 +        'system-thread.h',
   1.495 +        'system-mutex.h',
   1.496 +	'system-file.h',
   1.497 +        'exec-commands.h',
   1.498 +        'wall-clock-ms.h',
   1.499 +        'reference-list.h',
   1.500 +        'callback.h',
   1.501 +        'test.h'
   1.502 +	])
   1.503 +
   1.504 +
   1.505 +#
   1.506 +# The Simu module
   1.507 +#
   1.508 +simu = Ns3Module ('simulator', 'src/simulator')
   1.509 +ns3.add (simu)
   1.510 +simu.add_dep ('core')
   1.511 +simu.add_sources ([
   1.512 +	'scheduler.cc', 
   1.513 +	'scheduler-list.cc',
   1.514 +        'scheduler-heap.cc',
   1.515 +        'scheduler-map.cc',
   1.516 +        'event-impl.cc',
   1.517 +        'event-tcc.cc',
   1.518 +        'event-tcc-test.cc',
   1.519 +        'simulator.cc',
   1.520 +	])
   1.521 +simu.add_headers ([
   1.522 +	'scheduler.h',
   1.523 +	'scheduler-heap.h',
   1.524 +	'scheduler-map.h',
   1.525 +	'scheduler-list.h'
   1.526 +	])
   1.527 +simu.add_inst_headers ([
   1.528 +	'event.h',
   1.529 +	'event-impl.h',
   1.530 +	'simulator.h',
   1.531 +	'event.tcc'
   1.532 +	])
   1.533 +
   1.534 +#
   1.535 +# The Common module
   1.536 +#
   1.537 +common = Ns3Module ('common', 'src/common')
   1.538 +common.add_deps (['core', 'simulator'])
   1.539 +ns3.add (common)
   1.540 +common.add_sources ([
   1.541 +	'buffer.cc',
   1.542 +	'mac-address-factory.cc',
   1.543 +	'static-position.cc',
   1.544 +	'chunk.cc',
   1.545 +	'mac-network-interface.cc',
   1.546 +	'static-speed-position.cc',
   1.547 +	'chunk-constant-data.cc',
   1.548 +	'packet.cc',
   1.549 +	'tags.cc',
   1.550 +	'chunk-llc-snap.cc',
   1.551 +	'packet-logger.cc',
   1.552 +	'chunk-utils.cc',
   1.553 +	'pcap-writer.cc',
   1.554 +	'trace-container.cc',
   1.555 +	'population-analysis.cc',
   1.556 +	'traced-variable-test.cc',
   1.557 +	'ipv4-address.cc',
   1.558 +	'position.cc',
   1.559 +	'trace-stream-test.cc',
   1.560 +	'ipv4-network-interface.cc',
   1.561 +	'random-uniform-mrg32k3a.cc',
   1.562 +	'utils.cc',
   1.563 +	'llc-snap-encapsulation.cc',
   1.564 +	'rng-mrg32k3a.cc',
   1.565 +	'mac-address.cc',
   1.566 +	'timeout.cc',
   1.567 +	'seed-generator-mrg32k3a.cc'
   1.568 +	])
   1.569 +common.add_inst_headers ([
   1.570 +	'ipv4-address.h',
   1.571 +	'buffer.h',
   1.572 +	'chunk.h',
   1.573 +	'tags.h',
   1.574 +	'packet.h',
   1.575 +	'ipv4-network-interface.h',
   1.576 +	'count-ptr-holder.tcc',
   1.577 +	'ui-traced-variable.tcc',
   1.578 +	'si-traced-variable.tcc',
   1.579 +	'f-traced-variable.tcc',
   1.580 +	'callback-logger.h',
   1.581 +	'trace-container.h',
   1.582 +	'packet-logger.h',
   1.583 +	'chunk-constant-data.h',
   1.584 +	'mac-address.h',
   1.585 +	'chunk-utils.h',
   1.586 +	'sgi-hashmap.h',
   1.587 +	'llc-snap-encapsulation.h',
   1.588 +	'mac-network-interface.h',
   1.589 +	'population-analysis.h',
   1.590 +	'position.h',
   1.591 +	'random-uniform.h',
   1.592 +	'timeout.h',
   1.593 +	'trace-stream.h',
   1.594 +	'pcap-writer.h',
   1.595 +	'mac-address-factory.h',
   1.596 +	'static-position.h',
   1.597 +	'utils.h'
   1.598 +	])
   1.599 +common.add_headers ([
   1.600 +	'chunk-llc-snap.h',
   1.601 +	'ref-ptr.h',
   1.602 +	'rng-mrg32k3a.h',
   1.603 +	'seed-generator.h',
   1.604 +	'static-speed-position.h'
   1.605 +	])
   1.606 +
   1.607 +
   1.608 +# utils
   1.609 +run_tests = Ns3Module ('run-tests', 'utils')
   1.610 +ns3.add (run_tests)
   1.611 +run_tests.set_executable ()
   1.612 +run_tests.add_deps (['core', 'simulator', 'common', 'ipv4', 'arp', 'ethernet', '80211'])
   1.613 +run_tests.add_source ('run-tests.cc')
   1.614 +
   1.615 +bench_packets = Ns3Module ('bench-packets', 'utils')
   1.616 +#ns3.add (bench_packets)
   1.617 +bench_packets.set_executable ()
   1.618 +bench_packets.add_dep ('core')
   1.619 +bench_packets.add_source ('bench-packets.cc')
   1.620 +
   1.621 +bench_simu = Ns3Module ('bench-simulator', 'utils')
   1.622 +ns3.add (bench_simu)
   1.623 +bench_simu.set_executable ()
   1.624 +bench_simu.add_dep ('simulator')
   1.625 +bench_simu.add_source ('bench-simulator.cc')
   1.626 +
   1.627 +
   1.628 +# samples
   1.629 +main_callback = Ns3Module ('main-callback', 'samples')
   1.630 +main_callback.set_executable ()
   1.631 +ns3.add (main_callback)
   1.632 +main_callback.add_dep ('core')
   1.633 +main_callback.add_source ('main-callback.cc')
   1.634 +
   1.635 +main_event = Ns3Module ('main-event', 'samples')
   1.636 +main_event.set_executable ()
   1.637 +ns3.add (main_event)
   1.638 +main_event.add_dep ('simulator')
   1.639 +main_event.add_source ('main-event.cc')
   1.640 +
   1.641 +main_trace = Ns3Module ('main-trace', 'samples')
   1.642 +ns3.add (main_trace)
   1.643 +main_trace.add_dep ('common')
   1.644 +main_trace.set_executable ()
   1.645 +main_trace.add_source ('main-trace.cc')
   1.646 +
   1.647 +main_simu = Ns3Module ('main-simulator', 'samples')
   1.648 +ns3.add (main_simu)
   1.649 +main_simu.set_executable ()
   1.650 +main_simu.add_dep ('simulator')
   1.651 +main_simu.add_source ('main-simulator.cc')
   1.652 +
   1.653 +main_packet = Ns3Module ('main-packet', 'samples')
   1.654 +ns3.add (main_packet)
   1.655 +main_packet.set_executable ()
   1.656 +main_packet.add_dep ('common')
   1.657 +main_packet.add_source ('main-packet.cc')
   1.658 +
   1.659 +
   1.660 +ns3.generate_dependencies ()
   1.661 +
   1.662 +
   1.663 +