-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update install process to fix class ucode link directives #255
base: master
Are you sure you want to change the base?
Changes from 2 commits
a74dccc
8f35b4a
6e5ccc0
838442d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
############################################################################ | ||
# | ||
# File: fixalllinks.icn | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let us give the a more descriptive name in this context, maybe fixucodelinks.icn ? Also, let us move the file down to a subdirectory. I suggest to uni/progs since we already have utilities there such as idxGen.icn that we use with docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any required name changes or location placement changes that you require are a "go" as far as I am concerned. Let me know exactly want you want here and I'll make the appropriate changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @brucerennie |
||
# | ||
# Subject: Program to correct link directives in the ucode files. | ||
# | ||
# Author: Bruce Rennie | ||
# | ||
# Date: August 12, 2020 | ||
# | ||
############################################################################ | ||
# | ||
# This file is in the public domain. | ||
# | ||
############################################################################ | ||
# | ||
# This program corrects the link directives in ucode files for all | ||
# references to class ucode files. On installation of the system into the | ||
# install directories, the ucode files will have the link directives for class | ||
# ucode files pointing to the original compilation directories. When copied | ||
# to the install directories these need to be changed to reflect the actual | ||
# locations. This will normally be run from the Makefile when make Install | ||
# is executed. | ||
# | ||
# fixalllinks install.dir | ||
# | ||
# Within the Makefile, the install.dir is $(ULB) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The install location for "unicon library files" is $(ULB) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a problem, I will update the comments shortly. |
||
# | ||
# | ||
# | ||
############################################################################ | ||
# | ||
# Links: io, basename, ximage | ||
# | ||
############################################################################ | ||
# | ||
# | ||
link io, basename, ximage | ||
|
||
procedure main(args) | ||
local srcdir, | ||
destdir, | ||
destdirfs, | ||
infilename, | ||
outfilename, | ||
infs, | ||
outfs, | ||
fname, | ||
bname, | ||
line, | ||
subdirectories := ["3d", "gui", "ide", "lib", "parser", "udb", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is better if these subdirectories re passed in from the command line. Actually, we don't even have to do them all it was, but we could. Since the Makefile already does the follopwing:
we can just add a call to fix links as we go one directory at a time. The reason for this is that we don't have change the file itself if we add/remove new subdirectory or if installing some of them became conditionals. Also, by generalizing it, a user can use it to patch ucode files for any reason when they are moved around. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll check first that we can run it in this position and make sure that the code doesn't break. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If we change to command line parameters, Bruce will have to change the present treatment of the log file. Currently, it is opened with "w" (which will erase the previous log file). We will need a way of starting again at the beginning of a fresh install. |
||
"udb/lib", "udb/dta", "unicon", "unidep", | ||
"unidoc", "xml"], | ||
sd, | ||
logfile, | ||
outline | ||
|
||
# | ||
# If no parameter is given print message and exit | ||
# | ||
destdir := \args[1] | (write("no changes to be done to ucode files") & exit(0)) | ||
# | ||
# we will have a logfile of all changes made to each of the ucode files. | ||
# Useful for review if needed | ||
# | ||
logfile := open("fixucode.log", "w") | ||
# | ||
# if the last charcater of the destination (install) directory is the directory | ||
# specifier, then remove as we will add it as required in the following code | ||
# | ||
if destdir[-1] == ("/" | "\\") then { | ||
destdir[-1] := "" | ||
} | ||
write(logfile, "destination directory:", destdir) | ||
# | ||
# we want to be cautious in running this program and make sure that we are | ||
# actually dealing with a directory that exists. If the parameter is not a | ||
# valid directory, we simply abort. | ||
# | ||
if chdir(destdir) then { | ||
# | ||
# within the unicon class directory, there are (at present) 10 | ||
# sub-directories that need to have the relevant ucode files checked | ||
# for fully specified "link" directives. These "link" directives will | ||
# be altered to use the specified destination directory as the prefix. | ||
# | ||
# A new ucode file is written with the updated "link" directives and this | ||
# new file will replace the old ucode file. The old ucode file will be | ||
# kept with a new suffix. | ||
# | ||
every sd := !subdirectories do { | ||
writes(logfile, "sub-directory:") | ||
destdirfs := open(write(logfile, destdir || "/" || sd), "r") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it's worth computing prefix := destdir || "/" || sd || "/" and then replacing the multiple instances of destdir || "/" || sd // "/" || ... with prefix || ... It might not make all that much difference to the run time, but it might make the code slightly easier to read. No worries if you disagree. |
||
while infilename := read(destdirfs) do { | ||
if infilename[-2:0] == ".u" then { | ||
writes(logfile, " ucode file:") | ||
infs := open(write(logfile, destdir || "/" || sd || "/" || infilename), "r") | ||
outfs := open(outfilename := destdir || "/" || sd || "/" || infilename || ".upd", "w") | ||
while line := read(infs) do { | ||
if match("link", line) then { | ||
write(logfile, " line:", line) | ||
if find("/", line) then { | ||
line ? { | ||
outline := move(5) | ||
fname := tail(tab(0)) | ||
bname := basename(fname[1]) | ||
outline ||:= destdir || "/" || (\bname | "") || "/" || (\fname[2] | "") | ||
} | ||
line := outline | ||
write(logfile, " line:", line) | ||
} | ||
} | ||
write(outfs, line) | ||
} | ||
close(infs) | ||
close(outfs) | ||
if exists(destdir || "/" || sd || "/" || infilename || ".old") then { | ||
remove(destdir || "/" || sd || "/" || infilename || ".old") | ||
} | ||
rename(destdir || "/" || sd || "/" || infilename, destdir || "/" || sd || "/" || infilename || ".old") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename can fail. Is it worth checking for that? |
||
rename(outfilename, destdir || "/" || sd || "/" || infilename) | ||
} | ||
} | ||
close(destdirfs) | ||
} | ||
} else { | ||
stop("cannot change to directory \"", destdir, "\"") | ||
} | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we installing these extra directories? Are they being used as libraries similar to the existing dirs ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra directories contain useful ucode files. In addition, they also have updateable link directives. I added them for completeness. If you do not want to include them that is your prerogative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason those are not included as the other ones is that they don't contain library files intended to be used by end users. ide, unicon, udb, etc, are meant to be used in their binary forms. They are also not on the IPATH/LPATH like the other ones, and that is why they are not included by default.