Skip to content
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

Cleanup and add a Makefile #161

Merged
merged 13 commits into from
Mar 13, 2020
Merged

Cleanup and add a Makefile #161

merged 13 commits into from
Mar 13, 2020

Conversation

alistair23
Copy link
Collaborator

After looking at #160 I think there are some things we can do to make it easier to get started with libtock-rs. One of the key things for me with all new projects is how hard is it to build and run this thing. I find the current bundle of scripts confusing and non obvious what I should do/run. This PR moves the linker files out of the main directory (so they don't clutter everything up) and then adds a Tock style Makefile which can be used to build the examples for the boards.

This PR also removes some unused files to again reduce clutter.

If this is merged the next step is to move the flash.sh actions into the Makefile and look at supporting building a single app (instead of all of the examples) and how to handle features.

Copy link
Contributor

@labbott labbott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the boards cleanup but I'm not sure if the Makefile is better. We were just relying on cargo to build and now we have cargo + make to maintain. Is this something we could supplement with just documentation?

Makefile Outdated Show resolved Hide resolved
@torfmaster
Copy link
Collaborator

Thank you for your contribution, I like the idea of moving the layout files. Can we please split out the discussion about the build system in general and the creation of a Makefile in particular to a separate issue? I created one for that topic: #162

@alistair23
Copy link
Collaborator Author

The advantage with Makefiles is that it's easy for new people to understand. Someone can clone this repo and run make and know what to do. The current method of run some random scripts is extremely confusing. Documenting something that is confusing only helps so much as people don't read documentation and that effort could be better spent just making it not confusing.\

As for just using Cargo, I don't think Cargo is powerful enough or easy to use enough for our use case right now. It's also not common (and not used outside of Rust), so it's another learning curve.

On top of that, Tock and libtoc-c both use Make, so now we all use the same thing.

@ppannuto
Copy link
Member

ppannuto commented Mar 10, 2020 via email

@alistair23
Copy link
Collaborator Author

Exactly! It's what everyone expects and our cargo commands are complex enough that we can't just say type cargo so we need something else around it.

In no way is this a move to get rid of Cargo. Replacing Cargo doesn't give you anything, this is just a simple wrapper to avoid people having to remember/discover the magic arguments to get their board working.

Copy link
Contributor

@Woyten Woyten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not very convinced that make is a good tool. From my understanding, it was designed to provide build management and change detection to old programming languages. Something that has become completely obsolete with cargo.

From my point, it's okay to use make if people insist. But I would like to let you know that when I got in touch with Tock OS for the first time, my reaction was that I wanted to stop immediately being annoyed by the fact that I was forced to install make which I considered a tool from the stone age.

Thus, using make is not a guarantee that people will appreciate the toolchain as in my case it lead to the opposite effect.

rustfmt.toml Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Comment on lines 1 to 8
#!/usr/bin/env bash

