aboutsummaryrefslogtreecommitdiffstats
path: root/build/conf/swig.conf
blob: 27819f10a8917090fe9441fdd6875d701f9b3f05 (plain) (blame)
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
_SWIG_TOOL=${tool:"contrib/tools/swig"}

_SWIG_LIBRARY=contrib/tools/swig/Lib
_SWIG_LIBRARY_ABS=$ARCADIA_ROOT/$_SWIG_LIBRARY

SWIG_IMPLICIT_INCLUDES = swig.swg go.swg java.swg perl5.swg python.swg

_SWIG_CMD=$_SWIG_PYTHON_CMD
_SWIG_SEM_TO_MODULE_LINK=${output;hide;suf=.o:SRC}

_SWIG_PYTHON_CMD=${_SWIG_TOOL} -module ${REALPRJNAME} -cpperraswarn -c++ -python -interface ${MODULE_PREFIX}${REALPRJNAME} -o ${output;noext;main;suf=_wrap.swg.cpp:SRC} ${output;noauto;add_to_outs;hide;tobindir;suf=.py:REALPRJNAME} -outdir ${BINDIR} ${pre=-I:_SWIG__INCLUDE} ${input:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}

_SWIG_PERL_CMD=${_SWIG_TOOL} -c++ -cpperraswarn -module ${REALPRJNAME} -shadow -perl -o ${output;noext;main;suf=_wrap.swg.cpp:SRC} ${output;noauto;add_to_outs;hide;tobindir;suf=.pm:REALPRJNAME} -outdir ${ARCADIA_BUILD_ROOT}/${MODDIR} ${pre=-I:_SWIG__INCLUDE} ${input:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}

_SWIG_JNI_CPP_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/jni_swig.py"} --swig ${_SWIG_TOOL} --default-module ${nopath;noext:SRC} --src ${input:SRC} --out-header ${output;main;noext;suf=_wrap.swg.h:SRC} --package-by-file ru/yandex/${input;rootrel:SRC} -- ${pre=-I:_SWIG__INCLUDE} -o ${output;noext;suf=_wrap.swg.cpp:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
_SWIG_JNI_JAVA_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/jni_swig.py"} --swig ${_SWIG_TOOL} --default-module ${nopath;noext:SRC} --src ${input:SRC} --package-by-file ru/yandex/${input;rootrel:SRC} --jsrc ${output;main;suf=.jsrc:SRC} -- ${pre=-I:_SWIG__INCLUDE} -o ${BINDIR}/unused.cpp ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
_SWIG_JNI_CMD=$YMAKE_PYTHON3 ${input:"build/scripts/jni_swig.py"} --swig ${_SWIG_TOOL} --default-module ${nopath;noext:SRC} --src ${input:SRC} --out-header ${output;main;noext;suf=_wrap.swg.h:SRC} --package-by-file ru/yandex/${input;rootrel:SRC} --jsrc ${output;suf=.jsrc:SRC} -- ${pre=-I:_SWIG__INCLUDE} -o ${output;noext;suf=_wrap.swg.cpp:SRC} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
_SWIG_JNI_PEERDIR=contrib/libs/jdk

REAL_SWIG_DLL_JAR_CMD=$GENERATE_VCS_JAVA_INFO_NODEP && ${cwd:ARCADIA_BUILD_ROOT} $YMAKE_PYTHON ${input:"build/scripts/build_dll_and_java.py"} $JAVA_SWIG_DELIM $REAL_LINK_DYN_LIB $JAVA_SWIG_DELIM $COMPILE_JAVA $JAVA_SWIG_DELIM $AUTO_INPUT $JAVA_SWIG_DELIM $TARGET $JAVA_SWIG_DELIM ${output;suf=.jar:REALPRJNAME} $JAVA_SWIG_DELIM ${output;suf=-sources.jar:REALPRJNAME} $JAVA_SWIG_DELIM $ARCADIA_BUILD_ROOT $ARCADIA_ROOT

when ($USE_SYSTEM_JDK == "yes" || $OS_ANDROID == "yes") {
    _SWIG_JNI_PEERDIR=
}

# tag:python-processing tag:internal
### @usage: _SWIG_PYTHON_CPP(Src, DstSubPrefix) # internal
###
### Run swig on Src to produce DstSubPrefix.py and DstSubPrefix_swg.cpp that
### provides DstSubPrefix_swg python module.
macro _SWIG_PYTHON_CPP(Src, DstSubPrefix) {
    .CMD=$_SWIG_TOOL -I$ARCADIA_BUILD_ROOT -I$ARCADIA_ROOT -I$_SWIG_LIBRARY_ABS/python -I$_SWIG_LIBRARY_ABS -c++ -python -module ${nopath:DstSubPrefix} -interface ${nopath;suf=_swg:DstSubPrefix} -o ${output;suf=.swg.cpp:DstSubPrefix} ${input:Src} ${output;noauto;hide;suf=.py:DstSubPrefix} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
    .PEERDIR=contrib/tools/swig/Lib/python
}

