Fix relative/absolute path issuew
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 27 Apr 2010 14:05:51 +0000 (14:05 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 27 Apr 2010 14:05:51 +0000 (14:05 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3546 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/bertos_utils.py
wizard/mktemplates/template.mk

index 493ffbe21c64bc8653994a1b1d8fc69dda68e620..37e80d3d7bfe695bfe454be2ae1755c23606755f 100644 (file)
@@ -40,6 +40,7 @@ import re
 import shutil
 # Use custom copytree function
 import copytree
+import relpath
 import pickle
 
 import const
@@ -119,7 +120,8 @@ def projectFileGenerator(project_info):
         # project_data["BERTOS_PATH"] = project_info.info("BERTOS_PATH")
         project_data["BERTOS_PATH"] = directory
     project_data["PROJECT_NAME"] = project_info.info("PROJECT_NAME", os.path.basename(directory))
-    project_data["PROJECT_SRC_PATH"] = project_info.info("PROJECT_SRC_PATH")
+    project_src_relpath = relpath.relpath(project_info.info("PROJECT_SRC_PATH"), directory)
+    project_data["PROJECT_SRC_PATH"] = project_src_relpath
     project_data["TOOLCHAIN"] = project_info.info("TOOLCHAIN")
     project_data["CPU_NAME"] = project_info.info("CPU_NAME")
     project_data["SELECTED_FREQ"] = project_info.info("SELECTED_FREQ")
@@ -144,8 +146,8 @@ def userMkGenerator(project_info):
     # Deadly performances loss was here :(
     mk_data = {}
     mk_data["$pname"] = os.path.basename(project_info.info("PROJECT_PATH"))
-    mk_data["$ppath"] = os.path.basename(project_info.info("PROJECT_SRC_PATH"))
-    mk_data["$main"] = os.path.basename(project_info.info("PROJECT_PATH")) + "/main.c"
+    mk_data["$ppath"] = relpath.relpath(project_info.info("PROJECT_SRC_PATH"), project_info.info("PROJECT_PATH"))
+    mk_data["$main"] = os.path.join("$(%s_PROJECT_SRC_PATH)" %project_info.info("PROJECT_NAME"), "main.c")
     for key in mk_data:
         while makefile.find(key) != -1:
             makefile = makefile.replace(key, mk_data[key])
@@ -159,7 +161,7 @@ def mkGenerator(project_info):
     destination = os.path.join(project_info.prjdir, os.path.basename(project_info.prjdir) + ".mk")
     mk_data = {}
     mk_data["$pname"] = project_info.info("PROJECT_NAME")
-    mk_data["$ppath"] = os.path.basename(project_info.info("PROJECT_SRC_PATH"))
+    mk_data["$ppath"] = relpath.relpath(project_info.info("PROJECT_SRC_PATH"), project_info.info("PROJECT_PATH"))
     mk_data["$cpuclockfreq"] = project_info.info("SELECTED_FREQ")
     cpu_mk_parameters = []
     for key, value in project_info.info("CPU_INFOS").items():
@@ -169,7 +171,6 @@ def mkGenerator(project_info):
     mk_data["$csrc"], mk_data["$pcsrc"], mk_data["$cppasrc"], mk_data["$cxxsrc"], mk_data["$asrc"], mk_data["$constants"] = csrcGenerator(project_info)
     mk_data["$prefix"] = replaceSeparators(project_info.info("TOOLCHAIN")["path"].split("gcc")[0])
     mk_data["$suffix"] = replaceSeparators(project_info.info("TOOLCHAIN")["path"].split("gcc")[1])
-    mk_data["$main"] = os.path.basename(project_info.info("PROJECT_PATH")) + "/main.c"
     for key in mk_data:
         while makefile.find(key) != -1:
             makefile = makefile.replace(key, mk_data[key])
index 3fff12943b8ec93a70df040a0d530e647baffa35..5b866cd9017a713a529650fd8c4e0075ec57ad1b 100644 (file)
@@ -13,6 +13,8 @@ $pname_PREFIX = "$prefix"
 
 $pname_SUFFIX = "$suffix"
 
+$pname_PROJECT_SRC_PATH = "$ppath"
+
 # Files automatically generated by the wizard. DO NOT EDIT, USE $pname_USER_CSRC INSTEAD!
 $pname_WIZARD_CSRC = \
        $csrc