Instead of execClang we now have execKonanClang which properly invokes
the distribution clang able to utilize distributed sysroots etc. And execBareClang which just invokes the distribution clang with system sysroot.
This commit is contained in:
committed by
alexander-gorshenev
parent
3a6cb76dc1
commit
cdd3185920
@@ -2286,7 +2286,7 @@ if (isMac()) {
|
||||
interop = 'objcSmoke'
|
||||
|
||||
doFirst {
|
||||
execClang {
|
||||
execKonanClang(project.testTarget) {
|
||||
args "$projectDir/interop/objc/smoke.m"
|
||||
args "-lobjc", '-fobjc-arc'
|
||||
args '-fPIC', '-shared', '-o', "$buildDir/libobjcsmoke.dylib"
|
||||
|
||||
@@ -98,11 +98,6 @@ class CompileCppToBitcode extends DefaultTask {
|
||||
linkerArgs.addAll(args)
|
||||
}
|
||||
|
||||
List<String> targetArgs(String target) {
|
||||
def result = project.rootProject.targetClangArgs(KonanTarget.valueOf(target.toUpperCase()))
|
||||
return result
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
void compile() {
|
||||
// the strange code below seems to be required due to some Gradle (Groovy?) behaviour
|
||||
@@ -113,12 +108,11 @@ class CompileCppToBitcode extends DefaultTask {
|
||||
File objDir = this.getObjDir()
|
||||
objDir.mkdirs()
|
||||
|
||||
project.execClang {
|
||||
project.execKonanClang(this.target) {
|
||||
workingDir objDir
|
||||
executable "clang++"
|
||||
args '-std=c++11'
|
||||
|
||||
args targetArgs(this.target)
|
||||
args compilerArgs
|
||||
|
||||
args "-I$headersDir"
|
||||
|
||||
@@ -22,6 +22,7 @@ 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 {
|
||||
|
||||
@@ -31,11 +32,52 @@ class ExecClang {
|
||||
this.project = project
|
||||
}
|
||||
|
||||
public ExecResult execClang(Closure closure) {
|
||||
return this.execClang(ConfigureUtil.configureUsing(closure));
|
||||
private List<String> konanArgs(KonanTarget target) {
|
||||
return project.rootProject.targetClangArgs(target)
|
||||
}
|
||||
|
||||
public ExecResult execClang(Action<? super ExecSpec> action) {
|
||||
private List<String> konanArgs(String target) {
|
||||
return konanArgs(new TargetManager(target).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) {
|
||||
@@ -55,6 +97,7 @@ class ExecClang {
|
||||
|
||||
environment["PATH"] = project.files(project.hostClang.hostClangPath).asPath +
|
||||
File.pathSeparator + environment["PATH"]
|
||||
args defaultArgs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user