Skip to content

Commit

Permalink
Add build.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
mczachurski committed Jun 30, 2021
1 parent 950bca8 commit cdf6d8c
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Temporary Items
## Build generated
build/
DerivedData/
output/

## Various settings
*.pbxuser
Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,25 @@ brew install wallpapper
Open your terminal and run following commands.

```bash
git clone https://github.com/mczachurski/wallpapper.git
cd wallpapper
swift build --configuration release
sudo cp .build/release/wallpapper /usr/local/bin
sudo cp .build/release/wallpapper-exif /usr/local/bin
$ git clone https://github.com/mczachurski/wallpapper.git
$ cd wallpapper
$ swift build --configuration release
$ sudo cp .build/release/wallpapper /usr/local/bin
$ sudo cp .build/release/wallpapper-exif /usr/local/bin
```

If you are using swift in version 4.1, please edit `Package.swift` file and put there your version of swift (in first line).

Also you can build using `build.sh` script (it uses `swiftc` instead Swift CLI).

```bash
$ git clone https://github.com/mczachurski/wallpapper.git
$ cd wallpapper
$ ./build.sh
$ sudo cp .output/wallpapper /usr/local/bin
$ sudo cp .output/wallpapper-exif /usr/local/bin
```

Now in the console you can run `wallpapper -h` and you should got a response similar to the following one.

```bash
Expand Down
78 changes: 78 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash

OUTPUT_DIR="output"
WALLPAPPER_DIR="Wallpapper.Objects"
WALLPAPPER_EXIF_DIR="WallpapperExif.Objects"
WALLPAPPER_LIB_DIR="WallpapperLib.Objects"
SRC_PATH="../../Sources"

if [ -d $OUTPUT_DIR ]; then
echo "Remove output directory"
rm -rf $OUTPUT_DIR
fi

echo "Create output directory [$OUTPUT_DIR]"
mkdir $OUTPUT_DIR

echo "Create wallpapper directory [$OUTPUT_DIR/$WALLPAPPER_DIR]"
mkdir $OUTPUT_DIR/$WALLPAPPER_DIR

echo "Create wallpapper exit directory [$OUTPUT_DIR/$WALLPAPPER_EXIF_DIR]"
mkdir $OUTPUT_DIR/$WALLPAPPER_EXIF_DIR

echo "Create wallpapper lib directory [$OUTPUT_DIR/$WALLPAPPER_LIB_DIR]"
mkdir $OUTPUT_DIR/$WALLPAPPER_LIB_DIR

cd $OUTPUT_DIR/$WALLPAPPER_LIB_DIR
echo "Compile WallpapperLib"

swiftc -c \
$SRC_PATH/WallpapperLib/*.swift \
$SRC_PATH/WallpapperLib/*/*.swift \
$SRC_PATH/WallpapperLib/*/*/*.swift \
-parse-as-library \
-module-name WallpapperLib

swiftc \
${SRC_PATH}/WallpapperLib/*.swift \
${SRC_PATH}/WallpapperLib/*/*.swift \
${SRC_PATH}/WallpapperLib/*/*/*.swift \
-emit-module \
-module-name WallpapperLib

# compile Wallpapper
cd ../$WALLPAPPER_DIR

echo "Compile Wallpapper"

swiftc -c \
${SRC_PATH}/Wallpapper/*.swift \
-I../$WALLPAPPER_LIB_DIR \
-module-name wallpapper

cd ..

swiftc -emit-executable \
$WALLPAPPER_LIB_DIR/*.o \
$WALLPAPPER_DIR/*.o \
-o wallpapper

# compile WallpapperExif
cd $WALLPAPPER_EXIF_DIR

echo "Compile WallpapperExif"

swiftc -c \
${SRC_PATH}/WallpapperExif/*.swift \
-I../$WALLPAPPER_LIB_DIR \
-module-name wallpapper_exif

cd ..

swiftc -emit-executable \
$WALLPAPPER_LIB_DIR/*.o \
$WALLPAPPER_EXIF_DIR/*.o \
-o wallpapper-exif

cd ..
echo "All done"

0 comments on commit cdf6d8c

Please sign in to comment.