Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/sourcetools/com.ibm.uma/com/ibm/uma/om/VPath.java
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2001, 2017 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
package com.ibm.uma.om;
23
24
import com.ibm.uma.IPlatform;
25
import com.ibm.uma.UMA;
26
import com.ibm.uma.UMAException;
27
import com.ibm.uma.util.Logger;
28
29
30
public class VPath extends PredicateList {
31
32
public static final int TYPE_ROOT_PATH = 0;
33
public static final int TYPE_ARTIFACT = 1;
34
public static final int TYPE_MACRO = 2;
35
public static final int TYPE_RELATIVE_PATH = 3;
36
37
38
int type = TYPE_ARTIFACT;
39
String path;
40
String macro;
41
String pattern;
42
boolean augmentObjects;
43
boolean augmentIncludes;
44
45
public VPath(String containingFile) {
46
super(containingFile);
47
}
48
49
public boolean isAugmentIncludes() {
50
return augmentIncludes;
51
}
52
53
public void setAugmentIncludes(boolean augmentIncludes) {
54
this.augmentIncludes = augmentIncludes;
55
}
56
57
public boolean isAugmentObjects() {
58
return augmentObjects;
59
}
60
61
public void setAugmentObjects(boolean augmentObjects) {
62
this.augmentObjects = augmentObjects;
63
}
64
65
public int getType() {
66
return type;
67
}
68
69
public void setType(String typeString) {
70
if ( typeString.equalsIgnoreCase("rootpath") ) {
71
type = TYPE_ROOT_PATH;
72
} else if ( typeString.equalsIgnoreCase("artifact") ) {
73
type = TYPE_ARTIFACT;
74
} else if ( typeString.equalsIgnoreCase("relativepath") ) {
75
type = TYPE_RELATIVE_PATH;
76
} else if ( typeString.equalsIgnoreCase("macro") ) {
77
type = TYPE_MACRO;
78
}
79
}
80
81
public String getPattern() {
82
if ( pattern == null ) return "%";
83
return pattern;
84
}
85
86
public String getObjectFile() throws UMAException {
87
String objFile = "";
88
IPlatform platform = UMA.getUma().getPlatform();
89
String [] parts = pattern.split("\\.");
90
if ( parts.length == 1 ) {
91
objFile = pattern + platform.getObjectExtension();
92
} else {
93
for ( int i=0; i<parts.length-1; i++ ) {
94
objFile += parts[i];
95
}
96
objFile += platform.getObjectExtension();
97
}
98
return objFile;
99
}
100
101
public void setFile(String file) {
102
this.pattern = file;
103
}
104
105
public String getPath() {
106
return path;
107
}
108
109
public void setPath(String path) {
110
this.path = path;
111
}
112
113
@Override
114
public boolean evaluate() throws UMAException {
115
if ( !super.evaluate() ) return false;
116
if ( type == TYPE_MACRO ) {
117
macro = path;
118
path = UMA.getUma().getPlatform().replaceMacro(path);
119
type = TYPE_ARTIFACT;
120
}
121
if ( type == TYPE_ARTIFACT ) {
122
Artifact artifact = UMA.getUma().getArtifact(path);
123
if ( artifact == null ) {
124
/* in jvm.27 uma was updated to use an '_' instead of a '.' to define delimit scope from artifact name
125
* to support this change module.xml files were updated to change from '.' to '_' in jvm.27, older streams
126
* still use '.'.
127
*
128
* Add code here to detect the use of '.' and convert it to '_'.
129
* */
130
String underscorePath = path.replace('.', '_');
131
artifact = UMA.getUma().getArtifact(underscorePath);
132
if ( artifact == null ) {
133
// TODO turn this into hard-error vs. soft-error
134
if ( macro != null ) {
135
Logger.getLogger().println(Logger.WarningLog, "Warning: vpath path macro " + path + " does not expand to an artifact. [" + containingFile + "]");
136
} else {
137
Logger.getLogger().println(Logger.WarningLog, "Warning: vpath path " + path + " of type artifact not found. [" + containingFile + "]");
138
}
139
return false;
140
}
141
}
142
path = artifact.getContainingModule().getFullName();
143
type = TYPE_ROOT_PATH;
144
}
145
return true;
146
}
147
148
}
149
150