Linux build makefile deployment?

Discuss coding questions, pull requests, and implementation details.
User avatar
noabody
Posts: 6
Joined: Tue Sep 25, 2018 1:32 pm

Linux build makefile deployment?

Post by noabody » Tue Sep 25, 2018 9:58 pm

I build projects from source to get more bleeding edge features and it's always a learning experience. This one is tricky and I haven't quite gotten it to work.
The requirements appear to be:
daggerfall-unity github
Unity Linux 2018.1.2f1

This is my makefile to build on the commandline:

Code: Select all

prefix := /usr
name := DaggerfallUnity
game := $(prefix)/games
bindir := $(prefix)/share/dfunity
icondir := $(prefix)/share/icons/hicolor/scalable/apps

.PHONY: all
all:
	$(HOME)/unity-2018.1.2f1/Editor/Unity -quit -batchmode -logFile stdout.log -buildTarget Linux64 -buildLinux64Player "build/$(name).x86_64"

.PHONY: clean
clean:
	rm -rf build/$(name)_Data
	rm -f "build/Daggerfall Unity Manual.pdf"
	rm -f build/$(name).x86_64

.PHONY: distclean
distclean: clean
	rm -rf Library

.PHONY: install
install:
	mkdir -p $(prefix)/share/applications/
	mkdir -p $(icondir)/
	mkdir -p $(bindir)/
	install -m 755 build/$(name).x86_64 $(bindir)
	install -m 755 dfunity.sh $(bindir)
	cp -r build/$(name)_Data $(bindir)/
	cp "build/Daggerfall Unity Manual.pdf" "$(bindir)/Daggerfall Unity Manual.pdf"
	cp dfunity.desktop $(prefix)/share/applications/dfunity.desktop
	cp dfunity.svg $(icondir)/dfunity.svg
There is a global install directive but it's meant to be used in conjunction with checkinstall as an interface to the package management system.

The makefile appears to work and its distclean option is like a full rebuild.

Right now I can make it into the main game but the initial quest doesn't trigger and I'm thinking that's just an interim issue related to github code refactoring and additions.

I'm not finding much information on how to build the project so maybe the makefile is worthy of discussion or review. It does seem to get the job done.

User avatar
noabody
Posts: 6
Joined: Tue Sep 25, 2018 1:32 pm

Re: Linux build makefile deployment?

Post by noabody » Tue Sep 25, 2018 10:05 pm

As an aside, this is the whole patch I'm using to create relevant files in the github folder sans the icon.

The launcher script is unique because it has to symlink around key folders DaggerfallUnity_Data/StreamingAssets then copy the contents of that folder and the binary itself to a target location (I just use the profile folder).

I parse the files to sym-link into an array, then check for the existence of each before linking. The binary picks up the absolute path of the folder from which it is run. There doesn't seem to be a way around this. (neither sym-link, or cd to the folder and run the link). As a result, I md5 compare global key files to local and replace if they don't match.

It's all really quite hackish and simplistic but, again, it seems to work.

Code: Select all

