Skip to content

Commit

Permalink
Okay, it's working on Windows now.
Browse files Browse the repository at this point in the history
  • Loading branch information
apjanke committed Jan 23, 2020
1 parent f18dc55 commit 543db17
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
30 changes: 16 additions & 14 deletions Mcode/+matpatch/Patch.m
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,17 @@ function harvest(this)
info.MatlabVersion, matpatch.Shed.matlabVersion);
return
end
% TODO: Detect whether a Unix-y diff is installed on Windows
% Detect whether a Unix-y diff is installed on Windows
if ispc
[status, output] = system('diff --version');
if status ~= 0
logger.warn('Can''t find a diff command.');
logger.info('This is probably because you don''t have diffutils installed.');
logger.info('Try installing diffutils from http://gnuwin32.sourceforge.net/packages/diffutils.htm');
logger.info('And make sure to add them to your %%PATH%%.')
return
end
end

% We can't diff directly against the Matlab installation, because we want
% to ignore non-existent files only on one side. So create a staging
Expand Down Expand Up @@ -262,19 +272,11 @@ function harvest(this)
userInfo.Name, userInfo.Email, datestr(now), ...
info.MatlabVersion, computer);
matpatch.Shed.spew(this.patchFile, header);
if isunix
cmd = sprintf('LC_ALL=C diff -Nru "%s" . >> "%s"', ...
tempDir, this.patchFile);
else
% Just hope that there is a Unix-y diff installed
cmd = sprintf('diff -Nru "%s" . >> "%s"', ...
tempDir, this.patchFile);
end
[status,output] = system(cmd);
if status ~= 0
mperror('Running diff failed: %s', output);
return
end
cmd = sprintf('diff -Nru "%s" . >> "%s"', ...
tempDir, this.patchFile);
[~,~] = system(cmd);
% We're just ignoring the exit status because diff returns nonzero if
% the files differ, and we can't differentiate that from failure.

matpatch.Shed.rmrf(tempDir);

Expand Down
4 changes: 2 additions & 2 deletions Mcode/+matpatch/Shed.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function cpr(src, dest)
function rmrf(target)
% Recursively, forcibly remove files
if ispc
cmd = sprintf('del /S /F "%s"', target);
cmd = sprintf('del /S /F /Q "%s"', target);
else
cmd = sprintf('rm -rf "%s"', target);
end
Expand All @@ -76,7 +76,7 @@ function spew(file, txt)
if fid < 1
error("Failed opening file '%s' for writing: %s", file, msg);
end
RAII.fid = @() fclose(fid); %#ok<STRNU>
RAII.fid = onCleanup(@() fclose(fid));
fprintf(fid, '%s', txt);
end

Expand Down
2 changes: 1 addition & 1 deletion Mcode/+matpatch/activate.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ function activate(patchNameOrPrefix)

matpatch.Shed.activatePatch(patchName);

logger.info("Walked over to patch %s", patchName);
logger.info("Now gardening patch %s", patchName);
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ But do that at your own risk; it is an unsupported configuration.

WARNING! Matlab is proprietary, commerical software. Its contents are the intellectual property of MathWorks. The patches you create are derived works of Matlab, and will also contain MathWorks' intellectual property. Do not give access to your patches to anyone unless you have verified that they have a currently active Matlab license!

## Requirements

On Windows, you need to install [GNU diffutils](http://gnuwin32.sourceforge.net/packages/diffutils.htm) or something else that gives you a Unix-y `diff` command.

MatPatchGardener requires the latest release of Matlab.
(There's not much point in producing patches for older releases.)
As of this writing, that's Matlab R2019b.

## Quick Start

```matlab
Expand Down Expand Up @@ -50,12 +58,6 @@ The easiest way to do this is to cd to the `Mcode/` directory under the MatPatch

If this is your first time gardening, `matpatch.wakeup` will walk you through an interactive setup of your user info.

## Requirements

MatPatchGardener requires the latest release of Matlab.
(There's not much point in producing patches for older releases.)
As of this writing, that's Matlab R2019b.

## Author

MatPatchGardner is written by [Andrew Janke](https://apjanke.net).
Expand Down

0 comments on commit 543db17

Please sign in to comment.