Linux Makefile [based on mechjebs]
chriscamacho opened this issue ยท 4 comments
couldnt be arsed with figuring out git pull, just paste below into a file called Makefile
to use just type make zip at the command line
Makefile for building KAS - by codifies - based on MechJeb Makefile
ifeq ($(OS),Windows_NT)
# do 'Doze stuff
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
#KSPDIR := ${HOME}/.local/share/Steam/SteamApps/common/Kerbal\ Space\ Program
KSPDIR := ${HOME}/.local/share/Steam/steamapps/common/Kerbal\ Space\ Program
MANAGED := ${KSPDIR}/KSP_Data/Managed/
endif
ifeq ($(UNAME_S),Darwin)
KSPDIR := ${HOME}/Library/Application\ Support/Steam/SteamApps/common/Kerbal\ Space\ Program/
MANAGED := ${KSPDIR}/KSP.app/Contents/Data/Managed/
endif
endif
KASFILES := $(wildcard Plugin/.cs)
$(wildcard Plugin/Properties/.cs) \
RESGEN2 := resgen2
GMCS := gmcs
GIT := git
TAR := tar
ZIP := zip
VERSION :=
all: build
info:
@echo "== KAS Build Information =="
@echo " resgen2: ${RESGEN2}"
@echo " gmcs: ${GMCS}"
@echo " git: ${GIT}"
@echo " tar: ${TAR}"
@echo " zip: ${ZIP}"
@echo " KSP Data: ${KSPDIR}"
@echo "================================"
build: build/KAS.dll
build/%.dll: ${KASFILES}
mkdir -p build
#${RESGEN2} -usesourcepath Properties/Resources.resx build/Resources.resources
${GMCS} -t:library -lib:${MANAGED}
-r:Assembly-CSharp,Assembly-CSharp-firstpass,UnityEngine
-out:$@
${KASFILES}
package: build ${KASFILES}
mkdir -p package/KAS/Plugins
cp -r Parts package/KAS/
cp -r Sounds package/KAS/
cp -r Textures package/KAS/
cp build/KAS.dll package/KAS/Plugins/
cp LICENSE.md README.md package/KAS/
%.tar.gz:
tar.gz: package KAS-${VERSION}.tar.gz
%.zip:
zip: package KAS-${VERSION}.zip
clean:
@echo "Cleaning up build and package directories..."
rm -rf build/ package/
install: build
mkdir -p ${KSPDIR}/GameData/KAS/Plugins
cp -r Parts ${KSPDIR}/GameData/KAS/
cp -r Sounds ${KSPDIR}/GameData/KAS/
cp -r Textures ${KSPDIR}/GameData/KAS/
cp build/KAS.dll ${KSPDIR}/GameData/KAS/Plugins/
uninstall: info
rm -rf ${KSPDIR}/GameData/KAS/Plugins
rm -rf ${KSPDIR}/GameData/KAS/Parts
.PHONY : all info build package tar.gz zip clean install uninstall
Using copy/paste for the makefile doesn't work so well. Particularly on Github, where every line you copy is prefixed with the # character and some whitespace. The markdown parser also eats some characters like the * character, which you'll notice has disappeared from the wildcard commands, which will cause them to fail.
I spent some time fixing up the makefile, and I'll submit a pull request if I can get it to work. I ran into a wall when the compiler complained about missing KIS references. I'm not really familiar with C#, but I'm assuming that compiling KAS would also require you to compile KIS first? Or would I just need to pass the path of some of the source files from KIS to gmcs to get this to work?
I just tested not sure which client you're using but copied a working makefile just fine with Firefox...
I've no idea about KIS and havnt touched KAS in a while but its quite possible to do c# without IDE's intelliguess etc getting in the way.... Just pretend its any other language that uses a makefile...!
I just tried it with the latest source: you do need to pass the compiler a copy of KIS.dll in order to compile it from the makefile as it is right now. MechJeb, for example, uses some Kerbal Engineer Redux code, but they put the code they need for compilation in their source tree so you don't have to go out and get/make the KER dll file to compile MechJeb.
There are probably a few ways to go about solving this. Using a git submodule to include the relevant files in the KAS source tree would probably be cleanest. Having the makefile for KAS fetch the source of KIS, compile it, and then use the compiled KIS.dll to compile KAS is another option that works, but is probably inefficient/takes longer. There's probably something else that can be done using the extern keyword (like one might do in C/C++), but from what I've read it doesn't quite work like that in C# and it seems like the worst of those options anyway.
ok I looked again at this...
this assumes you have KIS and KAS cloned in the same directory, and KIS has been compiled...
# Makefile for KAS
#
# If you have KSP in a non-standard directory, be sure to set the environment variable
# $XDG_DATA_HOME (if different from usual), or $KSPDIR to the directory of KSP (if using
# a Steam library in a non-standard location).
#
# Example: if you have a Steam library in the directory /media/partition3, do something like:
# export KSPDIR="/media/partition3/SteamLibrary/SteamApps/common/Kerbal Space Program"
# then, run make as normal.
ifeq ($(OS),Windows_NT)
# It's unlikely that a windows user will use a makefile to compile KAS
# Visual studio is free, after all. torture is usually free
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
ifndef XDG_DATA_HOME
XDG_DATA_HOME := ${HOME}/.local/share
endif
ifndef KSPDIR
KSPDIR := ${XDG_DATA_HOME}/Steam/steamapps/common/Kerbal Space Program
endif
MANAGED := ${KSPDIR}/KSP_Data/Managed/
endif
ifeq ($(UNAME_S),Darwin)
ifndef KSPDIR
KSPDIR := ${HOME}/Library/Application\ Support/Steam/SteamApps/common/Kerbal\ Space\ Program/
endif
MANAGED := ${KSPDIR}/KSP.app/Contents/Data/Managed/
endif
endif
KASFILES := $(wildcard Plugins/Source/*.cs) \
$(wildcard Plugins/Source/Properties/*.cs)
RESGEN2 := resgen2
GMCS := gmcs
GIT := git
TAR := tar
ZIP := zip
VERSION := $(shell ${GIT} describe --tags --always)
all: build
info:
@echo "== KAS Build Information =="
@echo " resgen2: ${RESGEN2}"
@echo " gmcs: ${GMCS}"
@echo " git: ${GIT}"
@echo " tar: ${TAR}"
@echo " zip: ${ZIP}"
@echo " KSP Data: ${KSPDIR}"
@echo " KAS Files: ${KASFILES}"
@echo "================================"
build: build/KAS.dll
build/%.dll: ${KASFILES}
mkdir -p build
${GMCS} -t:library -lib:"${MANAGED}",../KIS/Plugins \
-r:KIS,Assembly-CSharp,Assembly-CSharp-firstpass,UnityEngine \
-out:$@ \
${KASFILES}
package: build ${KASFILES}
mkdir -p package/KAS/Plugins
cp -r Parts package/KAS/
cp -r Sounds package/KAS/
cp -r Textures package/KAS/
cp build/KAS.dll package/KAS/Plugins/
cp LICENSE.md README.md package/KAS/
%.tar.gz:
${TAR} zcf $@ package/KAS
tar.gz: package KAS-${VERSION}.tar.gz
%.zip:
${ZIP} -9 -r $@ package/KAS
zip: package KAS-${VERSION}.zip
clean:
@echo "Cleaning up build and package directories..."
rm -rf build/ package/
install: build
mkdir -p ${KSPDIR}/GameData/KAS/Plugins
cp -r Parts ${KSPDIR}/GameData/KAS/
cp -r Sounds ${KSPDIR}/GameData/KAS/
cp -r Textures ${KSPDIR}/GameData/KAS/
cp build/KAS.dll ${KSPDIR}/GameData/KAS/Plugins/
uninstall: info
rm -rf ${KSPDIR}/GameData/KAS/Plugins
rm -rf ${KSPDIR}/GameData/KAS/Parts
.PHONY : all info build package tar.gz zip clean install uninstall)