rm dfunity.sh dfunity.desktop Makefile
patch -p1 < ../dfunity.patch
cp ../unibuild/data/dfunity.svg .
diff notes
http://beta.unity3d.com/download/3709a3f954c1/UnitySetup-2018.1.2f1
http://beta.unity3d.com/download/a6cc294b73ee/UnitySetup-2018.1.9f2
diff  a/dfunity.sh b/dfunity.sh
--- a/dfunity.sh	1969-12-31 17:00:00.000000000 -0700
+++ b/dfunity.sh	2018-08-08 12:41:13.390810041 -0600
@@ -0,0 +1,26 @@
+#!/bin/bash
+gmcfg="$HOME/.config/unity3d/Daggerfall Workshop/Daggerfall Unity"
+glnch="DaggerfallUnity.x86_64"
+i_syms=()
+
+test -d "$gmcfg/DaggerfallUnity_Data" || mkdir -p "$gmcfg/DaggerfallUnity_Data"
+readarray -t i_syms < <(find /usr/share/dfunity -mindepth 1 -maxdepth 2 ! \( -iname '*dfunity.sh' -o -iname '*DaggerfallUnity.x86_64' -o -ipath '*StreamingAssets*' -o -ipath '*DaggerfallUnity_Data' \) -printf '%P\n')
+for i in ${!i_syms[@]}; do
+  test -h "$gmcfg/${i_syms[$i]}" || ln -sf "/usr/share/dfunity/${i_syms[$i]}" "$gmcfg/${i_syms[$i]}"
+done
+unset i_syms
+readarray -t i_syms < <(find /usr/share/dfunity -mindepth 3 -maxdepth 4 -type d \( -iname '*DaggerfallUnity.x86_64' -o -ipath '*StreamingAssets*' \) -printf '%P\n')
+for i in ${!i_syms[@]}; do
+  test -d "$gmcfg/${i_syms[$i]}" || mkdir -p "$gmcfg/${i_syms[$i]}"
+done
+unset i_syms
+readarray -t i_syms < <(find /usr/share/dfunity -mindepth 1 -maxdepth 4 -type f \( -iname '*DaggerfallUnity.x86_64' -o -ipath '*StreamingAssets*' \) -printf '%P\n')
+for i in ${!i_syms[@]}; do
+  if [ -f "$gmcfg/${i_syms[$i]}" ]; then
+    test "$(md5sum "$gmcfg/${i_syms[$i]}" | cut -d' ' -f1)" == "$(md5sum "/usr/share/dfunity/${i_syms[$i]}" | cut -d' ' -f1)" || cp -f "/usr/share/dfunity/${i_syms[$i]}" "$gmcfg/${i_syms[$i]}"
+  else
+    cp "/usr/share/dfunity/${i_syms[$i]}" "$gmcfg/${i_syms[$i]}"
+  fi
+done
+unset i_syms
+(cd "$gmcfg" && "$gmcfg/$glnch")
diff  a/dfunity.desktop b/dfunity.desktop
--- a/dfunity.desktop
+++ b/dfunity.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=Daggerfall Unity
+Comment=Open source recreation of Daggerfall in the Unity engine.
+Keywords=game;console;
+Exec=/usr/share/dfunity/dfunity.sh
+Icon=dfunity
+Terminal=false
+Type=Application
+Categories=GNOME;GTK;Game;
+StartupNotify=false
diff  a/Makefile b/Makefile
--- a/Makefile	1969-12-31 17:00:00.000000000 -0700
+++ b/Makefile	2018-08-08 12:41:13.390810041 -0600
@@ -0,0 +1,44 @@
+prefix := /usr
+name := DaggerfallUnity
+game := $(prefix)/games
+bindir := $(prefix)/share/dfunity
+icondir := $(prefix)/share/icons/hicolor/scalable/apps
+
+.PHONY: all
+all:
+	$(HOME)/Unity/Hub/Editor/2018.1.9f2/Editor/Unity -quit -batchmode -logFile stdout.log -buildTarget linux64 -buildLinux64Player "build/$(name).x86_64"
+
+.PHONY: clean
+clean:
+	rm -rf build/$(name)_Data
+	rm -f "build/Daggerfall Unity Manual.pdf"
+	rm -f build/$(name).x86_64
+
+.PHONY: realclean
+realclean: clean
+	rm -rf Library
+
+.PHONY: distclean
+distclean: realclean
+	rm -rf Assets
+	git reset --hard
+	git checkout . -f
+	git submodule update --checkout -f
+
+.PHONY: install
+install:
+	mkdir -p $(prefix)/share/applications/
+	mkdir -p $(icondir)/
+	mkdir -p $(bindir)/
+	install -m 755 build/$(name).x86_64 $(bindir)
+	install -m 755 dfunity.sh $(bindir)
+	cp -r build/$(name)_Data $(bindir)/
+	cp "build/Daggerfall Unity Manual.pdf" "$(bindir)/Daggerfall Unity Manual.pdf"
+	cp dfunity.desktop $(prefix)/share/applications/dfunity.desktop
+	cp dfunity.svg $(icondir)/dfunity.svg
+
+.PHONY: uninstall
+uninstall:
+	rm -rf $(bindir)
+	rm -f $(prefix)/share/applications/dfunity.desktop
+	rm -f $(icondir)/dfunity.svg
Last edited by noabody on Tue Oct 02, 2018 11:55 am, edited 2 times in total.

User avatar
Interkarma
Posts: 5478
Joined: Sun Mar 22, 2015 1:51 am

Re: Linux build makefile deployment?

Post by Interkarma » Tue Sep 25, 2018 11:27 pm

Welcome to the forums. :) This is really clever!

I'm using Unity Cloud Build to automate and distribute builds, but a local makefile deployment could still be an interesting option. Hopefully others will jump in to discuss and refine with you.

Not sure why the main quest wouldn't start. Provided everything is copied into StreamingAssets at build, it should be offered at start of game. Might be worth checking output log and quest log for any errors with location quest files or compiling quest when game starts.

User avatar
pango
Posts: 2348
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Linux build makefile deployment?

Post by pango » Wed Sep 26, 2018 7:53 pm

