瀏覽代碼

Made mkconfig a bit more flexible as it allows now to use the first argument

Eiyeron Fulmincendii 10 年之前
父節點
當前提交
0f01ee66b9
共有 1 個文件被更改,包括 26 次插入6 次删除
  1. 26 6
      mkconfig

+ 26 - 6
mkconfig

@@ -1,11 +1,31 @@
 #!/bin/bash
 
+TARGET_LIST=("nspire" "sfml")
+
+create_configuration() {
+	echo "Creating $1 configuration"
+	rm config.mk -f
+	echo "include platform/$1/rules.mk" >> config.mk
+}
+
+is_valid_target() {
+	for item in "${TARGET_LIST[@]}"; do
+		[[ $1 == "$item" ]] && return 0
+	done
+	return 1
+}
+
 old_PS3=PS3
 PS3='#? '
-echo "Platform:"
-select TARGET in nspire sfml; do
-	rm config.mk -f
-	echo "include platform/$TARGET/rules.mk" >> config.mk
-	[[ $TARGET == "" ]] || break
-done
+# If $1 isn't set
+if [[ -z ${1+z} ]]; then
+	echo "Platform:"
+	select TARGET in "${TARGET_LIST[@]}"; do
+		create_configuration "$TARGET"
+		[[ $TARGET == "" ]] || break
+	done
+# else use it as a platform selection
+else
+	is_valid_target "$1" && create_configuration "$1"
+fi
 PS3=old_PS3