From: mmv Date: Mon, 9 Dec 2013 12:04:40 +0000 (+0400) Subject: Added opportunity to generate AutoMake files for new platform X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=fb139de4954b3c36028cf40427ca56718f2f1132;p=occt-wok.git Added opportunity to generate AutoMake files for new platform --- diff --git a/src/WOKTclLib/OS.tcl b/src/WOKTclLib/OS.tcl index aea000a..b7c5f2e 100755 --- a/src/WOKTclLib/OS.tcl +++ b/src/WOKTclLib/OS.tcl @@ -3148,7 +3148,7 @@ proc OS:cbp { theModules theOutDir } { return $aProjectFiles } -proc OS:MKAMK { theOutDir {theModules {}} theSubPath} { +proc OS:MKAMK { theOutDir {theModules {}} theSubPath isAndroid} { wokUtils:FILES:mkdir $theOutDir foreach aModule $theModules { @@ -3156,7 +3156,7 @@ proc OS:MKAMK { theOutDir {theModules {}} theSubPath} { puts " toolkit: $aToolKit ==> [woklocate -p ${aToolKit}:source:EXTERNLIB]" wokUtils:FILES:rmdir $theOutDir/$aToolKit wokUtils:FILES:mkdir $theOutDir/$aToolKit - osutils:tk:mkam $theOutDir/$aToolKit $aToolKit + osutils:tk:mkam $theOutDir/$aToolKit $aToolKit $isAndroid } foreach anExecutable [OS:executable $aModule] { wokUtils:FILES:rmdir $theOutDir/$anExecutable @@ -3166,7 +3166,7 @@ proc OS:MKAMK { theOutDir {theModules {}} theSubPath} { } osutils:am:adm $theOutDir $theModules - osutils:am:root [wokinfo -p HomeDir] $theSubPath $theModules + osutils:am:root [wokinfo -p HomeDir] $theSubPath $theModules $isAndroid puts "The automake files are stored in the $theOutDir directory" } @@ -3301,7 +3301,7 @@ set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}" # Entry function to generate project files and solutions for IDE proc OS:MKPRC { {theOutDir {}} {theProjectType {}} {theIDE ""} } { - set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "cmake" "amk" "xcd"} + set aSupportedIDE { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "cmake" "amk" "xcd" "android"} if { [lsearch $aSupportedIDE $theIDE] < 0 } { puts stderr "WOK does not support generation of project files for the selected IDE: $theIDE\nSupported IDEs: [join ${aSupportedIDE} " "]" @@ -3368,7 +3368,8 @@ proc OS:MKPRC { {theOutDir {}} {theProjectType {}} {theIDE ""} } { "vc12" { OS:MKVC $anOutDir $aModules $anAllSolution $theIDE } "cbp" { OS:MKCBP $anOutDir $aModules $anAllSolution } "cmake" { OS:MKCMK "${anOutRoot}/.." $aModules $anAllSolution } - "amk" { OS:MKAMK $anOutDir $aModules "adm/${aWokStation}/${theIDE}"} + "amk" { OS:MKAMK $anOutDir $aModules "adm/${aWokStation}/${theIDE}" ""} + "android" { OS:MKAMK $anOutDir $aModules "adm/${aWokStation}/${theIDE}" "true"} "xcd" { set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000" OS:MKXCD $anOutDir $aModules $anAllSolution diff --git a/src/WOKTclLib/osutils.tcl b/src/WOKTclLib/osutils.tcl index 1901402..0960c3b 100755 --- a/src/WOKTclLib/osutils.tcl +++ b/src/WOKTclLib/osutils.tcl @@ -1121,7 +1121,7 @@ proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} ;# Create in dir the Makefile.am associated with toolkit tkloc. ;# Returns the full path of the created file. ;# -proc osutils:tk:mkam { dir tkloc } { +proc osutils:tk:mkam { dir tkloc isAndroid} { set pkgs [woklocate -p ${tkloc}:PACKAGES] if { $pkgs == {} } { puts stderr "osutils:tk:mkam : Error. File PACKAGES not found for toolkit $tkloc." @@ -1157,6 +1157,15 @@ proc osutils:tk:mkam { dir tkloc } { } else { set libadd "" } + + if { $isAndroid !={} } { + set avoidversion "lib${tkloc}_la_LDFLAGS = -avoid-version" + } else { + set avoidversion "" + } + + regsub -all -- {__AVOIDVERSION__} $tmplat $avoidversion tmplat + regsub -all -- {__LIBADD__} $tmplat $libadd tmplat set source [osutils:am:__SOURCES__ $lsrc] regsub -all -- {__SOURCES__} $tmplat $source tmplat @@ -1363,7 +1372,7 @@ proc osutils:am:adm { dir {lesmodules {}} } { ;# Create in dir the Makefile.am and configure.ac in CASROOT directory. ;# Returns the full path of the created file. ;# -proc osutils:am:root { dir theSubPath {lesmodules {}} } { +proc osutils:am:root { dir theSubPath {lesmodules {}} isAndroid} { set amstring "srcdir = @srcdir@\n\n" append amstring "SUBDIRS = ${theSubPath}\n\n" append amstring "VPATH = @srcdir@ @top_srcdir@/${theSubPath}: @top_srcdir@/${theSubPath}:\n\n" @@ -1422,6 +1431,25 @@ proc osutils:am:root { dir theSubPath {lesmodules {}} } { } set lower [string tolower ${lower}] + + if {$isAndroid !={} } { + set flags {Linux*) CXXFLAGS="$CXXFLAGS -DLIN -D_GNU_SOURCE=1" + CFLAGS="$CFLAGS -DLIN" + LDFLAGS="$LDFLAGS -lstdc++ -lc";;} + set pthread {AC_CHECK_LIB([c],[pthread_create],[],[AC_MSG_ERROR([Posix threads required])]) + CSF_ThreadLibs_LIB=-lc} + set fpucontrol "fpu_control.h" + set pathmakefile "adm/lin/android/Makefile" + } else { + set flags {Linux*) CXXFLAGS="$CXXFLAGS -DLIN -DLININTEL -D_GNU_SOURCE=1 -mmmx -msse -msse2 -mfpmath=sse -Wall" + CFLAGS="$CFLAGS -DLIN -DLININTEL -fexceptions -mmmx -msse -msse2 -mfpmath=sse -Wall" + LDFLAGS="$LDFLAGS -lstdc++ -lrt";;} + + set pthread {AC_CHECK_LIB([pthread],[pthread_create],[],[AC_MSG_ERROR([Posix threads required])]) + CSF_ThreadLibs_LIB=-lpthread} + set fpucontrol "" + set pathmakefile "adm/lin/amk/Makefile" + } append amstring "\n\nif ENABLE_${up}\n" append amstring " ${theModule}_DIRS = \$(${theModule}_PKGS)\n" append amstring "else\n" @@ -1511,6 +1539,10 @@ proc osutils:am:root { dir theSubPath {lesmodules {}} } { append amstring $exelocal append amstring $phony + regsub -all -- {__PATHMAKEFILE__} $acstring $pathmakefile acstring + regsub -all -- {__PTHREAD__} $acstring $pthread acstring + regsub -all -- {__FPUCONTROL__} $acstring $fpucontrol acstring + regsub -all -- {__LINUXFLAGS__} $acstring $flags acstring regsub -all -- {__ENABLEMODULES__} $acstring $enablestr acstring regsub -all -- {__CONFMODULES__} $acstring $confstr acstring regsub -all -- {__CONDMODULES__} $acstring $condstr acstring diff --git a/src/WOKTclLib/templates/build_android b/src/WOKTclLib/templates/build_android new file mode 100755 index 0000000..125c104 --- /dev/null +++ b/src/WOKTclLib/templates/build_android @@ -0,0 +1,133 @@ +#!/bin/bash +################################################################# +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +################################################################# +# Please define variables (required) +ndk=/path/to/android-ndk-r8e +prefix=/path/to/libs +toolchain=/android-toolchain +################################################################# + +exportvar() +{ + if [ ! -e $ndk$toolchain/sysroot/usr/include/jni.h ]; then + echo "Abort. No toolchain found." + exit 0 + fi + echo "Running export..." + export SYSROOT="$ndk$toolchain/sysroot" + export PATH=$PATH:$ndk$toolchain/bin + export CXX="$ndk$toolchain/bin/arm-linux-androideabi-g++ --sysroot=$SYSROOT" + export CC="$ndk$toolchain/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT" + export NM="$ndk$toolchain/bin/arm-linux-androideabi-nm --sysroot=$SYSROOT" + export CPP="$ndk$toolchain/bin/arm-linux-androideabi-cpp --sysroot=$SYSROOT" + export AS="$ndk$toolchain/bin/arm-linux-androideabi-as --sysroot=$SYSROOT" + export OBJCOPY="$ndk$toolchain/bin/arm-linux-androideabi-objcopy --sysroot=$SYSROOT" + export OBJDUMP="$ndk$toolchain/bin/arm-linux-androideabi-objdump --sysroot=$SYSROOT" + export STRIP="$ndk$toolchain/bin/arm-linux-androideabi-strip --sysroot=$SYSROOT" + export RANLIB="$ndk$toolchain/bin/arm-linux-androideabi-ranlib --sysroot=$SYSROOT" + export CCLD="$ndk$toolchain/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT" + export AR="$ndk$toolchain/bin/arm-linux-androideabi-ar --sysroot=$SYSROOT" + export LD="$ndk$toolchain/bin/arm-linux-androideabi-ld" +} + +configure() +{ + exportvar + + echo "Running configure..." + ./configure --without-tk --without-tcl --disable-vis --disable-draw --enable-data --enable-algo --enable-dxe --enable-caf --disable-static --enable-debug=no --enable-production=yes --enable-shared=yes --build=i686-pc-linux-gnu --target=arm-linux-androideabi --host=arm-linux-androideabi --prefix=$prefix + + echo "Done." +} + +build() +{ + exportvar + + echo "Running make..." + core=$(echo "`nproc`" *2 | bc -l) + make -j $core + + echo "Running make install..." + make install + + echo "Done." + exit 0 +} + +strip() +{ + echo "Running strip..." + export STRIP="$ndk$toolchain/bin/arm-linux-androideabi-strip"; + for f in $prefix/lib/*.so; do $STRIP --strip-unneeded $f; done + echo "Done." +} + +test() +{ + echo "Running test..." + if [ ! -e $prefix/lib/libTKernel.so ]; then + echo "Nothing to be done." + exit 0 + fi + + cat <<_ACEOF > test.cpp + #include + #include + int main() { + BRepPrimAPI_MakeTorus Torus(4.0, 2.0); + return 0; + } +_ACEOF + +export CXX="$ndk$toolchain/bin/arm-linux-androideabi-g++" +$CXX test.cpp -DHAVE_IOSTREAM -DHAVE_FSTREAM -DHAVE_LIMITS_H -DHAVE_IOMANIP \ +-I$prefix/inc/ -L$prefix/lib/ -Wl,--start-group -lTKPrim -lTKMath -lTKernel \ +-lTKG2d -lTKBRep -lTKGeomBase -lTKG3d -lTKTopAlgo -lTKGeomAlgo -Wl,--end-group + +echo "Done." +} + +help() +{ +echo "Download android-ndk-rXX: (Linux XX-bit (x86)) +http://developer.android.com/tools/sdk/ndk/index.html + +Create toolchain: +/android-ndk-rXX/build/tools/make-standalone-toolchain.sh +--platform=android-X +--install-dir=\$ndk/android-toolchain +--toolchain=arm-linux-androideabi-4.7 + +Run scripts: +./build_configure +./build_Android configure +./build_Android build + +For additional information, please read: \$ndk/docs" +} + +case "$1" in + configure) + configure + ;; + build) + build + ;; + strip) + strip + ;; + test) + test + ;; + help) + help + ;; + + *) + echo "Usage: $0 {configure|build|test|strip|help}" >&2 + exit 1 +esac + +exit 0 diff --git a/src/WOKTclLib/templates/template.ac b/src/WOKTclLib/templates/template.ac old mode 100644 new mode 100755 index de6cfdf..f549532 --- a/src/WOKTclLib/templates/template.ac +++ b/src/WOKTclLib/templates/template.ac @@ -36,7 +36,7 @@ dnl Checks for header files. AC_HEADER_STDC AC_LANG([C]) AC_MSG_CHECKING([ for C header files ]) -AC_CHECK_HEADERS(dlfcn.h dl.h ieeefp.h time.h sys/time.h pwd.h) +AC_CHECK_HEADERS(dlfcn.h dl.h ieeefp.h time.h sys/time.h pwd.h __FPUCONTROL__) AC_CHECK_HEADERS(sys/statvfs.h sys/vfs.h sys/param.h osfcn.h netdb.h) AC_CHECK_HEADERS(sys/ioctl.h net/if.h sys/systeminfo.h sys/utsname.h) AC_CHECK_HEADERS(sysent.h unistd.h sys/unistd.h sys/socket.h) @@ -143,9 +143,7 @@ CXXFLAGS="$CXXFLAGS -DCSFDB -DOCC_CONVERT_SIGNALS" CFLAGS="$CFLAGS -DCSFDB -DOCC_CONVERT_SIGNALS" case $platform in - Linux*) CXXFLAGS="$CXXFLAGS -DLIN -DLININTEL -D_GNU_SOURCE=1 -mmmx -msse -msse2 -mfpmath=sse -Wall" - CFLAGS="$CFLAGS -DLIN -DLININTEL -fexceptions -mmmx -msse -msse2 -mfpmath=sse -Wall" - LDFLAGS="$LDFLAGS -lstdc++ -lrt";; + __LINUXFLAGS__ SunOS*) CXXFLAGS="$CXXFLAGS -Usun -DSOLARIS -instances=static" CFLAGS="$CFLAGS -Usun -DSOLARIS -instances=static" LDFLAGS="$LDFLAGS -instances=static" @@ -1081,5 +1079,5 @@ echo "-------------------------- -----" __REPMODULES__ echo -AC_OUTPUT([Makefile adm/lin/amk/Makefile custom.sh \ +AC_OUTPUT([Makefile __PATHMAKEFILE__ custom.sh \ __ACCONFMODULES__]) diff --git a/src/WOKTclLib/templates/template.mam b/src/WOKTclLib/templates/template.mam old mode 100644 new mode 100755 index 5669bce..da41e85 --- a/src/WOKTclLib/templates/template.mam +++ b/src/WOKTclLib/templates/template.mam @@ -14,6 +14,7 @@ __INCLUDES__ lib_LTLIBRARIES=lib__TKNAM__.la +__AVOIDVERSION__ lib__TKNAM___la_LIBADD = $(CSF_OPT_LIBS) \ __LIBADD__ \ __EXTERNLIB__ diff --git a/src/WOKsite/wok_tclshrc.tcl b/src/WOKsite/wok_tclshrc.tcl old mode 100644 new mode 100755 index 62e50f5..df6ae32 --- a/src/WOKsite/wok_tclshrc.tcl +++ b/src/WOKsite/wok_tclshrc.tcl @@ -301,7 +301,8 @@ proc wgenprojbat {thePath theIDE} { "vc11" { file copy -force -- "$::env(WOKHOME)/lib/templates/msvc.bat" "$aBox/msvc.bat" } "cbp" { file copy -force -- "$::env(WOKHOME)/lib/templates/codeblocks.sh" "$aBox/codeblocks.sh" } "xcd" { file copy -force -- "$::env(WOKHOME)/lib/templates/xcode.sh" "$aBox/xcode.sh" } - + "android" {file copy -force -- "$::env(WOKHOME)/lib/templates/build_android" "$aBox/build_android" } + } } } @@ -315,7 +316,7 @@ proc removeAllOccurrencesOf { theObject theList } { # Wrapper-function to generate VS project files proc wgenproj { args } { - set aSupportedTargets { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "cmake" "amk" "xcd" } + set aSupportedTargets { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "cbp" "cmake" "amk" "xcd" "android"} set anArgs $args # Setting default IDE. @@ -382,6 +383,7 @@ proc wgenproj { args } { cmake - CMake amk - AutoMake xcd - Xcode" + android - Android AutoMake" return }