[libre-riscv-dev] [PATCH] Updating build scripts for installation

lkcl lkcl at libre-riscv.org
Mon Oct 22 12:28:35 BST 2018


On Mon, Oct 22, 2018 at 5:56 AM Daniel Benusovich
<flyingmonkeys1996 at gmail.com> wrote:
>
> Did not realize that the attachment is not present here is the patch:

 hi daniel, yes that's possibly my fault for setting strict filters on
what types of attachments are permitted: text/plain, multipart,
images, multipart/signature (for gpg) and not a lot else.

> From 74a914a8fbadd3da3e5896ade246202d75027832 Mon Sep 17 00:00:00 2001
> From: Daniel Benusovich <flyingmonkeys1996 at gmail.com>
> Date: Sun, 21 Oct 2018 20:12:23 -0700
> Subject: [PATCH] Updating build scripts for installation

  ok so what's very good about this patch is that it highlights the
areas where the quick-hack added python script i added assumes that it
is run in the cwd. ($src_dir).

 i must apologise for not making the requirements clear (or, the
"normal" behaviour of autoconf / makefiles, which is that they should
be runnable from any directory.  i.e. it should be possible to create
a directory absolutely anywhere, then explicitly run the configure
script either by relative *or* absolute; the autoconf configure script
then uses its position in the source tree to create and propagate a
Makefile variable "$src_dir" which is then expected to be used in all
scripts and commands.

 so that's what i had missed out.

 these lines are original, and worked as intended:
 - sed 's/NAME/$(subst .cc,,$@)/' $(src_dir)/riscv/insn_template.cc | sed

 i was not the one to add these, and they are the correct behaviour.
note the use of the $(src_dir).

 now, ordinarily, it would be okay to pass python
$(src_dir)/id_regs.py $(src_dir)/riscv/insns/$(subst....) etc to the
python script from the Makefile.

 however... um, as you probably found out, i wrote the script in such
a hurry that it has the riscv subdirectory hard-coded.  you fix this
here:

 -insns_dir = "./riscv/insns"
+insns_dir = "../riscv/insns"

at the expense of making it not possible for me to use the script in
the root ($src_dir) directory, which i should not be doing, but hey :)

there are a number of ways to fix this, and the one that i prefer is
something along the lines of using:

 src_dir =  os.path.dirname(os.path.realpath(__file__))

which is the top answer from here:
https://stackoverflow.com/questions/5137497/find-current-directory-and-files-directory

and then prepending that to the command argument (os.path.join) and
modifying the riscv.mk.in to this:
python id_regs.py riscv/insns/$(subst .cc,,$@).h

it could even just have riscv/insns/ stripped off as well and for that
to be constructed inside the python script:
src_dir =  os.path.dirname(os.path.realpath(__file__))
instruction_filename = sys.argv[1]
os.path.join(src_dir, "riscv/ins", instructionfilename)

this would break if id_regs.py was ever moved out of the root
$src_dir... which i do not intend to do.

so, apologies for not making the expected behaviour clear... want to
have another go? :)

l.



More information about the libre-riscv-dev mailing list