diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..43109d0 --- /dev/null +++ b/Makefile @@ -0,0 +1,55 @@ +TEMPORARY_FOLDER=/tmp/Apous.dst +PREFIX=/usr/local +BUILD_TOOL=xcodebuild + +XCODEFLAGS=-project 'apous.xcodeproj' -scheme 'apous' DSTROOT=$(TEMPORARY_FOLDER) + +APOUS_EXECUTABLE=$(TEMPORARY_FOLDER)/apous + +FRAMEWORKS_FOLDER=/Library/Frameworks +BINARIES_FOLDER=/usr/local/bin + +VERSION_STRING=v0.2.0 +COMPONENTS_PLIST=misc/Components.plist + +OUTPUT_PACKAGE=Apous.pkg + +.PHONY: all bootstrap clean install package test uninstall + +all: bootstrap + $(BUILD_TOOL) $(XCODEFLAGS) build + +bootstrap: + misc/scripts/bootstrap.sh + +test: clean bootstrap + $(BUILD_TOOL) $(XCODEFLAGS) test + +clean: + rm -f "$(OUTPUT_PACKAGE)" + rm -rf "$(TEMPORARY_FOLDER)" + $(BUILD_TOOL) $(XCODEFLAGS) clean + +install: package + sudo installer -pkg "$(TEMPORARY_FOLDER)/$(OUTPUT_PACKAGE)" -target / + +uninstall: + rm -f "$(BINARIES_FOLDER)/apous" + +installables: clean bootstrap + $(BUILD_TOOL) $(XCODEFLAGS) install + + mkdir -p "$(TEMPORARY_FOLDER)$(BINARIES_FOLDER)" + +prefix_install: installables + mkdir -p "$(PREFIX)/Frameworks" "$(PREFIX)/bin" + cp -f "$(TEMPORARY_FOLDER)$(BINARIES_FOLDER)/apous" "$(PREFIX)/bin/" + +package: installables + pkgbuild \ + --component-plist "$(COMPONENTS_PLIST)" \ + --identifier "io.owensd.apous" \ + --install-location "/" \ + --root "$(TEMPORARY_FOLDER)" \ + --version "$(VERSION_STRING)" \ + "$(TEMPORARY_FOLDER)/$(OUTPUT_PACKAGE)" \ No newline at end of file diff --git a/apous.xcodeproj/project.pbxproj b/apous.xcodeproj/project.pbxproj index 7c9ba22..a945ea8 100644 --- a/apous.xcodeproj/project.pbxproj +++ b/apous.xcodeproj/project.pbxproj @@ -12,7 +12,6 @@ 7D3AC3461B49F99B0068CC83 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D3AC3451B49F99B0068CC83 /* Utils.swift */; }; 7D3AC3481B49FE170068CC83 /* ErrorCodes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D3AC3471B49FE170068CC83 /* ErrorCodes.swift */; }; 7D3AC34A1B4A37BC0068CC83 /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D3AC3491B4A37BC0068CC83 /* Tools.swift */; }; - 7DD671141B4BD94400C5DB6D /* apous in Deploy Locally */ = {isa = PBXBuildFile; fileRef = 7D0373351B49021700E2711D /* apous */; }; 7DF997441B4B33A200E90F56 /* VersionInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DF997431B4B33A200E90F56 /* VersionInfo.swift */; }; 7DF997511B4B4A6900E90F56 /* Tools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D3AC3491B4A37BC0068CC83 /* Tools.swift */; }; 7DF9988C1B4B72FD00E90F56 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D3AC3451B49F99B0068CC83 /* Utils.swift */; }; @@ -46,17 +45,6 @@ ); runOnlyForDeploymentPostprocessing = 1; }; - 7D03733F1B49026800E2711D /* Deploy Locally */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "$(SRCROOT)/bin"; - dstSubfolderSpec = 0; - files = ( - 7DD671141B4BD94400C5DB6D /* apous in Deploy Locally */, - ); - name = "Deploy Locally"; - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -181,7 +169,6 @@ 7D0373311B49021700E2711D /* Sources */, 7D0373321B49021700E2711D /* Frameworks */, 7D0373331B49021700E2711D /* CopyFiles */, - 7D03733F1B49026800E2711D /* Deploy Locally */, 7DE115081B4C4A9100B198FB /* Package for GitHub Release */, ); buildRules = ( @@ -275,7 +262,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "mkdir -p releases\nrm -f $SRCROOT/releases/$TARGET_NAME.zip\nzip -j $SRCROOT/releases/$TARGET_NAME.zip $SRCROOT/bin/$TARGET_NAME"; + shellScript = "#mkdir -p releases\n#rm -f $SRCROOT/releases/$TARGET_NAME.zip\n#zip -j $SRCROOT/releases/$TARGET_NAME.zip $SRCROOT/bin/$TARGET_NAME"; }; 7DF9988B1B4B4C5600E90F56 /* Copy Samples */ = { isa = PBXShellScriptBuildPhase; diff --git a/apous.xcodeproj/xcshareddata/xcschemes/apous.xcscheme b/apous.xcodeproj/xcshareddata/xcschemes/apous.xcscheme new file mode 100644 index 0000000..95e87bf --- /dev/null +++ b/apous.xcodeproj/xcshareddata/xcschemes/apous.xcscheme @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/misc/Components.plist b/misc/Components.plist new file mode 100644 index 0000000..2176fc9 --- /dev/null +++ b/misc/Components.plist @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/misc/scripts/bootstrap.sh b/misc/scripts/bootstrap.sh new file mode 100755 index 0000000..d89fb73 --- /dev/null +++ b/misc/scripts/bootstrap.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +export SCRIPT_DIR=$(dirname "$0") + +## +## Bootstrap Process +## + +main () +{ + local submodules=$(git submodule status) + local result=$? + + if [ "$result" -ne "0" ] + then + exit $result + fi + + if [ -n "$submodules" ] + then + echo "*** Updating submodules..." + update_submodules + fi +} + +bootstrap_submodule () +{ + local bootstrap="script/bootstrap" + + if [ -e "$bootstrap" ] + then + echo "*** Bootstrapping $name..." + "$bootstrap" >/dev/null + else + update_submodules + fi +} + +update_submodules () +{ + git submodule sync --quiet && git submodule update --init && git submodule foreach --quiet bootstrap_submodule +} + +export -f bootstrap_submodule +export -f update_submodules + +main \ No newline at end of file