# Find boards based on folders with Makefiles
for b in $(find boards -maxdepth 4 | egrep 'layout'); do
b1=${b#boards/layout_}
b2=${b1%.ld}
echo $b2
done
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be a part of the makefile?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be able to, but I think it might be cleaner being outside

@bradjc
Copy link
Contributor

bradjc commented Mar 10, 2020

I agree that make is not good. But it is ubiquitous. Having cargo build work would be amazing, but I doubt it will ever be possible to have just cargo build actually work.

Having make do something useful is really nice.

@alistair23
Copy link
Collaborator Author

I'm amazed you didn't have Make installed, it's so commonly used in open source projects.

Right now you can build the OpenTitan platform, but accidentally enable atomics via the target flag, which results in a binary that will crash. There is no way that is clear to users and is prone to errors.

I have updated the Makefile to support: flashing, features and debug builds. It's all self documenting (make will tell you what to do) and it's in the README. This should be much easier for anyone getting started.

Signed-off-by: Alistair Francis <[email protected]>
@Woyten
Copy link
Contributor

Woyten commented Mar 10, 2020

I'm amazed you didn't have Make installed, it's so commonly used in open source projects.

It is commonly used in old programming languages that aren't shipped with build management. As I said, for me it's a tool from the stone age of computer science and I was not expecting to ever use it again, especially in the context of Rust which is shipped with a build management system. Keep in mind that, like me, there are a lot of people that never use it and don't have it installed since it's not required when working with more modern languages like Java, Phython, JavaScript or Rust.

Installing dependencies like Make was one of the hurdles when we did a workshop involving libtock-rs at our company. People tend to say that they don't want to pollute their system with Make only to play around with libtock-rs. It's just an old piece of software that is no longer installed on every system.

@torfmaster
Copy link
Collaborator

Can we move this discussion to #162 and merge the other changes in this PR in the meanwhile? It's not just adding a Makefile but adding just another build system to the existing one (I doubt that Makefiles will replace cargo, but if we were consequent, it should). I think we should have a structured discussion about the requirements we have for the build system.

Comment on lines -100 to -104
Instead of specifying an environment variable each time you can permanently configure your platform by writing its name into a file named `platform`, e.g.

```bash
echo nrf52 > platform
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this feature is no longer supported? Then, it should be removed from the build.rs script. Or you might consider bringing it back?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build.rs checks whether the PLATFORM env variable is set and, if not, checks whether the file platform is present.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will still do that, I haven't change build.rs. I just don't think this needs to be documented in the top level README anymore as it isn't really user exposed.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@Woyten
Copy link
Contributor

Woyten commented Mar 10, 2020

Could you adapt Contributing.md and consider removing doc/README.md?

@alistair23
Copy link
Collaborator Author

I just pushed an update addressing all of your comments.

README.md Show resolved Hide resolved
@torfmaster
Copy link
Collaborator

Having make do something useful is really nice.

I partially agree. But this PR commits libtock-rs to having a Makefile instead of a modern build system also in the CI. Moreover, we just wrap some functionality of Cargo in a Makefile (instead of just deleting Cargo.toml).

I see important points in the tock kernel build system not to use make:

  • tests are run for some crates in the kernel repo and for some not
  • there code around in the kernel repo which doesn't compile

This is something you get for free when you just use cargo but now require additional work (adding some command somewhere in a Makefile). I tried to fix that by making the kernel repo a cargo workspace but gave up. This is exactly the maintance hell you get into when you use Makefiles.

I would agree to having a Makefile in the repo because people coming from the embedded world feel that this takes away some initial hurdles. But the build system should still be make-free so it can be easily maintained by people having only background in Rust (at least this is a Rust library).

@torfmaster
Copy link
Collaborator

Right now you can build the OpenTitan platform, but accidentally enable atomics via the target flag, which results in a binary that will crash. There is no way that is clear to users and is prone to errors.

I believe this could be fixed by a validation in ´build.rs` We just were not aware of this issue.

Makefile Outdated Show resolved Hide resolved
.cargo/config Outdated Show resolved Hide resolved
@alistair23 alistair23 force-pushed the alistair/cleanup branch 2 times, most recently from e40e63e to cc49bf0 Compare March 11, 2020 17:03
@alistair23
Copy link
Collaborator Author

I have addressed all comments

Comment on lines +12 to +16
@echo " - hail"
@echo " - nrf52840"
@echo " - opentitan"
@echo " - hifive1"
@echo " - nrf52"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I really like about this PR is that the platform names have been cleaned up. Before, it was a mixture of CPU architectures and board layouts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly! :)

@torfmaster
Copy link
Collaborator

The cleanup is really nice and I have the feeling that many find the Makefile helpful.

bors d+

@bors
Copy link
Contributor

bors bot commented Mar 13, 2020

✌️ alistair23 can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@alistair23
Copy link
Collaborator Author

bors r+

@bors
Copy link
Contributor

bors bot commented Mar 13, 2020

Build succeeded

@bors bors bot merged commit 4d27d24 into tock:master Mar 13, 2020
@alistair23 alistair23 deleted the alistair/cleanup branch March 20, 2020 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants