ohrstrom@1504: /* ohrstrom@1504: * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. ohrstrom@1504: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohrstrom@1504: * ohrstrom@1504: * This code is free software; you can redistribute it and/or modify it ohrstrom@1504: * under the terms of the GNU General Public License version 2 only, as ohrstrom@1504: * published by the Free Software Foundation. Oracle designates this ohrstrom@1504: * particular file as subject to the "Classpath" exception as provided ohrstrom@1504: * by Oracle in the LICENSE file that accompanied this code. ohrstrom@1504: * ohrstrom@1504: * This code is distributed in the hope that it will be useful, but WITHOUT ohrstrom@1504: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohrstrom@1504: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohrstrom@1504: * version 2 for more details (a copy is included in the LICENSE file that ohrstrom@1504: * accompanied this code). ohrstrom@1504: * ohrstrom@1504: * You should have received a copy of the GNU General Public License version ohrstrom@1504: * 2 along with this work; if not, write to the Free Software Foundation, ohrstrom@1504: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohrstrom@1504: * ohrstrom@1504: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohrstrom@1504: * or visit www.oracle.com if you need additional information or have any ohrstrom@1504: * questions. ohrstrom@1504: */ ohrstrom@1504: ohrstrom@1504: package com.sun.tools.sjavac; ohrstrom@1504: ohrstrom@1504: import java.io.PrintStream; ohrstrom@1504: import java.net.URI; ohrstrom@1504: import java.util.Set; ohrstrom@1504: import java.util.Map; ohrstrom@1504: ohrstrom@1504: /** ohrstrom@1504: * The transform interface is used to transform content inside a package, from one form to another. ohrstrom@1504: * Usually the output form is an unpredictable number of output files. (eg class files) ohrstrom@1504: * but can also be an unpredictable number of generated source files (eg idl2java) ohrstrom@1504: * or a single predictable output file (eg when copying,cleaning or compiling a properties file). ohrstrom@1504: * ohrstrom@1504: *

This is NOT part of any supported API. ohrstrom@1504: * If you write code that depends on this, you do so at your own ohrstrom@1504: * risk. This code and its internal interfaces are subject to change ohrstrom@1504: * or deletion without notice.

ohrstrom@1504: */ ohrstrom@1504: public interface Transformer ohrstrom@1504: { ohrstrom@1504: /** ohrstrom@1504: * The transform method takes a set of package names, mapped to their source files and to the ohrstrom@1504: * pubapis of the packages. ohrstrom@1504: * ohrstrom@1504: * The transform implementation must: ohrstrom@1504: * store the names of the generated artifacts for each package into package_artifacts ohrstrom@1504: * store found dependencies to other packages into the supplied set package_dependencies ohrstrom@1504: * store the public api for a package into the supplied set package_pubapis ohrstrom@1504: * ohrstrom@1504: * Any benign messages as a result of running the transform ohrstrom@1504: * are written into stdout, and errors are written to stderr. ohrstrom@1504: * ohrstrom@1504: * The debug_level can be 0=silent (only warnings and errors) 1=normal 2=verbose 3 or greater=debug ohrstrom@1504: * setExtra is used to set the extra information information that can be passed on ohrstrom@1504: * the command line to the smart javac wrapper. ohrstrom@1504: * ohrstrom@1504: * If sjavac is building incrementally from an existing javac_state, the var incremental is true. ohrstrom@1504: * ohrstrom@1504: * The transformer will only be called if some source in the package (or dependency) has ohrstrom@1504: * a modified timestamp. Thus the transformer might get called with many sources, of which ohrstrom@1504: * only one has changed. The transformer is allowed to regenerate all artifacts but ohrstrom@1504: * a better transformer will only write those artifacts that need updating. ohrstrom@1504: * ohrstrom@1504: * However the transformer must verify that the existing artifacts really are there! ohrstrom@1504: * and it must always update package_artifacts, package_dependencies, and package_pubapis correctly. ohrstrom@1504: * This means that at least for Java source, it will always have to recompile the sources. ohrstrom@1504: * ohrstrom@1504: * The transformer is allowed to put files anywhere in the dest_root. ohrstrom@1504: * An example of this is, can be the META-INF transformer that copy files ohrstrom@1504: * below META-INF directories to the single META-INF directory below dest_root. ohrstrom@1504: * ohrstrom@1504: * False is returned if there was an error that prevented the transform. ohrstrom@1504: * I.e. something was printed on stderr. ohrstrom@1504: * ohrstrom@1504: * If num_cores is set to a non-zero value. The transform should attempt to use no more than these ohrstrom@1504: * number of threads for heavy work. ohrstrom@1504: */ ohrstrom@1504: boolean transform(Map> pkgSrcs, ohrstrom@1504: Set visibleSources, ohrstrom@1504: Map> visibleClasses, ohrstrom@1504: Map> oldPackageDependencies, ohrstrom@1504: URI destRoot, ohrstrom@1504: Map> packageArtifacts, ohrstrom@1504: Map> packageDependencies, ohrstrom@1504: Map packagePublicApis, ohrstrom@1504: int debugLevel, ohrstrom@1504: boolean incremental, ohrstrom@1504: int numCores, ohrstrom@1504: PrintStream out, ohrstrom@1504: PrintStream err); ohrstrom@1504: ohrstrom@1504: void setExtra(String e); ohrstrom@1504: void setExtra(String[] args); ohrstrom@1504: }