summaryrefslogtreecommitdiffstats
path: root/cpp/sca/runtime/extensions/python/build.xml
blob: 59598dada56921672268be0381e2aad8d1b5aea5 (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
179
180
181
182
183
184
<?xml version="1.0" encoding="UTF-8"?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
     http://www.apache.org/licenses/LICENSE-2.0
     
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
-->
<project name="TuscanyScaNative_extension_python" default="all" basedir="../../..">

  <import file="${basedir}/antscripts/system.xml"/>
  <import file="${basedir}/antscripts/compile-targets.xml"/>

  <!--
    Notice that the basedir for this project is set to the TuscanySCA root dir
    This makes path setting in system.xml much simpler, but we'll just have to
    set a property here to this directory.
  -->
  <property name="this.dir"              location="${basedir}/runtime/extensions/python"/>
  <property name="this.src.dir"          location="${basedir}/runtime/extensions/python/src"/>
  <property name="python.xsd.dir"        location="${this.dir}/xsd"/>
  <property name="python.core.dir"       location="${this.src.dir}/tuscany/sca/python"/>
  <property name="python.model.dir"      location="${this.src.dir}/tuscany/sca/python/model"/>
  <property name="lib.dir"               location="${this.src.dir}/.libs"/>
  <property name="python.extension.lib"  value="tuscany_sca_python"/>
  <property name="python.extension.install.dir"
            location="${tuscanySCA.install.dir}/extensions/python"/>

  <!--
    All the cpp files per subdirectory
    New classes should be added to these properties
  -->
  <property
    name="python.core.cpp.files"
    value="PythonExtension.cpp
           PythonImplementationExtension.cpp
           PythonInterfaceExtension.cpp
           PythonServiceProxy.cpp
           PythonServiceWrapper.cpp
           sca_module.cpp"/>

  <property
    name="python.model.cpp.files"
    value="PythonImplementation.cpp
           PythonInterface.cpp
           PythonReferenceBinding.cpp
           PythonServiceBinding.cpp"/>

  <property
    name="python.xsd.files"
    value="sca-implementation-python.xsd
           sca-interface-python.xsd"/>

  <!--
    Public targets
  -->
  <target name="all"
      description="Compile, link, and install all TuscanyScaNative python extension source code">
    <antcall target="compile"/>
    <antcall target="link"/>
    <antcall target="install"/>
  </target>

  <target name="build" description="Compile and link all TuscanyScaNative python extension source code">
    <antcall target="compile"/>
    <antcall target="link"/>
  </target>

  <target name="compile" description="Compile all TuscanyScaNative python extension source code">
    <antcall target="compile.python.core"/>
    <antcall target="compile.python.model"/>
  </target>

  <target name="link" depends="check.python" if="enable_python"
          description="Link all TuscanyScaNative python extension source code">
    <cpp-link
        outfile="${python.extension.lib}"
        outdir="${lib.dir}"
        indir="${lib.dir}"
        infiles="*${object.ext}">
      <custom-ld-elements>
        <libset dir="${python.lib.dir}" libs="${python.version}"/>
      </custom-ld-elements>
    </cpp-link>
  </target>

  <target name="install" description="Install TuscanyScaNative python extension libraries and headers">
    <antcall target="install.python.core"/>
    <antcall target="install.python.xsd"/>
  </target>

  <target name="clean" description="Clean all TuscanyScaNative python extension compiled source code">
    <antcall target="clean.python.core"/>
    <antcall target="clean.python.xsd"/>
  </target>

  <!--
    Internal targets
    They can still be called, they're just not described, so wont show up in "ant -p"
  -->

    <!-- compile -->

  <target name="compile.python.core" depends="check.python" if="enable_python">
    <cpp-compile
        srcdir="${python.core.dir}"
        objdir="${lib.dir}"
        infiles="${python.core.cpp.files}">
      <custom-cc-elements>
        <includepath path="${this.src.dir}"/>
        <includepath path="${python.include.dir}"/>
        <defineset if="windows" define="TUSCANY_SCA_PYTHON_EXPORTS"/>
      </custom-cc-elements>
    </cpp-compile>
  </target>

  <target name="compile.python.model" depends="check.python" if="enable_python">
    <cpp-compile
        srcdir="${python.model.dir}"
        objdir="${lib.dir}"
        infiles="${python.model.cpp.files}">
      <custom-cc-elements>
        <includepath path="${this.src.dir}"/>
        <includepath path="${python.include.dir}"/>
        <defineset if="windows" define="TUSCANY_SCA_PYTHON_EXPORTS"/>
      </custom-cc-elements>
    </cpp-compile>
  </target>

    <!-- install -->

  <target name="install.python.core" depends="check.python" if="enable_python">
    <cpp-install-lib
        lib="${python.extension.lib}"
        srcdir="${lib.dir}"
        destrootdir="${python.extension.install.dir}"/>
    <cpp-symlink
        linkdir="${python.extension.install.dir}/lib"
        link="${lib.prefix}${python.extension.lib}${lib.ext}"
        resource="${lib.prefix}${python.extension.lib}${lib.ext}${tuscanySCA.library.version}"/>
    <cpp-symlink
        linkdir="${python.extension.install.dir}/module"
        link="${lib.prefix}${python.extension.lib}${lib.ext}"
        resourcedir="${python.extension.install.dir}/lib"
        resource="${lib.prefix}${python.extension.lib}${lib.ext}"/>
  </target>

  <target name="install.python.xsd" depends="check.python" if="enable_python">
    <cpp-install-files
        files="${python.xsd.files}"
        srcdir="${python.xsd.dir}"
        destdir="${python.extension.install.dir}/xsd"/>
  </target>

    <!-- clean -->

  <target name="clean.python.core">
    <cpp-clean-lib
    	lib="${python.extension.lib}"
        librootdir="${python.extension.install.dir}"/>
    <cpp-clean-files
        dir="${python.extension.install.dir}/module"
        rmdir="true"/>
    <delete dir="${lib.dir}" quiet="true"/>
  </target>

  <target name="clean.python.xsd">
    <cpp-clean-files
        dir="${python.extension.install.dir}/xsd"
        rmdir="true"/>
  </target>

</project>