1/* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18/* 19 * This gets separated out from misc module into a native module due to incompatibility between cpp-library and java-library plugins. 20 * For details, please see https://github.com/gradle/gradle-native/issues/352#issuecomment-461724948 21 */ 22import org.apache.tools.ant.taskdefs.condition.Os 23 24description = 'Module for native code' 25 26apply plugin: 'cpp-library' 27 28library { 29 baseName = 'LuceneNativeIO' 30 31 // Native build for Windows platform will be added in later stage 32 targetMachines = [ 33 machines.windows.x86_64 34 ] 35 36 // Point at platform-specific sources. Other platforms will be ignored 37 // (plugin won't find the toolchain). 38 if (Os.isFamily(Os.FAMILY_WINDOWS)) { 39 source.from file("${projectDir}/src/main/windows") 40 } 41} 42 43tasks.withType(CppCompile).configureEach { 44 def javaHome = rootProject.ext.runtimeJavaHome 45 46 // Assume standard openjdk layout. This means only one architecture-specific include folder is present. 47 systemIncludes.from file("${javaHome}/include") 48 49 for (def path : [file("${javaHome}/include/win32")]) { 50 if (path.exists()) { 51 systemIncludes.from path 52 } 53 } 54 55 compilerArgs.add '-fPIC' 56} 57 58tasks.withType(LinkSharedLibrary).configureEach { 59 linkerArgs.add '-lstdc++' 60} 61