Cleaned up the build script

No more commented out code, and the finished product actually runs now.
Also updated the readme to reflect the new build rules.
This commit is contained in:
Ted Meyer 2017-12-21 14:50:29 -08:00
parent f3da424820
commit 89031c1bab
4 changed files with 64 additions and 34 deletions

2
.gitignore vendored
View File

@ -7,3 +7,5 @@ conf.json
*.exe
build/
npm-debug.log
ui/package-lock.json
build/

View File

@ -1,29 +1,49 @@
# Build tool for Factorio Server Manager
#
NODE_ENV:=production
build:
# make sure this project is located within GOPATH, I.E. $GOPATH/src/factorio-server-manager
#TODO add support for a mac build maybe?
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
release := build/factorio-server-manager-linux.zip
else
release := build/factorio-server-manager-windows.zip
endif
# Build Linux release
mkdir build
GOOS=linux GOARCH=amd64 go build -o factorio-server-manager/factorio-server-manager factorio-server-manager/src
# ui/node_modules/webpack/bin/webpack.js ui/webpack.config.js app/bundle.js --progress --profile --colors
cp -r app/ factorio-server-manager/
cp conf.json.example factorio-server-manager/conf.json
zip -r build/factorio-server-manager-linux-x64.zip factorio-server-manager
rm -rf factorio-server-manager
# Build Windows release
GOOS=windows GOARCH=386 go build -o factorio-server-manager/factorio-server-manager.exe factorio-server-manager/src
cp -r app/ factorio-server-manager/
cp conf.json.example factorio-server-manager/conf.json
zip -r build/factorio-server-manager-windows.zip factorio-server-manager
rm -rf factorio-server-manager
build: $(release)
dev:
mkdir dev
GOOS=linux GOARCH=amd64 go build -o factorio-server-linux/factorio-server-manager factorio-server-manager/src
cp -r app/ dev/
cp conf.json.example dev/conf.json
mv factorio-server-linux/factorio-server-manager dev/factorio-server-manager
$(shell mkdir -p build)
build/factorio-server-manager-%.zip: app/bundle.js factorio-server-manager-%
@echo "Packaging Build - $@"
@cp -r app/ factorio-server-manager/
@cp conf.json.example factorio-server-manager/conf.json
@zip -r $@ factorio-server-manager > /dev/null
@rm -r factorio-server-manager
app/bundle.js:
@echo "Building Frontend"
@cd ui && npm install && npm run build
factorio-server-manager-linux: godeps
@echo "Building Backend - Linux"
@GOPATH="${GOPATH}:${PDW}"
@mkdir -p factorio-server-manager
@GOOS=linux GOARCH=amd64 go build -o factorio-server-manager/factorio-server-manager ./src
factorio-server-manager-windows: godeps
@echo "Building Backend - Windows"
@GOPATH="${GOPATH}:${PDW}"
@mkdir -p factorio-server-manager
@GOOS=windows GOARCH=386 go build -o factorio-server-manager/factorio-server-manager.exe ./src
godeps:
@echo "Installing Packages"
@cat gopkglist | xargs go get
gen_release: build/factorio-server-manager-linux.zip build/factorio-server-manager-windows.zip
@echo "Done"
clean:
@echo "Cleaning"
@rm -r build/
@rm app/bundle.js

View File

@ -87,19 +87,23 @@ All api actions are accessible with the /api route. The frontend is accessible
+ Go 1.6
+ NodeJS 4.2.6
#### Building the Go backend
Go Application which manages the Factorio server.
API requests for managing the Factorio server are sent to /api.
The frontend code is served by a HTTP file server running on /.
#### Building Releases
Creates a release zip for windows and linux: (this will install the dependencies listed in gopkgdeps)
```
git clone https://github.com/MajorMJR/factorio-server-manager.git
cd factorio-server-manager
make build
make gen_release
```
#### Building the React frontend
#### Building a Testing Binary:
```
git clone https://github.com/MajorMJR/factorio-server-manager.git
cd factorio-server-manager
make
./factorio-server-manager/factorio-server-manager
```
#### Building the React Frontend alone
Frontend is built using React and the AdminLTE CSS framework. See app/dist/ for AdminLTE included files and license.
The root of the UI application is served at app/index.html. Run the npm build script and the Go application during development to get live rebuilding of the UI code.
@ -108,9 +112,7 @@ All necessary CSS and Javascript files are included for running the UI.
Transpiled bundle.js application is output to app/bundle.js, 'npm run build' script starts webpack to build the React application for development.
```
cd ui/
npm install
npm run build
make app/bundle.js
```
### Building for Windows

6
gopkglist Normal file
View File

@ -0,0 +1,6 @@
github.com/apexskier/httpauth
github.com/go-ini/ini
github.com/gorilla/mux
github.com/gorilla/websocket
github.com/hpcloud/tail
github.com/majormjr/rcon