Merge pull request #10 from Sendoushi/init-file

[new] Initialization file
This commit is contained in:
Lokathor 2018-11-20 00:19:31 -07:00 committed by GitHub
commit fdda573c0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 247 additions and 0 deletions

View file

@ -16,6 +16,12 @@ detailed for you [in the 0th chapter of the
book](https://rust-console.github.io/gba/ch00/index.html) that goes with this book](https://rust-console.github.io/gba/ch00/index.html) that goes with this
crate. crate.
## For a fast initialization start
```sh
curl https://raw.githubusercontent.com/rust-console/gba/master/init.sh -sSf | bash -s APP_NAME
```
# Contribution # Contribution
This crate is Apache2 licensed and any contributions you submit must also be This crate is Apache2 licensed and any contributions you submit must also be

65
init.sh Normal file
View file

@ -0,0 +1,65 @@
#!/bin/sh
APP_NAME=$1
if [ -z "$APP_NAME"]; then APP_NAME="rust-console-hello"; fi
TARGET="thumbv4-none-agb"
CRT_LOCAL="crt0.s"
echo "Initializing rust-console gba at: $1"
# initialize cargo
cargo init $APP_NAME --bin
# remove old
rm -rf $APP_NAME/thumbv4-none-agb.json*
rm -rf $APP_NAME/$CRT_LOCAL*
rm -rf $APP_NAME/linker.ld*
rm -rf $APP_NAME/Makefile*
rm -rf $APP_NAME/README.md*
# download dependencies
wget https://raw.githubusercontent.com/rust-console/gba/master/thumbv4-none-agb.json
mv $TARGET.json $APP_NAME/$TARGET.json
wget https://raw.githubusercontent.com/rust-console/gba/master/crt0.s
mv crt0.s $APP_NAME/$CRT_LOCAL
wget https://raw.githubusercontent.com/rust-console/gba/master/linker.ld;
mv linker.ld $APP_NAME/linker.ld
# substitute cargo main file with a new basic one
rm -rf $APP_NAME/src/main.rs
wget https://raw.githubusercontent.com/rust-console/gba/master/examples/hello1.rs
mv hello1.rs $APP_NAME/src/main.rs
# setup make file
echo -e "CRT_FILE=$(echo $CRT_LOCAL)
CRT_OUTPUT=crt0.o
PROJECT_NAME=$(echo $APP_NAME)
TARGET=$(echo $TARGET)
THUMB_TARGET=$(echo $TARGET).json
all: build
build:
\tarm-none-eabi-as \$(CRT_FILE) -o \$(CRT_OUTPUT)
\tcargo xbuild --target \$(THUMB_TARGET)
build-prod:
\tarm-none-eabi-as \$(CRT_FILE) -o \$(CRT_OUTPUT)
\tcargo xbuild --target \$(THUMB_TARGET) --release
\tarm-none-eabi-objcopy -O binary target/\$(TARGET)/release/\$(PROJECT_NAME) target/\$(PROJECT_NAME).gba
\tgbafix target/\$(PROJECT_NAME).gba
" > $APP_NAME/Makefile
# setup the readme file
echo -e "Rust console project
----
## Development
\`\`\`sh
make
\`\`\`
" > $APP_NAME/README.md

176
tags Normal file

File diff suppressed because one or more lines are too long