Create workspace and project file for codelite
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 9 Mar 2009 10:18:17 +0000 (10:18 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 9 Mar 2009 10:18:17 +0000 (10:18 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2387 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/bertos_utils.py
wizard/cltemplates/bertos.project [new file with mode: 0644]
wizard/cltemplates/bertos.workspace [new file with mode: 0644]
wizard/const.py

index 1066f034e4c7f9a66aebdc9c709d410877f85697..3c7407bfbd846d2a7dc78ce4f3ed6d9030efe9e2 100644 (file)
@@ -67,6 +67,10 @@ def createBertosProject(projectInfo):
     makefile = open("mktemplates/template.mk", "r").read()
     makefile = mkGenerator(projectInfo, makefile)
     open(prjdir + "/" + os.path.basename(prjdir) + ".mk", "w").write(makefile)
+    workspace = codeliteWorkspaceGenerator(projectInfo)
+    open(directory + "/" + os.path.basename(prjdir) + ".workspace", "w").write(workspace)
+    project = codeliteProjectGenerator(projectInfo)
+    open(directory + "/" + os.path.basename(prjdir) + ".project", "w").write(project)
 
 def mkGenerator(projectInfo, makefile):
     """
@@ -108,6 +112,43 @@ def csrcGenerator(projectInfo):
                     files.append(path + "/" + filename)
     csrc = " \\\n\t".join(files) + " \\"
     return csrc
+
+def clFiles(fileDict, directory):
+    filelist = []
+    filelist.append("<VirtualDirectory Name=\"%s\">" %os.path.basename(directory))
+    for f in fileDict[directory]["files"]:
+        filelist.append("<File Name=\"%s\"/>" %os.path.join(directory, f))
+    for d in fileDict[directory]["dirs"]:
+        filelist += clFiles(fileDict, os.path.join(directory, d))
+    filelist.append("</VirtualDirectory>")
+    return filelist
+
+def findSources(path):
+    fileDict = {}
+    for root, dirs, files in os.walk(path):
+        if root.find("svn") == -1:
+            fileDict[root] = {"dirs": [], "files": []}
+            for dir in dirs:
+                if dir.find("svn") == -1:
+                    fileDict[root]["dirs"].append(dir)
+            for file in files:
+                if file.endswith(const.EXTENSION_FILTER):
+                    fileDict[root]["files"].append(file)
+    return fileDict
+
+def codeliteProjectGenerator(projectInfo):
+    template = open("cltemplates/bertos.project").read()
+    filelist = "\n".join(clFiles(findSources(projectInfo.info("PROJECT_PATH")), projectInfo.info("PROJECT_PATH")))
+    while template.find("$filelist") != -1:
+        template = template.replace("$filelist", filelist)
+    return template
+
+def codeliteWorkspaceGenerator(projectInfo):
+    template = open("cltemplates/bertos.workspace").read()
+    projectName = os.path.basename(projectInfo.info("PROJECT_PATH"))
+    while template.find("$project") != -1:
+        template = template.replace("$project", projectName)
+    return template
     
 def getSystemPath():
     path = os.environ["PATH"]
diff --git a/wizard/cltemplates/bertos.project b/wizard/cltemplates/bertos.project
new file mode 100644 (file)
index 0000000..a865056
--- /dev/null
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<CodeLite_Project Name="bertos" InternalType="">
+$filelist
+  <Description></Description>
+  <Dependencies/>
+  <Settings Type="Dynamic Library">
+    <Configuration Name="Debug" CompilerType="gnu g++" DebuggerType="GNU gdb debugger" Type="Dynamic Library">
+      <General OutputFile="" IntermediateDirectory="./Debug" Command="" CommandArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes"/>
+      <Compiler Required="yes" Options="-g">
+        <IncludePath Value="."/>
+      </Compiler>
+      <Linker Required="yes" Options=""/>
+      <Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
+        <PostConnectCommands></PostConnectCommands>
+        <StartupCommands></StartupCommands>
+      </Debugger>
+      <ResourceCompiler Required="no" Options=""/>
+      <PreBuild/>
+      <PostBuild/>
+      <CustomBuild Enabled="yes">
+        <CleanCommand>make clean</CleanCommand>
+        <BuildCommand>make</BuildCommand>
+        <PreprocessFileCommand></PreprocessFileCommand>
+        <SingleFileCommand></SingleFileCommand>
+        <MakefileGenerationCommand></MakefileGenerationCommand>
+        <ThirdPartyToolName>None</ThirdPartyToolName>
+        <WorkingDirectory>$(WorkspacePath)</WorkingDirectory>
+      </CustomBuild>
+      <AdditionalRules>
+        <CustomPostBuild></CustomPostBuild>
+        <CustomPreBuild></CustomPreBuild>
+      </AdditionalRules>
+    </Configuration>
+    <Configuration Name="Release" CompilerType="gnu g++" DebuggerType="GNU gdb debugger" Type="Dynamic Library">
+      <General OutputFile="" IntermediateDirectory="./Release" Command="" CommandArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes"/>
+      <Compiler Required="yes" Options="">
+        <IncludePath Value="."/>
+      </Compiler>
+      <Linker Required="yes" Options="-O2"/>
+      <Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
+        <PostConnectCommands></PostConnectCommands>
+        <StartupCommands></StartupCommands>
+      </Debugger>
+      <ResourceCompiler Required="no" Options=""/>
+      <PreBuild/>
+      <PostBuild/>
+      <CustomBuild Enabled="yes">
+        <CleanCommand>make clean</CleanCommand>
+        <BuildCommand>make</BuildCommand>
+        <PreprocessFileCommand></PreprocessFileCommand>
+        <SingleFileCommand></SingleFileCommand>
+        <MakefileGenerationCommand></MakefileGenerationCommand>
+        <ThirdPartyToolName>None</ThirdPartyToolName>
+        <WorkingDirectory>$(WorkspacePath)</WorkingDirectory>
+      </CustomBuild>
+      <AdditionalRules>
+        <CustomPostBuild></CustomPostBuild>
+        <CustomPreBuild></CustomPreBuild>
+      </AdditionalRules>
+    </Configuration>
+  </Settings>
+</CodeLite_Project>
diff --git a/wizard/cltemplates/bertos.workspace b/wizard/cltemplates/bertos.workspace
new file mode 100644 (file)
index 0000000..4b9d795
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<CodeLite_Workspace Name="$project" Database="./bertos.tags">
+  <Project Name="$project" Path="$project.project" Active="Yes"/>
+  <BuildMatrix>
+    <WorkspaceConfiguration Name="Debug" Selected="yes">
+      <Project Name="$project" ConfigName="Debug"/>
+    </WorkspaceConfiguration>
+    <WorkspaceConfiguration Name="Release" Selected="yes">
+      <Project Name="$project" ConfigName="Release"/>
+    </WorkspaceConfiguration>
+  </BuildMatrix>
+</CodeLite_Workspace>
index 8902d4bbbaf7aa775c4a477f3819fb68dd79fe7b..86115373713e24b62c9d2c42e5fd129430f13ac1 100644 (file)
@@ -29,7 +29,7 @@ CPU_DEF = {
     "CPU_DESC" : []
 }
 
-TOOLCHAIN_ITEMS = ["ld", "as"]
+TOOLCHAIN_ITEMS = ("ld", "as")
 
 CPU_DEFINITION = "*.cdef"
 
@@ -37,4 +37,12 @@ GCC_NAME = "*gcc*"
 
 MODULE_CONFIGURATION = "cfg_*.h"
 
-UI_LOCATION = "ui"
\ No newline at end of file
+UI_LOCATION = "ui"
+
+EXTENSION_FILTER = (
+    ".c",
+    ".cpp",
+    ".cxx",
+    ".h",
+    ".c++",
+)
\ No newline at end of file