[Open_electroporator] culture shock build automation script

Nathan McCorkle nmz787 at gmail.com
Sat May 5 05:17:35 UTC 2018


On Fri, May 4, 2018 at 9:16 PM, John Griessen <john at cibolo.com> wrote:

> I tested make_PYFLEX_F401.py some.
>
> I found it has option for doing G30TH.  I was thinking of having a
> separate file for that
> in another dir, since often the code directory has files of the same name,
> boot.py, main.py, so being contained in a dir with  a
> name like
> code_PYFLEX_F401
> or
> code_G30TH
> has utility.
>

Duplication of code is a cardinal sin of good software engineering :) I was
a little upset that I saw all the duplication in the low-level.py files in
the pyflex code dir... it's really ugly and hard to navigate and debug or
understand the parallel (duplicate) code flows.



>
> Maybe we could turn this into a script called make-upy.py, short and easy
> to remember and use it from one ~/bin directory,
> or /usr/local/bin/make-upy.py.  Otherwise the way I was using bash scripts
> is to have one in each code dir, with a few definitions
> in the top lines to make it unique for a target board.
>

seems like unneeded work, there's no good reason not to just leave it in
the culture_shock clone (or pypi package, if we go that far)

>
> I'd like to have the target board defined by the dir it is called from.
> Is there a way to grab that from
> a file?  A file called BOARD.TXT?  Containing PYFLEX_F401 for the case of
> being in /culture_shock/code_PYFLEX_F401/BOARD.TXT?


just use os.getcwd() to get the directory from where the
script/Python-process was launched (but watch out and do it before the
calls to os.chdir I wrote in there, chdir changes what getcwd returns). If
you had that dir name, then there's no reason for BOARD.TXT.


> Then you would call it without a --board xxx123 argument, and it would
> create a build dir called
> ../../micropython/ports/stm32/build-PYFLEX_F401
>

OK, sure, that seems like trading off --board XYZ with cd XYZ. It seems
like supporting both is easy enough. Defaulting to pyflex seems reasonable
too, since that's the target.

>
> Call it with argument, --clean, and it erases
> ../../micropython/ports/stm32/build-PYFLEX_F401 and exits.
>
> As of now, after --clean it asks for input.   That's a little mistake.
>

Oh, no I intended it to be that way... but it's an easy change, I just
chose a direction and coded it.


>
> I pushed a version with ../../micropython as the relative location for
> micropython.  That assumes you start in
> a dir like
> /culture_shock/code_PYFLEX_F401
> or
> /culture_shock/code_G30TH.
>

eh, that messes up the whole output_dir thing, which is what I'd prefer...
I want to tell the script where the build files will end up, then later
once the board is working, if I choose to free up drive space I just delete
the whole folder. Or if compile fails, or I am testing the overall
automation flow. What if I call the script from the root of the filesystem,
then that will also fail.

Just provide --micropython argument if you want to set the micropython root
and not have the automation clone for you. Cloning into two dirs higher
just doesn't make sense.

>
> I changed the top line of the below:
>
> micropython_dirname = "micropython"
> g30th_board_dirname = os.path.split(dhylands_g30th_b
> oard_url)[-1].split('.')[0]
> pyflex_board_dirname = os.path.split(pyflex_board_url)[-1].split('.')[0]
>
> to stop circular definition problem.


What circular definitions? The dependence chain looks linear to me.


> I don't think the board names need to come from a repo as it may change


exact the reason, if the repo URL changes, that's all the work we need to
do. As little code to change later if needed. Having multiple data sources
that could be coming from one single is a "code smell" to me.


> in

the future either.  These could just be string variables.
>

Well, they are strings before and after the string-splitting already.


> When I gave it the --board PYFLEX_F401 arguments, it was creating a
> build-PYB-V10 build dir...
>

you don't need to provide --board, it defaults to pyflex. Also, as I said,
I didn't test without using --output_dir=foobar... but when I just did now,
it clones micropython right in the culture_shock/code_PYFLEX_F401. The make
command started the build inside
culture_shock/code_PYFLEX_F401/micropython/ports/stm32/build-PYFLEX_F401

Literally all I typed was:
python make_PYFLEX_F401.py
from the code_PYFLEX_F401 dir


>
> I'm going ahead using the old bash script for now to get some hardware
> testing done.
>

Which was that? Are the steps in the markdown correct for your flow? Such
that if I run them step-by-step I can get past the initial make?


>
> Thanks in advance Nathan, if you have time to add more to this, and thanks
> for this error checking, data input asking script --
> it will be good when its ready.


Please let's reduce the code duplication, I don't want to sift through and
de-duplicate myself if we can just prevent it up-front. Add IF statements,
use monkey-patching, add a class structure, etc... let's talk about what
you are seeing and thinking, maybe I am mistakenly seeing duplication where
there is none... please let me know how I can help.

I am off for the month of May, but am somewhat interrupted with diaper
changes every 2-3 hours and other associated new-father tasks.


-- 
-Nathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cibolo.us/pipermail/open_electroporator/attachments/20180504/246445da/attachment.html>


More information about the open_electroporator mailing list