Fixed a little issue in how we call ExecClang plugin. (#1317)
Moved ExecClang plugin to Kotlin.
This commit is contained in:
committed by
Nikolay Igotti
parent
12bec9b22f
commit
43cbea8a67
@@ -64,6 +64,8 @@ ext.externalTestsDir = project.file("external")
|
||||
ext.externalStdlibTestsDir = project.file("stdlib_external")
|
||||
externalTestsDir.mkdirs()
|
||||
|
||||
ext.platformManager = project.rootProject.platformManager
|
||||
ext.target = platformManager.targetManager(project.testTarget).target
|
||||
project.convention.plugins.remoteExec = new org.jetbrains.kotlin.ExecRemote(project)
|
||||
|
||||
allprojects {
|
||||
@@ -2424,7 +2426,7 @@ if (isMac()) {
|
||||
interop = 'objcSmoke'
|
||||
|
||||
doFirst {
|
||||
execKonanClang(project.testTarget) {
|
||||
execKonanClang(project.target) {
|
||||
args "$projectDir/interop/objc/smoke.m"
|
||||
args "-lobjc", '-fobjc-arc'
|
||||
args '-fPIC', '-shared', '-o', "$buildDir/libobjcsmoke.dylib"
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.process.ExecResult
|
||||
import org.gradle.process.ExecSpec
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
|
||||
class ExecClang {
|
||||
|
||||
private final Project project
|
||||
|
||||
ExecClang(Project project) {
|
||||
this.project = project
|
||||
}
|
||||
|
||||
private def platformManager = project.rootProject.platformManager
|
||||
|
||||
private List<String> konanArgs(KonanTarget target) {
|
||||
return platformManager.platform(target).clang.clangArgsForKonanSources
|
||||
}
|
||||
|
||||
private List<String> konanArgs(String targetName) {
|
||||
def target = platformManager.targetManager(targetName).target
|
||||
return konanArgs(target)
|
||||
}
|
||||
|
||||
// The bare ones invoke clang with system default sysroot.
|
||||
|
||||
public ExecResult execBareClang(Action<? super ExecSpec> action) {
|
||||
return this.execClang([], action)
|
||||
}
|
||||
|
||||
public ExecResult execBareClang(Closure closure) {
|
||||
return this.execClang([], closure)
|
||||
}
|
||||
|
||||
// The konan ones invoke clang with konan provided sysroots.
|
||||
// So they require a target or assume it to be the host.
|
||||
// The target can be specified as KonanTarget or as a
|
||||
// (nullable, which means host) target name.
|
||||
|
||||
public ExecResult execKonanClang(String target, Action<? super ExecSpec> action) {
|
||||
return this.execClang(konanArgs(target), action)
|
||||
}
|
||||
|
||||
public ExecResult execKonanClang(KonanTarget target, Action<? super ExecSpec> action) {
|
||||
return this.execClang(konanArgs(target), action)
|
||||
}
|
||||
|
||||
public ExecResult execKonanClang(String target, Closure closure) {
|
||||
return this.execClang(konanArgs(target), closure)
|
||||
}
|
||||
|
||||
public ExecResult execKonanClang(KonanTarget target, Closure closure) {
|
||||
return this.execClang(konanArgs(target), closure)
|
||||
}
|
||||
|
||||
// These ones are private, so one has to choose either Bare or Konan.
|
||||
|
||||
private ExecResult execClang(List<String> defaultArgs, Closure closure) {
|
||||
return this.execClang(defaultArgs, ConfigureUtil.configureUsing(closure))
|
||||
}
|
||||
|
||||
private ExecResult execClang(List<String> defaultArgs, Action<? super ExecSpec> action) {
|
||||
Action<? super ExecSpec> extendedAction = new Action<ExecSpec>() {
|
||||
@Override
|
||||
void execute(ExecSpec execSpec) {
|
||||
action.execute(execSpec)
|
||||
|
||||
execSpec.with {
|
||||
|
||||
if (executable == null) {
|
||||
executable = 'clang'
|
||||
}
|
||||
|
||||
if (executable in ['clang', 'clang++']) {
|
||||
executable = "${project.llvmDir}/bin/$executable"
|
||||
} else {
|
||||
throw new GradleException("unsupported clang executable: $executable")
|
||||
}
|
||||
|
||||
environment["PATH"] = project.files(project.hostPlatform.clang.clangPaths).asPath +
|
||||
File.pathSeparator + environment["PATH"]
|
||||
args defaultArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
return project.exec(extendedAction)
|
||||
}
|
||||
}
|
||||
@@ -551,7 +551,7 @@ class DynamicKonanTest extends KonanTest {
|
||||
|
||||
void runClang(List<String> cSources, String output, List<String> moreArgs) {
|
||||
def log = new ByteArrayOutputStream()
|
||||
project.execKonanClang(project.testTarget) {
|
||||
project.execKonanClang(project.target) {
|
||||
workingDir outputDirectory
|
||||
|
||||
executable "clang"
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import org.gradle.api.Action
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.process.ExecResult
|
||||
import org.gradle.process.ExecSpec
|
||||
import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.konan.target.*
|
||||
import org.jetbrains.kotlin.konan.file.*
|
||||
|
||||
internal class ExecClang(private val project: Project) {
|
||||
|
||||
private val platformManager = project.rootProject.findProperty("platformManager") as PlatformManager
|
||||
|
||||
private fun konanArgs(target: KonanTarget): List<String> {
|
||||
return platformManager.platform(target).clang.clangArgsForKonanSources.asList()
|
||||
}
|
||||
|
||||
private fun konanArgs(targetName: String?): List<String> {
|
||||
val target = platformManager.targetManager(targetName).target
|
||||
return konanArgs(target)
|
||||
}
|
||||
|
||||
// The bare ones invoke clang with system default sysroot.
|
||||
|
||||
fun execBareClang(action: Action<in ExecSpec>): ExecResult {
|
||||
return this.execClang(emptyList<String>(), action)
|
||||
}
|
||||
|
||||
fun execBareClang(closure: Closure<in ExecSpec>): ExecResult {
|
||||
return this.execClang(emptyList<String>(), closure)
|
||||
}
|
||||
|
||||
// The konan ones invoke clang with konan provided sysroots.
|
||||
// So they require a target or assume it to be the host.
|
||||
// The target can be specified as KonanTarget or as a
|
||||
// (nullable, which means host) target name.
|
||||
|
||||
fun execKonanClang(target: String?, action: Action<in ExecSpec>): ExecResult {
|
||||
return this.execClang(konanArgs(target), action)
|
||||
}
|
||||
|
||||
fun execKonanClang(target: KonanTarget, action: Action<in ExecSpec>): ExecResult {
|
||||
return this.execClang(konanArgs(target), action)
|
||||
}
|
||||
|
||||
fun execKonanClang(target: String?, closure: Closure<in ExecSpec>): ExecResult {
|
||||
return this.execClang(konanArgs(target), closure)
|
||||
}
|
||||
|
||||
fun execKonanClang(target: KonanTarget, closure: Closure<in ExecSpec>): ExecResult {
|
||||
return this.execClang(konanArgs(target), closure)
|
||||
}
|
||||
|
||||
// These ones are private, so one has to choose either Bare or Konan.
|
||||
|
||||
private fun execClang(defaultArgs: List<String>, closure: Closure<in ExecSpec>): ExecResult {
|
||||
return this.execClang(defaultArgs, ConfigureUtil.configureUsing(closure))
|
||||
}
|
||||
|
||||
private fun execClang(defaultArgs: List<String>, action: Action<in ExecSpec>): ExecResult {
|
||||
val extendedAction = object : Action<ExecSpec> {
|
||||
override fun execute(execSpec: ExecSpec) {
|
||||
action.execute(execSpec)
|
||||
|
||||
execSpec.apply {
|
||||
if (executable == null) {
|
||||
executable = "clang"
|
||||
}
|
||||
|
||||
if (listOf("clang", "clang++").contains(executable)) {
|
||||
val llvmDir = project.findProperty("llvmDir")
|
||||
executable = "${llvmDir}/bin/$executable" }
|
||||
else {
|
||||
throw GradleException("unsupported clang executable: $executable")
|
||||
}
|
||||
|
||||
val hostPlatform = project.findProperty("hostPlatform") as Platform
|
||||
environment["PATH"] = project.files(hostPlatform.clang.clangPaths).asPath +
|
||||
java.io.File.pathSeparator + environment["PATH"]
|
||||
args(defaultArgs)
|
||||
}
|
||||
}
|
||||
}
|
||||
return project.exec(extendedAction)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user