#!/bin/bash
# dev/package/git - package git version control support

set -e

lib_load 'sys/tool/git'


######
# Library Settings

dev_package_git_config_init() {
	lib_setting_vars package_git_required
	lib_setting_vars -ro package_repodir package_objdir package_gendir

	dev_package_git_config_check
}

dev_package_git_config_check() {
	package_git_required=${package_git_required:-true}

	local repodir
	repodir=$(package_repodir_locate)
	if [ -z "$repodir" ]; then
		repodir=$(git_repo_dir)
		if [ -z "$repodir" ]; then
			if $package_git_required; then
				error "unable to locate package source tree"
			else
				repodir=$PWD
			fi
		fi
	fi

	package_repodir=${package_repodir:-$repodir}
	package_objdir=${package_objdir:-$package_repodir/obj}
	package_gendir=${package_gendir:-$package_objdir/gen}
}

package_repodir_locate() {
	local i=20
	local dir=$PWD
	while [ ! -f "$dir/Makefile.i7.in" ]; do
		dir="$dir/.."
		i=$((i - 1))
		if [ $i -eq 0 ]; then
			error "unable to find source tree root"
			return 1
		fi
	done
	realpath "$dir"
}

View the Developer Guide Index

View the Reference Manual Index


Generated on Fri Jul 28 14:35:25 PDT 2017 by mcsh d14 v0.23.0.