Skip to content

Commit

Permalink
Made the change to use lib.rs (#2)
Browse files Browse the repository at this point in the history
* Made the change to use lib.rs

* Removed unnecessary comment

* Improved compilation script
  • Loading branch information
margual56 authored Nov 3, 2022
1 parent 712e56a commit b5295de
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 33 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
**/target
**/bin
run_debug.sh
**/.fleet/
**/.fleet/
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "connect4"
version = "0.1.0"
version = "1.0.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
21 changes: 10 additions & 11 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

CARGO_DIR=$HOME/.cargo/bin

echo Compiling linux gnu
$CARGO_DIR/cross build --target x86_64-unknown-linux-gnu --release

echo Compiling linux musl
$CARGO_DIR/cross build --target x86_64-unknown-linux-musl --release

echo Compiling windows
$CARGO_DIR/cross build --target x86_64-pc-windows-gnu --release

echo Compiling android
$CARGO_DIR/cross build --target aarch64-linux-android --release
targets=(x86_64-unknown-linux-gnu x86_64-unknown-linux-musl x86_64-pc-windows-gnu aarch64-linux-android)
mkdir ./bin

for target in "${targets[@]}"
do
echo Compiling $target
$CARGO_DIR/cross build --target $target --release || exit
mkdir ./bin/$target
mv "./target/$target/release" "./bin/$target"
done

4 changes: 2 additions & 2 deletions src/lib/board.rs → src/board.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tabled::{builder::Builder, Style};

use super::{BoardError, Chip};
use crate::chip::Chip;
use crate::errors::BoardError;

// Chips in a row needed to win
pub const CHIPS_IN_A_ROW: i32 = 4;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/lib/client.rs → src/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::io::{Read, Write};
use std::net::TcpStream;

use crate::lib::Board;
use crate::board::Board;

pub fn run(ip: String, port: String) {
match TcpStream::connect(ip + ":" + &port) {
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod board;
mod chip;
pub mod client;
mod errors;
pub mod server;
9 changes: 0 additions & 9 deletions src/lib/mod.rs

This file was deleted.

6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub mod lib;

use clap::Parser;
use inquire::Select;
use lib::{client, server};

use connect4::client;
use connect4::server;

#[derive(Parser)]
struct Cli {
Expand Down
5 changes: 2 additions & 3 deletions src/lib/server.rs → src/server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::lib::Chip;

use super::Board;
use crate::chip::Chip;
use crate::board::Board;
use std::io::{Error, Read, Write};
use std::net::{Shutdown, TcpListener, TcpStream};

Expand Down

0 comments on commit b5295de

Please sign in to comment.