1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // Multi-Phasic Applications: SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.plugin
.general
.cmake
;
12 import java
.io
.FileNotFoundException
;
13 import java
.io
.IOException
;
14 import java
.nio
.file
.Files
;
15 import java
.nio
.file
.Path
;
16 import java
.util
.concurrent
.TimeUnit
;
17 import org
.gradle
.api
.Action
;
18 import org
.gradle
.api
.Task
;
19 import org
.gradle
.api
.logging
.LogLevel
;
22 * Actual build task for CMake projects.
26 public class CMakeBuildTaskAction
27 implements Action
<Task
>
34 public void execute(Task __task
)
36 CMakeBuildTask from
= (CMakeBuildTask
)__task
;
38 Path cmakeSource
= from
.cmakeSource
;
39 Path cmakeBuild
= from
.cmakeBuild
;
43 // Make sure the output build directory exists
44 Files
.createDirectories(cmakeBuild
);
46 // Configure CMake first
47 CMakeUtils
.cmakeExecute(__task
.getLogger(),
50 "-S", cmakeSource
.toAbsolutePath().toString(),
51 "-B", cmakeBuild
.toAbsolutePath().toString());
53 // Then perform the actual build
54 CMakeUtils
.cmakeExecute(__task
.getLogger(),
57 "--build", cmakeBuild
.toAbsolutePath().toString(),
58 "-t", from
.cmakeRule
);
60 // Was the output file even created?
61 if (from
.cmakeOutFile
!= null && !Files
.exists(from
.cmakeOutFile
))
62 throw new FileNotFoundException(
63 "Could not find output library: " +
66 catch (IOException __e
)
68 throw new RuntimeException("CMake Build Failed.", __e
);