Skip to content

Commit 5761fd5

Browse files
authored
Merge pull request #4 from usethesource/fix/add-typepal-to-checker-projects
Add typepal dependency to projects that depend on Rascal checker
2 parents 17ad9d2 + a0652ab commit 5761fd5

1 file changed

Lines changed: 26 additions & 11 deletions

File tree

src/main/rascal/Main.rsc

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Projects projects = {
4242
<"drambiguity", project(|https://github.com/cwi-swat/drambiguity.git|, {"rascal", "salix-core"})>,
4343
<"rascal-git", project(|https://github.com/cwi-swat/rascal-git.git|, {"rascal"})>,
4444
<"php-analysis", project(|https://github.com/cwi-swat/php-analysis.git|, {"rascal", "rascal-git"}, srcs=["src/main/rascal"])>,
45-
<"rascal-lsp-all", project(|https://github.com/usethesource/rascal-language-servers.git|, {"rascal-all", "typepal"}, subdir="rascal-lsp", srcs=["src/main/rascal/library","src/main/rascal/lsp"])>,
45+
<"rascal-lsp-all", project(|https://github.com/usethesource/rascal-language-servers.git|, {"rascal-all"}, subdir="rascal-lsp", srcs=["src/main/rascal/library","src/main/rascal/lsp"])>,
4646
<"rascal-lsp", project(|https://github.com/usethesource/rascal-language-servers.git|, {"rascal", "typepal"}, srcs=["src/main/rascal/library"], subdir="rascal-lsp")>
4747
};
4848

@@ -70,16 +70,22 @@ str buildCP(loc entries...) = intercalate(getSystemProperty("path.separator"), [
7070
loc projectRoot(loc repoFolder, str name, Project proj) = (repoFolder + name) + proj.subdir;
7171

7272

73-
tuple[list[loc], list[loc]] calcSourcePaths(str name, Project proj, loc repoFolder) {
73+
tuple[list[loc], list[loc]] calcSourcePaths(str name, Project proj, loc repoFolder, loc(str) getProjectLoc) {
7474
srcs = proj.srcs != [] ? [projectRoot(repoFolder, name, proj) + s | s <- proj.srcs ] : getProjectPathConfig(projectRoot(repoFolder, name, proj)).srcs;
75-
ignores = [ s + i | s<- srcs, s.scheme != "jar+file", i <- proj.ignores];
75+
if (name == "rascal-all") {
76+
// To be able to access typepal in rascal-all (and rascal-lsp-all) without bootstrapping issues, we copy typepal sources and put them on our src path
77+
tpSources = repoFolder + "rascal-all/src/org/rascalmpl/typepal";
78+
copy(getProjectLoc("typepal") + "src/analysis/typepal", tpSources + "analysis/typepal", recursive=true);
79+
srcs = [src | src <- srcs, !(src.scheme == "mvn" && startsWith(src.authority, "org.rascalmpl--typepal"))] + resolveLocation(tpSources);
80+
}
81+
ignores = [ s + i | s <- srcs, s.scheme != "jar+file", i <- proj.ignores];
7682
return <srcs, ignores>;
7783
}
7884

79-
PathConfig generatePathConfig(str name, Project proj, loc repoFolder, false, false, loc _packageTarget) {
80-
<srcs, ignores> = calcSourcePaths(name, proj, repoFolder);
85+
PathConfig generatePathConfig(str name, Project proj, loc repoFolder, false, false, loc _packageTarget, loc(str) getProjectLoc) {
86+
<srcs, ignores> = calcSourcePaths(name, proj, repoFolder, getProjectLoc);
8187
for (str dep <- proj.dependencies, <dep, projDep> <- projects) {
82-
<nestedSrcs, nestedIgnores> = calcSourcePaths(dep, projDep, repoFolder);
88+
<nestedSrcs, nestedIgnores> = calcSourcePaths(dep, projDep, repoFolder, getProjectLoc);
8389
srcs += nestedSrcs;
8490
ignores += nestedIgnores;
8591
}
@@ -91,8 +97,8 @@ PathConfig generatePathConfig(str name, Project proj, loc repoFolder, false, fal
9197
libs = [repoFolder + "shared-tpls"] + (proj.rascalLib ? [|std:///|] : [])
9298
);
9399
}
94-
PathConfig generatePathConfig(str name, Project proj, loc repoFolder, true, bool package, loc packageTarget) {
95-
<srcs, ignores> = calcSourcePaths(name, proj, repoFolder);
100+
PathConfig generatePathConfig(str name, Project proj, loc repoFolder, true, bool package, loc packageTarget, loc(str) getProjectLoc) {
101+
<srcs, ignores> = calcSourcePaths(name, proj, repoFolder, getProjectLoc);
96102
result = pathConfig(
97103
projectRoot = projectRoot(repoFolder, name, proj),
98104
srcs = srcs,
@@ -166,6 +172,15 @@ int main(
166172
loc rascalVersion=|home:///.m2/repository/org/rascalmpl/rascal/0.41.0-RC46/rascal-0.41.0-RC46.jar|,
167173
set[str] tests = {/*all*/}
168174
) {
175+
176+
loc getProjectLoc(str projectName) {
177+
int res = updateRepos({p | p:<projectName, _> <- projects}, repoFolder, full);
178+
if (res != 0) {
179+
return |unknown:///|;
180+
}
181+
return repoFolder + projectName;
182+
}
183+
169184
mkDirectory(repoFolder);
170185
int result = 0;
171186
toBuild = (tests == {}) ? projects : { p | p <- projects, p.name in tests};
@@ -193,7 +208,7 @@ int main(
193208

194209
// prepare path configs
195210
println("*** Calculating class paths");
196-
pcfgs = [<n, generatePathConfig(n, proj, repoFolder, libs, package, packageTarget)> | n <- buildOrder, proj <- toBuild[n]];
211+
pcfgs = [<n, generatePathConfig(n, proj, repoFolder, libs, package, packageTarget, getProjectLoc)> | n <- buildOrder, proj <- toBuild[n]];
197212

198213

199214
if (clean) {
@@ -210,13 +225,13 @@ int main(
210225

211226
for (n <- buildOrder, proj <- toBuild[n]) {
212227
println("*** Preparing: <n>");
213-
p = generatePathConfig(n, proj, repoFolder, libs, package, packageTarget);
228+
p = generatePathConfig(n, proj, repoFolder, libs, package, packageTarget, getProjectLoc);
214229
if (clean) {
215230
for (f <- find(p.bin, "tpl")) {
216231
remove(f);
217232
}
218233
}
219-
println(p);
234+
iprintln(p);
220235
loc projectRoot = repoFolder + n;
221236
rProjectRoot = resolveLocation(projectRoot);
222237
rascalFiles = [*find(s, "rsc") | s <- p.srcs, (startsWith(s.path, projectRoot.path) || startsWith(s.path, rProjectRoot.path))];

0 commit comments

Comments
 (0)