# tag:python-processing tag:internal
### @usage: _SWIG_PYTHON_C(Src, DstSubPrefix) # internal
###
### Like _SWIG_PYTHON_CPP but generate DstSubPrefix_swg.c.
macro _SWIG_PYTHON_C(Src, DstSubPrefix) {
    .CMD=$_SWIG_TOOL -I$ARCADIA_BUILD_ROOT -I$ARCADIA_ROOT -I$_SWIG_LIBRARY_ABS/python -I$_SWIG_LIBRARY_ABS -python -module ${nopath:DstSubPrefix} -interface ${nopath;suf=_swg:DstSubPrefix} -o ${output;suf=.swg.c:DstSubPrefix} ${input:Src} ${output;noauto;hide;suf=.py:DstSubPrefix} ${kv;hide:"p SW"} ${kv;hide:"pc yellow"}
    .PEERDIR=contrib/tools/swig/Lib/python
}

_EXPLICIT_SWIG_JAVA_SOURCES=
_EXPLICIT_SWIG_IFACE_SOURCES=
macro _EXPORT_JAVA_BINDINGS(JavaSrcs...) {
    SET_APPEND(_EXPLICIT_SWIG_JAVA_SOURCES ${input:JavaSrcs})
    .SEM=find_package SWIG COMPONENTS java && find_package Java && include UseSWIG && include UseJava ${input;hide:JavaSrcs} ${output;hide;pre=$_HASH_HELPER($Args):".o"}
}
macro _EXPORT_SWIG_SOURCES(SwigSrcs...) {
    SET_APPEND(_EXPLICIT_SWIG_IFACE_SOURCES ${input:SwigSrcs})
}

macro _JNI_CPP_SWIG_SRCS(Srcs...) {
    SRCS(${ext=.cpp:Srcs} ${ext=.swg:Srcs})
    _EXPORT_JAVA_BINDINGS(${ext=.java:Srcs})
    _EXPORT_SWIG_SOURCES(${ext=.swg:Srcs})
    .PEERDIR=contrib/tools/swig/Lib/java
}
macro _JNI_JAVA_SWIG_SRCS(Srcs...) {
    SRCS(${ext=.java:Srcs} ${ext=.swg:Srcs})
}

SWIG_JNI_BINDINGS_SEM= \
    add_swig_jni_library ${MODDIR} ${REALPRJNAME}-cpp GEN_JAVA_FILES_LIST ${"$"}{CMAKE_CURRENT_BINARY_DIR}/swig_gen_java.lst SOURCES ${_EXPLICIT_SWIG_IFACE_SOURCES} && \
    set_target_property OUTPUT_NAME $REALPRJNAME && \
    ${VCS_INFO_SEM} && \
    target_include_directories PUBLIC $_C__INCLUDE_GLOBAL && \
    target_include_directories PRIVATE $_C__INCLUDE_OWNED && \
    target_compile_options PRIVATE $USER_CFLAGS $USER_CXXFLAGS $_SEM_EXTRA_CXX_FLAGS && target_compile_options PUBLIC $USER_CFLAGS_GLOBAL_RAW $USER_CXXFLAGS_GLOBAL_RAW && \
    target_link_options PRIVATE $LDFLAGS_GLOBAL_RAW $LDFLAGS $OBJADDE_LIB $OBJADDE_LIB_GLOBAL $OBJADDE && \
    add_jar ${REALPRJNAME} SOURCES $_EXPLICIT_SWIG_JAVA_SOURCES @${"$"}{CMAKE_CURRENT_BINARY_DIR}/swig_gen_java.lst ${hide:TARGET}

### @usage: DLL_JAVA()
###
### DLL built using swig for Java. Produces dynamic library and a .jar.
### Dynamic library is treated the same as in the case of PEERDIR from Java to DLL.
### .jar goes on the classpath.
###
### Documentation: https://wiki.yandex-team.ru/yatool/java/#integracijascpp/pythonsborkojj
multimodule DLL_JAVA {
    module JNI_DLL: DLL {
        .ALIASES=SRCS=_JNI_CPP_SWIG_SRCS
        .FINAL_TARGET=no
        .SEM=SWIG_JNI_BINDINGS_SEM
        SWIG_LANG=jni_cpp
    }
    module JAR_COMPILATION: EXTERNAL_JAVA_LIBRARY {
        .ARGS_PARSER=DLL
        .ALIASES=SRCS=_JNI_JAVA_SWIG_SRCS PEERDIR=_NOOP_MACRO
        .PEERDIRSELF=JNI_DLL
        PEERDIR+=build/platform/java/jdk
        PEERDIR+=$JDK_RESOURCE_PEERDIR
        SET(DONT_RESOLVE_INCLUDES yes)
        .FINAL_TARGET=yes

        SWIG_LANG=jni_java
        _SWIG_CMD=$_SWIG_JNI_JAVA_CMD
        _SWIG_PEERDIR=contrib/tools/swig/Lib/java $_SWIG_JNI_PEERDIR
        _SWIG_SEM_TO_MODULE_LINK=${output;hide;suf=.jsrc:SRC}
    }
}