summaryrefslogtreecommitdiff
path: root/dist/adodotnet/adapt_SQLite.Interop.2010.xq.in
blob: 05a00e6b02a388cf2c2240d15e2319e8652524a2 (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
(:
*  This template is only for changing SQLite.Interop/SQLite.Interop.vcproj
*  of ADO.NET
:)
declare variable $WINDOWS_PROJ_URL := '@BDB_PATH@/build_windows/VS10/db.vcxproj';
declare variable $WINDOWS_FILES := fn:document($WINDOWS_PROJ_URL)/Project/ItemGroup/ClCompile/parent::*;

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

let $root := Project
let $platformName := $root/ItemGroup/ProjectConfiguration[1]/Platform/string()
let $isWinCE := (fn:contains($platformName, "CEPC") or fn:contains($platformName, "ARM"))
let $fileList := $WINDOWS_FILES
let $cflags := if ($isWinCE) then (fn:replace($WINCE_FLAGS,'ARMV4','')) else ($WINDOWS_FLAGS)
(: VS2010 and VS2012 use ';' as separator :)
let $includes := if ($isWinCE) then (fn:replace($WINCE_INCLUDE, ',', ';')) else (
    fn:replace($WINDOWS_INCLUDE, ',', ';'))
let $inputLib := if ($isWinCE) then ('') else (fn:concat($WINDOWS_INPUT_LIB, ';advapi32.lib'))
return
(
  (: 
   Add BDB Files. We avoid doing this for WinCE projects, since xqilla can not
   handle it correctly.
  :)
  (
    let $newFileList := if ($isWinCE) then () else (local:getFileList($fileList))
    for $fileEntry in $root
      for $fileItem in $newFileList
        (:return $fileEntry:)
        return insert node $fileItem as last into $fileEntry
        (:return $fileItem:)
  ),

  (: Update PreprocessorDefinitions :)
  (
    for $node in $root//PreprocessorDefinitions[fn:contains(string(), 'WIN32;')]
    let $additionalFlags := 
      if (fn:contains($node/../../@Condition, 'Debug')) then (
        $DEBUG_ADDITIONAL_FLAGS
      ) else ()
    let $combinedFlags := fn:concat($node/string(), $cflags, $additionalFlags)
    return replace value of node $node with $combinedFlags
  ),

  (: Update/add AdditionalIncludeDirectories after PreprocessorDefinitions :)
  (
    for $node in $root//PreprocessorDefinitions[fn:contains(string(), 'WIN32;')]
    let $ClCompile := $node/parent::*
    let $AdditionalIncludeDirectories := $ClCompile/AdditionalIncludeDirectories
    return
      if (exists($AdditionalIncludeDirectories)) then (
        replace value of node $AdditionalIncludeDirectories
        with fn:concat($AdditionalIncludeDirectories/string(), ' ', $includes)
      ) else (
        insert node <AdditionalIncludeDirectories>{$includes}</AdditionalIncludeDirectories>
        into $ClCompile
      )
  ),

  (: Update AdditionalDependencies :)
  (
    for $node in $root//ItemDefinitionGroup/Link
    let $dependcies := $node/AdditionalDependencies
    let $group := $node/parent::*
    return
      if (fn:contains($group/@Condition, "Win32") or
          fn:contains($group/@Condition, "x64") or
          fn:contains($group/@Condition, "CEPC") or
          fn:contains($group/@Condition, "ARM")) then (
        if (exists($dependcies)) then (
          replace value of node $dependcies with fn:concat($inputLib, ';', $dependcies/string())
        ) else (
          insert node <AdditionalDependencies>{$inputLib}</AdditionalDependencies>
          into $node
        )
      ) else ()
  ),

  (: Update WarningLevel :)
  (
    for $node in $root//WarningLevel
    return replace value of node $node with "Level3"
  )
)