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
.IOException
;
13 import java
.nio
.file
.Files
;
15 import org
.gradle
.api
.Task
;
16 import org
.gradle
.api
.specs
.Spec
;
19 * Check to determine if the CMake build should be successful or not.
23 public class CMakeUpToDateWhen
31 public boolean isSatisfiedBy(Task __task
)
33 CMakeBuildTask cmakeTask
= (CMakeBuildTask
)__task
;
35 // Configuration is needed?
36 if (CMakeUtils
.configureNeeded(cmakeTask
))
39 // Cache directory does not exist?
40 if (!Files
.isDirectory(cmakeTask
.cmakeBuild
))
43 // Output is specified but does not exist?
44 if (cmakeTask
.cmakeOutFile
!= null &&
45 !Files
.exists(cmakeTask
.cmakeOutFile
))
48 // Poke the native build system to see if it is out of date
52 Map
<String
, String
> cmakeCache
= CMakeUtils
.loadCache(
53 cmakeTask
.cmakeBuild
);
55 // Which generator is being used?
56 String generator
= cmakeCache
.get("CMAKE_GENERATOR:INTERNAL");
59 case "MSYS Makefiles":
60 case "MinGW Makefiles":
61 case "Unix Makefiles":
62 if (CMakeUtils
.cmakeExecutePipe(false,
64 "up-to-date", "--", "-q") != 0)
68 case "NMake Makefiles":
69 if (CMakeUtils
.cmakeExecutePipe(false,
71 "up-to-date", "--", "/Q") != 0)
77 // If this occurs then assume out of date
78 catch (IOException __e
)
80 __task
.getLogger().warn("Could not determine if out of date.",
85 // Otherwise, success!