build.gradle 1.28 KB
Newer Older
Peter Steinbach's avatar
Peter Steinbach committed
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
import org.apache.tools.ant.taskdefs.condition.Os

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
apply plugin: 'maven-publish'

def project_root = file(".").absolutePath
def native_build_dir = './build/cpp'
def native_source_dir = './src/cpp'


task create_build_dir << {
  println 'create_build_dir'
  new File(native_build_dir).mkdirs()
}

task cmake(type:Exec) {
  
  workingDir(native_build_dir)
  
  inputs.dir file(native_source_dir).absolutePath
  outputs.file file(native_build_dir).absolutePath + '/Makefile'

  def native_build_type = project.hasProperty("sqy_build_type") ? sqy_build_type : "Release"
  def cmake_binary_path = project.hasProperty("cmake_binary_abspath") ? cmake_binary_abspath : "cmake"

  def cmake_args = [] as List
  cmake_args.add("-DCMAKE_BUILD_TYPE="+native_build_type+" ")

  cmake_args += file(native_source_dir).absolutePath



  if (Os.isFamily(Os.FAMILY_WINDOWS)){

    executable 'cmake.exe'
  } 
  else if (Os.isFamily(Os.FAMILY_MAC))
  {
    executable 'cmake'
    args cmake_args
  } 
  else if (Os.isFamily(Os.FAMILY_UNIX))
  {
    println "using "+cmake_binary_path
    executable cmake_binary_path
    args cmake_args

    // commandLine 'cmake',file(native_source_dir).absolutePath
  }

}

cmake.dependsOn create_build_dir
test.dependsOn cmake