Hi noobody,
Just a word to say I tried your Makefile and managed to compile DaggerfallUnity on my box, great stuff!
The game seems to work mostly ok, the HUD seems a little brittle but that may be because it's a development version rather that a build issue.

Shameless plug, if you have missed my announcement here, I've been working on a deployment script to install DaggerfallUnity and the mods I use in any directory; I use it a lot to double check bugs with older releases, or with a different set of mods, etc. The goal is totally different from your use case, but you may find it useful:
https://github.com/petchema/deploy_DFU

Regards,
Pierre.
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
noabody
Posts: 6
Joined: Tue Sep 25, 2018 1:32 pm

Re: Linux build makefile deployment?

Post by noabody » Sat Sep 29, 2018 10:16 pm

Thanks for that link pango! I was looking at your github the other day while trying to sort out the commands that would allow the project to build.

As far as the initial quest not starting, I matched my build version of Unity Unity Linux 2018.1.9f2 to the data files of the most recent live build PreAlpha 0.5 #131 08-Sep-18 and interchanged my binary with the one provided. It worked flawlessly so there's something in the data files. Here is the output of the Player Log both good and bad:

Good:

Code: Select all

Clearing scene cache. start=True
 
(Filename: /home/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

DFTFU 1.7.6: Assigned character Lorana Silinus
 
(Filename: /home/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

Total probability of the weather chances didn't add to 100%! Normalizing values.
 
(Filename: /home/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

Parsing quest __MQSTAGE00
Bad:

Code: Select all

Clearing scene cache. start=True
 
(Filename: /home/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

DFTFU 1.7.6: Assigned character Andrasara Thromlock
 
(Filename: /home/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

NullReferenceException: Object reference not set to an instance of an object
  at DaggerfallConnect.Arena2.BiogFile.ApplyEffects (System.Collections.Generic.List`1 effects, DaggerfallWorkshop.Game.Entity.PlayerEntity playerEntity) [0x00000] in <filename unknown>:0 
  at DaggerfallWorkshop.Game.Utility.StartGameBehaviour.StartNewCharacter () [0x00000] in <filename unknown>:0 
  at DaggerfallWorkshop.Game.Utility.StartGameBehaviour.InvokeStartMethod () [0x00000] in <filename unknown>:0 
  at DaggerfallWorkshop.Game.Utility.StartGameBehaviour.Update () [0x00000] in <filename unknown>:0 
 
(Filename:  Line: -1)

I can load a working save-game with my build regardless so I doubt Linux, non-licensed Unity, or building stand-alone, is any real issue.

Maybe the idea of using a "Makefile" will make stand-alone building more accessible to github users.

User avatar
pango
Posts: 2348
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Linux build makefile deployment?

Post by pango » Sun Sep 30, 2018 6:51 pm

I wonder if I'm seeing the same bug... If when creating a new character I choose "random biography" the game gets stuck at the very beginning (right after it switches to 3D).
If I answer the "12 questions" it starts normally.
I git-bisected it back to commit c4c239e nothing Linux related there.
I wonder if random biography generation is missing or something...
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
pango
Posts: 2348
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Linux build makefile deployment?

Post by pango » Tue Oct 02, 2018 4:45 am

From quick testing, I think it's fixed now (most likely related to https://forums.dfworkshop.net/viewtopic.php?f=24&t=1304)
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
noabody
Posts: 6
Joined: Tue Sep 25, 2018 1:32 pm

Re: Linux build makefile deployment?

Post by noabody » Tue Oct 02, 2018 11:49 am

Works great now, thanks!

Didn't mean to make this into a "trouble building" thread. Was mostly looking to provide a method for local automation.

P.S.
Uniity - Manual: Command Line Arguments
Contains the commands I used to automate.
I chose -buildLinux64Player where the main project uses -buildLinuxUniversalPlayer

If it worked, I attached the icon I'm using.
Attachments
dfunity.png
dfunity.png (101.41 KiB) Viewed 884 times

User avatar
pango
Posts: 2348
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Linux build makefile deployment?

Post by pango » Wed Oct 10, 2018 1:28 am

Hi,
Is there a Linux beta of Unity 2018.2.11f1 Editor?
I'm not even sure where to look...
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Interkarma
Posts: 5478
Joined: Sun Mar 22, 2015 1:51 am

Re: Linux build makefile deployment?

Post by Interkarma » Wed Oct 10, 2018 1:44 am

Updates are usually posted to this thread in Unity forums. Closest Linux editor beta appears to be 2018.2.7f1, which is probably good enough.

https://forum.unity.com/threads/unity-o ... st-3662605

Post Reply