summaryrefslogtreecommitdiff
path: root/dist/adodotnet/adapt_SQLite.Interop.2008.xq.in
blob: 45e8210f7d12401c39882e4e303c472f36234711 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
(:
*  This template is for changing SQLite.Interop/SQLite.Interop.vcproj
*  of ADO.NET
:)
declare variable $WINDOWS_PROJ_URL := '@BDB_PATH@/build_windows/VS8/db.vcproj';
declare variable $WINDOWS_FILES := fn:document($WINDOWS_PROJ_URL)/VisualStudioProject/Files;
declare variable $WINCE_FILES := fn:document($WINCE_PROJ_URL)/VisualStudioProject/Files;

(: Copy File List and adapt it :)
declare function local:getFileList($fileList)
{
  copy $newFileList := $fileList
  modify (
    (: Remove build_windows files, e.g.: libdb.def and libdb.rc :)
    delete node $newFileList/File[fn:contains(@RelativePath, 'build_windows')],
    (: Remove useless lang files, e.g.: lang\cxx :)
    delete node $newFileList/File[fn:contains(@RelativePath, '..\lang')],
    (: Change file path :)
    for $filePath in $newFileList/File/@RelativePath
    return replace value of node $filePath
      with fn:replace($filePath, '..\\..\\src', $WIN_SRC)
  )
  return $newFileList
};

let $root := VisualStudioProject
let $isWinCE := fn:contains($root/@Name, '.CE.')
let $fileList := if ($isWinCE) then ($WINCE_FILES) else ($WINDOWS_FILES)
let $cflags := if ($isWinCE) then ($WINCE_FLAGS) else ($WINDOWS_FLAGS)
let $includes := if ($isWinCE) then ($WINCE_INCLUDE) else ($WINDOWS_INCLUDE)
let $inputLib := if ($isWinCE) then ('') else ($WINDOWS_INPUT_LIB)
return
(
  (: Add BDB Files :)
  (
    let $newFileList := local:getFileList($fileList)
    for $fileEntry in $root/Files/Filter[@Name="Source Files"]
      for $fileItem in $newFileList/File
        return insert node $fileItem as last into $fileEntry
  ),

  (: Update Configurations :)
  (
    for $config in $root/Configurations/Configuration
    let $VCCLCompilerTool := $config/Tool[@Name="VCCLCompilerTool"]
    let $VCLinkerTool := $config/Tool[@Name="VCLinkerTool"]
    let $VCManifestTool := $config/Tool[@Name="VCManifestTool"]
    let $PreprocessorDefinitions := $VCCLCompilerTool/@PreprocessorDefinitions
    let $AdditionalIncludeDirectories := $VCCLCompilerTool/@AdditionalIncludeDirectories
    let $WarningLevel := $VCCLCompilerTool/@WarningLevel
    let $AdditionalDependencies := $VCLinkerTool/@AdditionalDependencies
    let $iswincenode := (fn:contains($config/@Name, 'Pocket PC 2003 (ARMV4)') or
        fn:contains($config/@Name, 'Windows Mobile 5.0 Pocket PC SDK (ARMV4I)') or
        fn:contains($config/@Name, 'Windows Mobile 5.0 Smartphone SDK (ARMV4I)') or
        fn:contains($config/@Name, 'Smartphone 2003 (ARMV4)') or
        fn:contains($config/@Name, 'Windows Mobile 6 Professional SDK (ARMV4I)') or
        fn:contains($config/@Name, 'Windows Mobile 6.5.3 Professional DTK (ARMV4I)'))
    return
    (
      (: For Win32/x64/WinCE :)
      if (fn:contains($config/@Name, "Win32") or
          fn:contains($config/@Name, "x64") or $iswincenode) then (

        (: Update PreprocessorDefinitions :)
        (
          for $node in $PreprocessorDefinitions
          let $additionalFlags := 
            if (fn:contains($config/@Name, 'Debug')) then (
              $DEBUG_ADDITIONAL_FLAGS
            ) else ()
          let $combinedFlags := fn:concat($node/string(), $cflags, $additionalFlags)
          return replace value of node $node with $combinedFlags
        ), 

        (: Update AdditionalIncludeDirectories :)
        (
          if (fn:exists($AdditionalIncludeDirectories)) then (
             (: Update the attribute if exist:)
             replace value of node $AdditionalIncludeDirectories
             with fn:concat($AdditionalIncludeDirectories/string(), ' ', $includes)
           ) else (
           (: Insert the attribute otherwise :)
             insert node attribute AdditionalIncludeDirectories {$includes} 
             into $VCCLCompilerTool
          )
        ),

        (: Update AdditionalDependencies :)
        (
          if (fn:exists($AdditionalDependencies)) then (
             (: Update the attribute if exist:)
             replace value of node $AdditionalDependencies
             with fn:concat($AdditionalDependencies/string(), ' ', $inputLib)
           ) else if ($inputLib != '') then (
             (: Insert the attribute otherwise :)
             insert node attribute AdditionalDependencies {$inputLib} 
             into $VCLinkerTool
           ) else ()
        ),

        (: Update WarningLevel :)
        (
          for $node in $WarningLevel
          return
            replace value of node $node with '3'
        ), 

        (: Set LinkTool for Windows CE/Mobile:)
        (
          if ($iswincenode) then (
            for $node in $VCLinkerTool
            (: Update the attribute if exist. Otherwise, insert it:)
            return (
              ( (: Change SubSystem for Windows CE/Mobile :)
                let $value := $WINCE_SUB_SYSTEM
                let $attr := $node/@SubSystem
                return
                  if (fn:exists($attr)) then (
                    replace value of node $attr with $value
                  ) else (
                    insert node attribute SubSystem {$value} into $node
                  )
              )
            )
          ) else ()
        ),

        (: Set ComplierTool for Windows CE/Mobile:)
        (
          if ($iswincenode) then (
            for $node in $VCCLCompilerTool
            (: Update the attribute if exist. Otherwise, insert it:)
            return (
              ( (: Set RuntimeLibrary to Multi-threaded (/MT):)
                let $value := "0"
                let $attr := $node/@RuntimeLibrary
                return
                  if (fn:exists($attr)) then (
                    replace value of node $attr with $value
                  ) else (
                    insert node attribute RuntimeLibrary {$value} into $node
                  )
              ),
              ( (: Set WholeProgramOptimization to false :)
                let $value := "false"
                let $attr := $node/@WholeProgramOptimization
                return
                  if (fn:exists($attr)) then (
                    replace value of node $attr with $value
                  ) else (
                    insert node attribute WholeProgramOptimization {$value} into $node
                  )
              ),
              ( (: Set default Optimization from 3 to 2 :)
                let $value := "2"
                for $attr in $node/@Optimization[string() = "3"]
                return
                  replace value of node $attr with $value
              ),
              ( (: Favor Small Code (/Os) for Windows CE/Mobile :)
                let $value := "2"
                let $attr := $node/@FavorSizeOrSpeed
                return
                  if (fn:exists($attr)) then (
                    replace value of node $attr with $value
                  ) else (
                    insert node attribute FavorSizeOrSpeed {$value} into $node
                  )
              )
            )
          ) else ()
        )

      ) else ()
    )
  )
)