Commit f01594fb authored by John van Groningen's avatar John van Groningen

use same separator characters in project and application relative paths in...

use same separator characters in project and application relative paths in project files on all platforms,
add list of other paths containing project modules

parent 511fe838
......@@ -2,7 +2,7 @@ implementation module PmFiles
// File I/O routines for the project.
import StdArray, StdFunc, StdInt
import StdArray, StdFunc, StdInt, StdChar, StdBool, StdStrictLists
import UtilNewlinesFile, UtilOptions, UtilStrictLists
import PmProject
import UtilDate
......@@ -45,7 +45,6 @@ EmptyDynamicInfo =
, dyn_paths = Nil
}
:: UndefSymbol =
{ symbol_name :: !String
, path :: !String
......@@ -74,10 +73,25 @@ code_gen_option = GroupedOption "CodeGen" CodeGenOptionsTable (\a->a.pg_codeg
application_option = GroupedOption "Application" ApplicationOptionsTable (\a->a.pg_application) (\v a->{a & pg_application=v})
link_option = GroupedOption "Link" LinkOptionsTable (\a->a.pg_link) (\v a->{a & pg_link=v})
paths_option = ListOption "Paths" PathName "" (\a->a.pg_projectPaths) (\v a->{a & pg_projectPaths=v})
otherpaths_option = ListOption "OtherPaths" PathName "" (\a->module_paths_not_in_project a.pg_projectPaths a.pg_otherModules) (\v a->a)
static_option = GroupedOption "Static" StaticLibsInfoTable (\a->a.pg_staticLibInfo) (\v a->{a & pg_staticLibInfo=v})
precompile_option = SimpleOption "Precompile" (\a->unwrap a.pg_precompile)(\v a->{a & pg_precompile = wrap v})
postlink_option = SimpleOption "Postlink" (\a->unwrap a.pg_postlink) (\v a->{a & pg_postlink = wrap v})
module_paths_not_in_project :: [!Pathname!] [!ModInfoAndName!]-> [!Pathname!]
module_paths_not_in_project project_paths [!!]
= [!!]
module_paths_not_in_project project_paths [!{info={dir}}:modules!]
# module_dirs = [!dir:get_module_dirs dir modules!];
= RemoveMembers module_dirs project_paths;
where
get_module_dirs previous_dir [!{info={dir}}:modules!]
| dir==previous_dir
= get_module_dirs previous_dir modules;
= [!dir:get_module_dirs dir modules!];
get_module_dirs _ [!!]
= [!!]
// Making Precompile & Postlink 'List' options is probably prettier...
unwrap Nothing = ""
unwrap (Just s) = s
......@@ -94,6 +108,7 @@ ProjectGlobalOptionsTable =
, application_option
, link_option
, paths_option
, otherpaths_option
, static_option
, precompile_option
, postlink_option
......@@ -119,8 +134,46 @@ where
fromString _
= True
ProjectDirSeparator:=='*'
convert_path_to_project_file_path :: !{#Char} -> {#Char}
convert_path_to_project_file_path path
= get_separator_and_convert_path path
where
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
= path
where
replace_prefix separator path
| separator==ProjectDirSeparator
= path
= replace_character_by_ProjectDirSeparator_in_string separator path
replace_character_by_ProjectDirSeparator_in_string :: !Char !{#Char} -> {#Char}
replace_character_by_ProjectDirSeparator_in_string old_c string
= {if (c==old_c) ProjectDirSeparator 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
name_option = SimpleOption "Name" (\a->a.name) (\v a->{a & name=v})
dir_option = SimpleWithStringConversionOption convert_path_separators "Dir" (\a->a.info.dir) (\v a->{a & info.dir=v})
dir_option = SimpleWithStringConversionsOption convert_path_separators convert_path_to_project_file_path "Dir" (\a->a.info.dir) (\v a->{a & info.dir=v})
compiler_option = GroupedOption "Compiler" CompilerOptionsTable (\a->a.info.compilerOptions)(\v a->{a & info.compilerOptions=v})
needed_obj_files_option = ListOption "NeededObjFiles" ObjectFile "" (\a->a.info.abcLinkInfo.linkObjFileNames)
(\v a->{a & info.abcLinkInfo.linkObjFileNames=v})
......@@ -282,7 +335,7 @@ ApplicationOptionsTable =
PathName :: OptionsTableEntry {#Char}
PathName
= SimpleWithStringConversionOption convert_path_separators "Path" id const
= SimpleWithStringConversionsOption convert_path_separators convert_path_to_project_file_path "Path" id const
ModuleName :: OptionsTableEntry {#Char}
ModuleName
......
......@@ -23,12 +23,14 @@ GetOptions :: !(OptionsTable a) ![Option] !a -> a
Simple :: Conversions a | toString, fromString a
SimpleWithStringConversion :: ({#Char} -> {#Char}) -> (Conversions a) | toString, fromString a
SimpleWithStringConversions :: ({#Char} -> {#Char}) ({#Char} -> {#Char}) -> Conversions a | toString, fromString a
List :: (OptionsTableEntry a) a -> Conversions (List a)
OptionalGroup :: (OptionsTable a) (a->Bool) -> Conversions 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}
SimpleWithStringConversionsOption cf ct l g p :== {labelName = l, conversions = SimpleWithStringConversions cf ct, get = g, put = p}
GroupedOption l s g p :== {labelName = l, conversions = Group s, get = g, put = p}
OptionalGroupedOption l e s g p :== {labelName = l, conversions = OptionalGroup s e, get = g, put = p}
ListOption l s d g p :== {labelName = l, conversions = List s d, get = g, put = p}
......
......@@ -69,6 +69,20 @@ SimpleWithStringConversion convert_string =
fromValue (Just {value}) subOptionsTable list
= fromString (convert_string value)
SimpleWithStringConversions :: ({#Char} -> {#Char}) ({#Char} -> {#Char}) -> Conversions a | toString, fromString a
SimpleWithStringConversions convert_string_from convert_string_to =
{
toValue
= \value -> ((Just {value = convert_string_to (toString value)}), []),
fromValue
= fromValue
}
where
fromValue Nothing _ value
= value
fromValue (Just {value}) subOptionsTable list
= fromString (convert_string_from 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