Пример #1
0
def generate_vs_project(env, source):
    projectFileDir = env.Dir('.').srcnode()
    print projectFileDir

    sources, includes = extensions.get_sources_and_includes(env, source[0])
    source_list = []
    include_list = []

    for src in sources | includes:
        item = projectFileDir.rel_path(src.srcnode())
        filename, file_extension = os.path.splitext(item)
        if file_extension.lower() in env["CPPSUFFIXES"]:
            if file_extension.lower() in [
                    ".c", ".cpp", ".s", ".cxx", ".cc", ".asm"
            ]:
                source_list.append(item)
            else:
                include_list.append(item)

    env.Append(CPPDEFINES='_ALLOW_KEYWORD_MACROS')
    env.Append(CPPDEFINES=['DEBUG', '_DEBUG'])
    env.Append(CCFLAGS='/MDd')
    env.Append(CCFLAGS=['/Zi', '/Fd${TARGET}.pdb'])
    env.Append(LINKFLAGS=['/DEBUG'])

    proj = env.MSVSProject(target=source[0],
                           srcs=source_list,
                           incs=include_list,
                           buildtarget=source[0],
                           variant='Debug')

    return proj
Пример #2
0
def generate_vs_project(env, source):
	projectFileDir = env.Dir('.').srcnode()
	print( projectFileDir)
	
	sources, includes = extensions.get_sources_and_includes(env, source[0])
	source_list = []
	include_list = []
	
	for src in sources | includes:
		item = projectFileDir.rel_path(src.srcnode())
		filename, file_extension = os.path.splitext(item)
		if file_extension.lower() in env["CPPSUFFIXES"]:
			if file_extension.lower() in [".c", ".cpp", ".s", ".cxx", ".cc", ".asm"]:
				source_list.append(item)
			else:
				include_list.append(item)
	
	env.Append(CPPDEFINES = '_ALLOW_KEYWORD_MACROS')
	env.Append(CPPDEFINES = ['DEBUG', '_DEBUG'])
	env.Append(CCFLAGS='/MDd')
	env.Append(CCFLAGS=['/Zi', '/Fd${TARGET}.pdb'])
	env.Append(LINKFLAGS = ['/DEBUG'])

	proj = env.MSVSProject(target = source[0],
					srcs = source_list,
					incs = include_list,
					buildtarget = source[0],
					variant = 'Debug')
	
	return proj
Пример #3
0
def get_lib_sources(target, source, env):
    lib_src_to_add = set()
    for src in source:
        sources, includes = extensions.get_sources_and_includes(env, src)
        for inc in includes:
            dir_name = os.path.dirname(inc.abspath)
            inc_file_name = os.path.splitext(os.path.basename(inc.abspath))[0]
            src_dir = os.path.join(dir_name, "src")
            if os.path.exists(src_dir):
                for lib_src_file in os.listdir(src_dir):
                    lib_src_base_name = os.path.splitext(lib_src_file)[0]
                    if lib_src_base_name.lower() == inc_file_name.lower():
                        lib_src_to_add.add(os.path.join(src_dir, lib_src_file))

    return lib_src_to_add
Пример #4
0
def create_project_target(env, currentSource, buildElement, projectFileDir,
                          buildTarget, compiler, project):
    targetElement = ET.SubElement(buildElement, "Target",
                                  {"title": buildTarget})
    sources, includes = extensions.get_sources_and_includes(env, currentSource)

    outPutRelative = projectFileDir.rel_path(currentSource)
    objectPath = os.path.dirname(outPutRelative)
    if objectPath == "":
        objectPath = "./"

    ET.SubElement(targetElement, "Option", {"output": outPutRelative})
    ET.SubElement(targetElement, "Option", {"object_output": objectPath})
    ET.SubElement(targetElement, "Option", {"type": "0"})
    ET.SubElement(targetElement, "Option", {"create_hex": "1"})
    ET.SubElement(targetElement, "Option", {"compiler": compiler})
    ET.SubElement(targetElement, "Option",
                  {"projectDeviceOptionsRelation": "0"})

    compilerElem = ET.SubElement(targetElement, "Compiler")
    for flag in env["CCFLAGS"]:
        ET.SubElement(compilerElem, "Add", option=flag)
    for define in env["CPPDEFINES"]:
        if isinstance(define, dict):
            for key in define:
                ET.SubElement(compilerElem,
                              "Add",
                              symbol="%s=%s" % (key, define[key]))
        else:
            ET.SubElement(compilerElem, "Add", symbol=define)

    for includePath in env["CPPPATH"]:
        includeDir = env.Dir(includePath).srcnode()
        includeDirRel = projectFileDir.rel_path(includeDir)
        ET.SubElement(compilerElem, "Add", directory=includeDirRel)

    cppElem = ET.SubElement(targetElement, "Cpp")
    for flag in env["CXXFLAGS"] + env["CCFLAGS"]:
        ET.SubElement(cppElem, "Add", option=flag)

    asmElem = ET.SubElement(targetElement, "Assembler")
    for flag in env["ASFLAGS"]:
        ET.SubElement(asmElem, "Add", option=flag)

    linkerScript = None
    linkElem = ET.SubElement(targetElement, "Linker")
    for flag in env["LINKFLAGS"]:
        flag = flag.rstrip('"').strip('"')
        if flag.startswith("-T"):
            linkerScript = flag
        ET.SubElement(linkElem, "Add", option=flag)

    deviceElem = ET.SubElement(targetElement, "Device")
    if 'DEVICE' in env:
        device = env["DEVICE"]
        if "cpu" in device:
            ET.SubElement(deviceElem, "Add", option="$device=" + device["cpu"])

    for src in sources | includes:
        item = projectFileDir.rel_path(src.srcnode())
        filename, file_extension = os.path.splitext(item)
        if file_extension.lower() in env["CPPSUFFIXES"]:
            #unit = ET.SubElement(targetElement, "Unit", { "filename":item})
            unit = ET.SubElement(project, "Unit", {"filename": item})
            if file_extension.lower() in [".c", ".cpp", ".s", ".cxx", ".cc"]:
                ET.SubElement(unit, "Option", {"compilerVar": "CC"})

    add_build_commands(targetElement)
Пример #5
0
def create_project_target(env, currentSource, buildElement, projectFileDir, buildTarget, compiler, project):
	target = buildTarget
	if isinstance(buildTarget, dict):
		target = buildTarget[currentSource]
		
	targetElement = ET.SubElement(buildElement, "Target", {"title":target})
	sources, includes = extensions.get_sources_and_includes(env, currentSource)
	
	outPutRelative = projectFileDir.rel_path(currentSource)
	objectPath = os.path.dirname(outPutRelative)
	if objectPath == "":
		objectPath = "./"
		
	ET.SubElement(targetElement, "Option", {"output":outPutRelative})
	ET.SubElement(targetElement, "Option", {"object_output": objectPath})
	ET.SubElement(targetElement, "Option", {"type":"0" })
	ET.SubElement(targetElement, "Option", {"create_hex":"1"})
	ET.SubElement(targetElement, "Option", {"compiler":compiler })
	ET.SubElement(targetElement, "Option", {"projectDeviceOptionsRelation":"0"})
	
	compilerElem = ET.SubElement(targetElement, "Compiler")
	for flag in env["CCFLAGS"]:
		ET.SubElement(compilerElem, "Add", option=flag)
	for define in env["CPPDEFINES"]:
		if isinstance(define, dict):
			for key in define:
				ET.SubElement(compilerElem, "Add", symbol="%s=%s" %(key, define[key]))
		else:
			ET.SubElement(compilerElem, "Add", symbol=define)
	
	for includePath in env["CPPPATH"]:
		includeDir = env.Dir(includePath).srcnode()
		includeDirRel =  projectFileDir.rel_path(includeDir)
		ET.SubElement(compilerElem, "Add", directory=includeDirRel)
	
	cppElem = ET.SubElement(targetElement, "Cpp")
	for flag in env["CXXFLAGS"] + env["CCFLAGS"]:
		ET.SubElement(cppElem, "Add", option=flag)
		
	asmElem = ET.SubElement(targetElement, "Assembler")
	for flag in env["ASFLAGS"]:
		ET.SubElement(asmElem, "Add", option=flag)
		
	linkerScript = None
	linkElem = ET.SubElement(targetElement, "Linker")
	for flag in env["LINKFLAGS"]:
		flag = flag.rstrip('"').strip('"')
		if flag.startswith("-T"):
			linkerScript = flag
		ET.SubElement(linkElem, "Add", option=flag)
	
	deviceElem = ET.SubElement(targetElement, "Device")
	if 'DEVICE' in env:
		device = env["DEVICE"]
		if "cpu" in device:
			ET.SubElement(deviceElem, "Add", option="$device=" + device["cpu"])

	for src in sources | includes:
		item = projectFileDir.rel_path(src.srcnode())
		filename, file_extension = os.path.splitext(item)
		if file_extension.lower() in env["CPPSUFFIXES"]:
			#unit = ET.SubElement(targetElement, "Unit", { "filename":item})
			unit = ET.SubElement(project, "Unit", { "filename":item})
			if file_extension.lower() in [".c", ".cpp", ".s", ".cxx", ".cc"]:
				ET.SubElement(unit, "Option", { "compilerVar":"CC"})
	
	add_build_commands(targetElement)