Commit 66f28a3b authored by John van Groningen's avatar John van Groningen

convert separators and .exe extension of paths from different

operating system in project file for relative paths
parent d259e79b
......@@ -179,7 +179,7 @@ where
s2m "Pers" = CompilePers
s2m n = CompileAsync (toInt n)
PathOption = SimpleOption "Path" id const
PathOption = SimpleWithStringConversionOption convert_path_separators "Path" id const
t_StdEnv20 :: Target
t_StdEnv20 =
......
......@@ -6,6 +6,7 @@ import StdArray, StdFunc, StdInt
import UtilNewlinesFile, UtilOptions, UtilStrictLists
import PmProject
import UtilDate
from PmPath import convert_path_separators,convert_exec_path_separators_and_extension
ProjectFileVersion :== "1.4"
......@@ -98,7 +99,7 @@ ProjectGlobalOptionsTable :: OptionsTable ProjectGlobalOptions
ProjectGlobalOptionsTable =
{ SimpleOption "Built" (\a->a.pg_built) (\v a->{a & pg_built=v})
, SimpleOption "Target" (\a->a.pg_target) (\v a->{a & pg_target=v})
, SimpleOption "Exec" (\a->a.pg_execpath) (\v a->{a & pg_execpath=v})
, SimpleWithStringConversionOption convert_exec_path_separators_and_extension "Exec" (\a->a.pg_execpath) (\v a->{a & pg_execpath=v})
, GroupedOption "CodeGen" CodeGenOptionsTable (\a->a.pg_codegen) (\v a->{a & pg_codegen=v})
, GroupedOption "Application" ApplicationOptionsTable (\a->a.pg_application) (\v a->{a & pg_application=v})
// , GroupedOption "Project" ProjectOptionsTable (\a->a.pg_projectOptions) (\v a->{a & pg_projectOptions=v})
......@@ -127,7 +128,7 @@ where
ModInfoAndNameTable :: OptionsTable ModInfoAndName
ModInfoAndNameTable =
{ SimpleOption "Name" (\a->a.name) (\v a->{a & name=v})
, SimpleOption "Dir" (\a->a.info.dir) (\v a->{a & info.dir=v})
, SimpleWithStringConversionOption convert_path_separators "Dir" (\a->a.info.dir) (\v a->{a & info.dir=v})
, GroupedOption "Compiler" CompilerOptionsTable (\a->a.info.compilerOptions)(\v a->{a & info.compilerOptions=v})
, GroupedOption "Dcl" EditWdOptionsTable (\a->a.info.defeo) (\v a->{a & info.defeo=v})
, SimpleOption "DclOpen" (\a->a.info.defopen) (\v a->{a & info.defopen=v})
......@@ -245,9 +246,10 @@ ProjectOptionsTable =
SimpleOption "Verbose" (\a->a.ProjectOptions.verbose) (\v a->{ProjectOptions | a & verbose=v})
}
*/
PathName :: OptionsTableEntry {#Char}
PathName
= SimpleOption "Path" id const
= SimpleWithStringConversionOption convert_path_separators "Path" id const
ModuleName :: OptionsTableEntry {#Char}
ModuleName
......
......@@ -32,6 +32,9 @@ fulPath :: !Pathname !Pathname !Pathname -> Pathname // appPath prjPath symPat
symPaths :: !Pathname !Pathname !(List Pathname) -> List Pathname
fulPaths :: !Pathname !Pathname !(List Pathname) -> List Pathname
convert_path_separators :: !Pathname -> Pathname
convert_exec_path_separators_and_extension :: !Pathname -> Pathname
symAppPath :: !Pathname !Pathname -> Pathname
fulAppPath :: !Pathname !Pathname -> Pathname
symAppPaths :: !Pathname !(List Pathname) -> List Pathname
......
......@@ -191,6 +191,61 @@ fulPath ap pp l
// if not put it in the project directory...
= MakeFullPathname pp l
get_separator_and_convert_path :: !Pathname -> (!Char,!Pathname)
get_separator_and_convert_path path
# prefix="{Project}"
# prefix_size=size prefix
# i=first_not_equal_character_index prefix path
| i==prefix_size && size path>prefix_size
= replace_prefix path.[prefix_size] path
# prefix="{Application}"
# prefix_size=size prefix
# i=first_not_equal_character_index prefix path
| i==prefix_size && size path>prefix_size
= replace_prefix path.[prefix_size] path
= (dirseparator,path)
where
replace_prefix separator path
| separator==dirseparator
= (separator,path)
= (separator,replace_character_in_string separator dirseparator path)
replace_character_in_string :: !Char !Char !{#Char} -> {#Char}
replace_character_in_string old_c new_c string
= {if (c==old_c) new_c c \\ c<-:string}
first_not_equal_character_index s1 s2
#! max_index=if (size s1<=size s2) (size s1) (size s2)
= first_not_equal_character_index 0 max_index s1 s2
where
first_not_equal_character_index :: !Int !Int !{#Char} !{#Char} -> Int
first_not_equal_character_index i n s1 s2
| i<n && s1.[i]==s2.[i]
= first_not_equal_character_index (i+1) n s1 s2
= i
convert_path_separators :: !Pathname -> Pathname
convert_path_separators path
# (separator,path) = get_separator_and_convert_path path
= path
convert_exec_path_separators_and_extension :: !Pathname -> Pathname
convert_exec_path_separators_and_extension path
# (separator,path) = get_separator_and_convert_path path
| separator==dirseparator
= path
| dirseparator=='\\'
= path+++".exe"
| separator=='\\'
# l=size path
| l>4 && path.[l-4]=='\\'
&& (path.[l-3]=='e' || path.[l-3]=='e')
&& (path.[l-2]=='x' || path.[l-2]=='x')
&& (path.[l-1]=='e' || path.[l-1]=='e')
= path % (0,l-4)
= path
= path
symPaths :: !Pathname !Pathname !(List Pathname) -> List Pathname
symPaths ap pp l = Map (symPath ap pp) l
......
......@@ -372,7 +372,7 @@ ReadTable options
# prefs = GetOptions PrefsOptionsTable options emptyPrefs
= prefs
PathOption =SimpleOption "Path" id const
PathOption = SimpleWithStringConversionOption convert_path_separators "Path" id const
PrefsOptionsTable :: OptionsTable Prefs
PrefsOptionsTable =
......
......@@ -22,10 +22,12 @@ PutOptions :: !(OptionsTable a) a -> [Option]
GetOptions :: !(OptionsTable a) ![Option] !a -> a
Simple :: Conversions a | toString, fromString a
SimpleWithStringConversion :: ({#Char} -> {#Char}) -> (Conversions a) | toString, fromString a
List :: (OptionsTableEntry a) a -> Conversions (List a)
Group :: (OptionsTable a) -> Conversions a
SimpleOption l g p :== {labelName = l, conversions = Simple, get = g, put = p}
SimpleWithStringConversionOption c l g p :== {labelName = l, conversions = SimpleWithStringConversion c, get = g, put = p}
GroupedOption l s g p :== {labelName = l, conversions = Group s, get = g, put = p}
ListOption l s d g p :== {labelName = l, conversions = List s d, get = g, put = p}
......
......@@ -55,6 +55,20 @@ Simple =
fromValue (Just {value}) subOptionsTable list
= fromString value
SimpleWithStringConversion :: ({#Char} -> {#Char}) -> (Conversions a) | toString, fromString a
SimpleWithStringConversion convert_string =
{
toValue
= \value -> ((Just {value = toString value}), []),
fromValue
= fromValue
}
where
fromValue Nothing _ value
= value
fromValue (Just {value}) subOptionsTable list
= fromString (convert_string value)
Group :: (OptionsTable a) -> Conversions a
Group subOptionTable =
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment