Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ jobs:
- name: lint standard modules
run: |
CHPL_HOME=$PWD make DYNO_ENABLE_ASSERTIONS=1 lint-standard-modules -j`util/buildRelease/chpl-make-cpu_count`
- name: lint mason
run: |
CHPL_HOME=$PWD make DYNO_ENABLE_ASSERTIONS=1 lint-mason -j`util/buildRelease/chpl-make-cpu_count`

make_check_llvm_none:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions Makefile.devel
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ lint-standard-modules: chplcheck FORCE
--disable-rule LineLength \
$(MODULES_TO_LINT)

MASON_MODULES_TO_LINT = $(shell find $(CHPL_MAKE_HOME)/tools/mason -name '*.chpl')
lint-mason: chplcheck FORCE
tools/chplcheck/chplcheck $(MASON_MODULES_TO_LINT)

run-frontend-linters: FORCE
@cd compiler && $(MAKE) run-frontend-linters

Expand Down
161 changes: 94 additions & 67 deletions test/mason/mason-help-tests/masonHelpTests.good

Large diffs are not rendered by default.

44 changes: 23 additions & 21 deletions tools/mason/MasonBuild.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ proc masonBuild(args: [] string) throws {

const projectType = getProjectType();
if projectType == "light" then
throw new owned MasonError("Mason light projects do not currently support 'mason build'");
throw new MasonError("Mason light projects do not " +
"currently support 'mason build'");

log.debugln("Project type acquired");

Expand Down Expand Up @@ -103,16 +104,18 @@ proc masonBuild(args: [] string) throws {
const tomlName = configNames[0];
const lockName = configNames[1];
log.debugln("About to build program");
buildProgram(release, show, force, skipUpdate, compopts, tomlName, lockName);
buildProgram(release, show, force, skipUpdate,
compopts, tomlName, lockName);
}
}

private proc checkChplVersion(lockFile : borrowed Toml) throws {
private proc checkChplVersion(lockFile: borrowed Toml) throws {
const root = lockFile["root"]!;
const (success, low, hi) = verifyChapelVersion(root);

if !success {
throw new owned MasonError("Build failure: lock file expecting chplVersion " + prettyVersionRange(low, hi));
throw new MasonError("Build failure: lock file expecting chplVersion " +
prettyVersionRange(low, hi));
}
}

Expand Down Expand Up @@ -167,14 +170,12 @@ proc buildProgram(release: bool, show: bool, force: bool, skipUpdate: bool,
var compopts = cmdLineCompopts;
compopts.pushBack(getTomlCompopts(lockFile));
// Compile Program
if compileSrc(lockFile, binLoc, show, release, compopts, projectHome) {
if compileSrc(lockFile, binLoc, release, compopts, projectHome) {
writeln("Build Successful\n");
} else {
throw new MasonError("Build Failed");
}
else {
throw new owned MasonError("Build Failed");
}
}
else {
} else {
writeln("Skipping Build... No changes to project");
}
}
Expand All @@ -184,7 +185,7 @@ proc buildProgram(release: bool, show: bool, force: bool, skipUpdate: bool,
folder. Requires that the main library file be
named after the project folder in which it is
contained */
proc compileSrc(lockFile: borrowed Toml, binLoc: string, show: bool,
proc compileSrc(lockFile: borrowed Toml, binLoc: string,
release: bool, compopts: list(string),
projectHome: string) : bool throws {

Expand All @@ -199,9 +200,8 @@ proc compileSrc(lockFile: borrowed Toml, binLoc: string, show: bool,
const moveTo = Path.joinPath(projectHome, 'target', binLoc, project);

if !isFile(pathToProj) {
throw new owned MasonError("Mason could not find your project");
}
else {
throw new MasonError("Mason could not find your project");
} else {
log.debugln("Starting to create compilation command");

var cmd: list(string);
Expand All @@ -226,6 +226,7 @@ proc compileSrc(lockFile: borrowed Toml, binLoc: string, show: bool,

// can't use _ since it will leak
// see https://github.com/chapel-lang/chapel/issues/25926
@chplcheck.ignore("UnusedLoopIndex")
for (_x, name, version) in srcSource.iterList(sourceList) {
const nameVer = "%s-%s".format(name, version);
// version of -1 specifies a git dep
Expand All @@ -246,8 +247,10 @@ proc compileSrc(lockFile: borrowed Toml, binLoc: string, show: bool,

// can't use _ since it will leak
// see https://github.com/chapel-lang/chapel/issues/25926
@chplcheck.ignore("UnusedLoopIndex")
for (_x, name, branch, _y) in gitSource.iterList(gitList) {
var gitDepSrc = ' ' + gitDepPath + name + "-" + branch + '/src/' + name + ".chpl";
const gitDepSrc = Path.joinPath(gitDepPath, name + "-" + branch,
'src', name + ".chpl");
cmd.pushBack(gitDepSrc);
}

Expand All @@ -263,9 +266,7 @@ proc compileSrc(lockFile: borrowed Toml, binLoc: string, show: bool,
}

// Confirming File Structure
if isFile(projectHome + '/target/' + binLoc + '/' + project) then
return true;
else return false;
return isFile(Path.joinPath(projectHome, 'target', binLoc, project));
}
return false;
}
Expand Down Expand Up @@ -320,7 +321,8 @@ proc getSrcCode(sourceList: list(srcSource), skipUpdate, show) throws {
const destination = baseDir + nameVers;
if !depExists(nameVers) {
if skipUpdate then
throw new MasonError("Dependency cannot be installed when MASON_OFFLINE is set.");
throw new MasonError("Dependency cannot be installed when " +
"MASON_OFFLINE is set.");
writeln("Downloading dependency: " + nameVers);
var getDependency = "git clone -qn "+ srcURL + ' ' + destination +'/';
var checkout = "git checkout -q v" + version;
Expand Down Expand Up @@ -383,7 +385,7 @@ proc getTomlCompopts(lock: borrowed Toml): list(string) throws {
}

if const exDeps = lock.get['external'] {
for (name, depInfo) in zip(exDeps.A.keys(), exDeps.A.values()) {
for (_, depInfo) in zip(exDeps.A.keys(), exDeps.A.values()) {
for (k,v) in allFields(depInfo!) {
var val = v!;
select k {
Expand All @@ -396,7 +398,7 @@ proc getTomlCompopts(lock: borrowed Toml): list(string) throws {
}
}
if const pkgDeps = lock.get['system'] {
for (name, dep) in zip(pkgDeps.A.keys(), pkgDeps.A.values()) {
for (_, dep) in zip(pkgDeps.A.keys(), pkgDeps.A.values()) {
var depInfo = dep!;
compopts.pushBack(depInfo["libs"]!.s);
compopts.pushBack("-I" + depInfo["include"]!.s);
Expand Down
55 changes: 34 additions & 21 deletions tools/mason/MasonEnv.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use MasonUtils;
public use MasonHelp;
const regUrl: string = "https://github.com/chapel-lang/mason-registry";

@chplcheck.ignore("CamelCaseFunctions")
proc MASON_HOME : string {
const envHome = getEnv("MASON_HOME");
const default = getEnv('HOME') + "/.mason";
Expand All @@ -32,9 +33,11 @@ proc MASON_HOME : string {
return masonHome;
}

/* Returns an array of directory strings corresponding to MASON_HOME/name for
each name in MASON_REGISTRY.
*/
/*
Returns an array of directory strings corresponding to MASON_HOME/name for
each name in MASON_REGISTRY.
*/
@chplcheck.ignore("CamelCaseFunctions")
proc MASON_CACHED_REGISTRY {
const masonRegistry = MASON_REGISTRY;
const masonHome = MASON_HOME;
Expand All @@ -45,28 +48,34 @@ proc MASON_CACHED_REGISTRY {
return cachedRegistry;
}

/* Returns value of MASON_OFFLINE, environment variable that disales online access.
*/
/*
Returns value of MASON_OFFLINE, environment variable that
disables online access.
*/
@chplcheck.ignore("CamelCaseFunctions")
proc MASON_OFFLINE {
const offlineEnv = getEnv('MASON_OFFLINE');
const default = false;
var offline = false;

if (offlineEnv == 'true') || (offlineEnv == 'True') || (offlineEnv == 'TRUE') || (offlineEnv == '1') {
if (offlineEnv == 'true') || (offlineEnv == 'True') ||
(offlineEnv == 'TRUE') || (offlineEnv == '1') {
offline = true;
}
else offline = default;

return offline;
}

/* Read the MASON_REGISTRY environment variable. It should be a comma
separated list of registry 'name|location' pairs. Returns an array of
tuples containing (name, location). If 'name|' is omitted, it defaults
to the text following the final slash in 'location' after removing any
trailing slashes. e.g. if location is "/path/to/my/local_registry//"
then the default name is "local_registry".
*/
/*
Read the MASON_REGISTRY environment variable. It should be a comma
separated list of registry 'name|location' pairs. Returns an array of
tuples containing (name, location). If 'name|' is omitted, it defaults
to the text following the final slash in 'location' after removing any
trailing slashes. e.g. if location is "/path/to/my/local_registry//"
then the default name is "local_registry".
*/
@chplcheck.ignore("CamelCaseFunctions")
proc MASON_REGISTRY throws {
const env = getEnv("MASON_REGISTRY");
const default = ("mason-registry",regUrl);
Expand All @@ -79,7 +88,8 @@ proc MASON_REGISTRY throws {
if str.strip().isEmpty() then continue;
const regArr = str.split('|');
if regArr.size > 2 || regArr.size < 1 {
const msg = "expected MASON_REGISTRY to contain a comma separated list of locations or 'name|location' pairs\n" + str;
const msg = "expected MASON_REGISTRY to contain a comma separated " +
"list of locations or 'name|location' pairs\n" + str;
throw new MasonError(msg);
} else {
var regTup: 2*string;
Expand All @@ -100,9 +110,10 @@ proc MASON_REGISTRY throws {
for i in registries.indices {
for j in i+1..<registries.size {
if registries(i)(0) == registries(j)(0) {
const msg = "registry names specified in MASON_REGISTRY must be unique:\n" +
registries(i)(0) + " - " + registries(i)(1) + "\n" +
registries(j)(0) + " - " + registries(j)(1);
const msg =
"registry names specified in MASON_REGISTRY must be unique:\n" +
registries(i)(0) + " - " + registries(i)(1) + "\n" +
registries(j)(0) + " - " + registries(j)(1);
throw new MasonError(msg);
}
}
Expand All @@ -111,10 +122,12 @@ proc MASON_REGISTRY throws {
return registries;
}

/* Returns the path to use when caching the list of licenses, if provided by the
user. This is useful for systems where internet connectivity can be erratic
or slow.
*/
/*
Returns the path to use when caching the list of licenses, if provided by the
user. This is useful for systems where internet connectivity can be erratic
or slow.
*/
@chplcheck.ignore("CamelCaseFunctions")
proc MASON_LICENSE_CACHE_PATH: string {
const licenseCache = getEnv("MASON_LICENSE_CACHE_PATH");

Expand Down
20 changes: 12 additions & 8 deletions tools/mason/MasonExample.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ proc masonExample(args: [] string) throws {

const projectType = getProjectType();
if projectType == "light" then
throw new owned MasonError("Mason light projects do not currently support 'mason example'");
throw new MasonError("Mason light projects do not currently " +
"support 'mason example'");

try! {
parser.parseArgs(args);
Expand Down Expand Up @@ -263,19 +264,22 @@ private proc runExamples(show: bool, run: bool, build: bool, release: bool,
}
} else {
// build is skipped but examples still need to be run
writeln("Skipping "+ example + ": no changes made to project or example");
writeln("Skipping ", example,
": no changes made to project or example");
if run then
runExampleBinary(projectHome, exampleName, release, show, exampleExecopts);
runExampleBinary(projectHome, exampleName,
release, show, exampleExecopts);
}
}
// just running the example
else {
runExampleBinary(projectHome, exampleName, release, show, exampleExecopts);
runExampleBinary(projectHome, exampleName,
release, show, exampleExecopts);
}
}
}
else {
throw new owned MasonError("No examples were found in /example");
throw new MasonError("No examples were found in /example");
}
}
catch e: MasonError {
Expand All @@ -300,9 +304,9 @@ private proc runExampleBinary(projectHome: string, exampleName: string,
const exampleResult = runWithStatus(command.toArray());
if exampleResult != 0 {
throw new MasonError(
"Example has not been compiled: " + exampleName + ".chpl\n" +
"Try running: mason build --example " + exampleName + ".chpl\n" +
" or: mason run --example " + exampleName + ".chpl --build");
"Example has not been compiled: " + exampleName + ".chpl\n" +
"Try running: mason build --example " + exampleName + ".chpl\n" +
" or: mason run --example " + exampleName + ".chpl --build");
}
}

Expand Down
Loading
Loading