< prev index next >

buildSrc/src/main/groovy/com/sun/javafx/gradle/NativeCompileTask.groovy

Print this page


   1 /*
   2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  65     public NativeCompileTask include(Iterable<String> includes) {
  66         patternSet.include(includes);
  67         return this;
  68     }
  69 
  70     private void updateFiles() {
  71         // Combine the different source roots into a single List<File> based on all files in each source root
  72         allFiles.clear();
  73         sourceRoots.each {
  74             def file = project.file(it);
  75             if (file && file.exists()) {
  76                 allFiles += file.isDirectory() ? file.listFiles() : file;
  77             }
  78         }
  79     }
  80 
  81     @TaskAction void compile() {
  82         // Get the existing native-dependencies file from build/dependency-cache and load its contents into
  83         // memory. If the file doesn't exist, then we will just have an empty dependency map.
  84         final Map<String, Map> dependencies = new ConcurrentHashMap<>();
  85         final File nativeDependenciesFile = project.file("$project.buildDir/dependency-cache/native-dependencies");
  86         if (nativeDependenciesFile.exists()) {
  87             nativeDependenciesFile.splitEachLine("\t", { strings ->
  88                 try {
  89                     dependencies.put(strings[0], ["DATE":Long.parseLong(strings[1]), "SIZE":Long.parseLong(strings[2])]);
  90                 } catch (Exception e) {
  91                     // Might fail due to a corrupt native-dependencies file, in which case, we'll just not
  92                     // do anything which will cause the native code to execute again
  93                 }
  94             });
  95         }
  96 
  97         project.mkdir(output);
  98 
  99         // Recompute the allFiles list as the input can come from auto-generated
 100         // content (HSLS files, for example) which might have changed since
 101         // the task was configured (i.e. when source() was called).
 102         updateFiles();
 103         def source = project.files(allFiles);
 104         boolean forceCompile = false;
 105         final Set<File> files = new HashSet<File>();


   1 /*
   2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  65     public NativeCompileTask include(Iterable<String> includes) {
  66         patternSet.include(includes);
  67         return this;
  68     }
  69 
  70     private void updateFiles() {
  71         // Combine the different source roots into a single List<File> based on all files in each source root
  72         allFiles.clear();
  73         sourceRoots.each {
  74             def file = project.file(it);
  75             if (file && file.exists()) {
  76                 allFiles += file.isDirectory() ? file.listFiles() : file;
  77             }
  78         }
  79     }
  80 
  81     @TaskAction void compile() {
  82         // Get the existing native-dependencies file from build/dependency-cache and load its contents into
  83         // memory. If the file doesn't exist, then we will just have an empty dependency map.
  84         final Map<String, Map> dependencies = new ConcurrentHashMap<>();
  85         final File nativeDependenciesFile = project.file("$project.buildDir/dependency-cache/native-dependencies-${output.getName()}");
  86         if (nativeDependenciesFile.exists()) {
  87             nativeDependenciesFile.splitEachLine("\t", { strings ->
  88                 try {
  89                     dependencies.put(strings[0], ["DATE":Long.parseLong(strings[1]), "SIZE":Long.parseLong(strings[2])]);
  90                 } catch (Exception e) {
  91                     // Might fail due to a corrupt native-dependencies file, in which case, we'll just not
  92                     // do anything which will cause the native code to execute again
  93                 }
  94             });
  95         }
  96 
  97         project.mkdir(output);
  98 
  99         // Recompute the allFiles list as the input can come from auto-generated
 100         // content (HSLS files, for example) which might have changed since
 101         // the task was configured (i.e. when source() was called).
 102         updateFiles();
 103         def source = project.files(allFiles);
 104         boolean forceCompile = false;
 105         final Set<File> files = new HashSet<File>();


< prev index next >