Skip to content

Commit

Permalink
Steve973 contribution - update fp_build.sh to use qmk compile instead
Browse files Browse the repository at this point in the history
  • Loading branch information
sadekbaroudi committed Nov 24, 2024
1 parent 4f1b300 commit 986fe99
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions bin/fp_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ Help()
echo "fp_build.sh -k \"barobord\""
}

get_build_json_path() {
local keyboard_dir="$1"
local userspace_dir=$(qmk config user.overlay_dir -r | cut -d'=' -f2)
local keyboard_path=${keyboard_dir#*/keyboards/}
local userspace_json="${userspace_dir}/${keyboard_path}/fp_build.json"
local keyboard_json="${keyboard_dir}/fp_build.json"

if [[ -f "${userspace_json}" ]]; then
echo "${userspace_json}"
elif [[ -f "${keyboard_json}" ]]; then
echo "${keyboard_json}"
else
echo ""
fi
}


get_valid_keyboards() {
valid_keyboards=""

Expand Down Expand Up @@ -107,12 +124,17 @@ get_valid_keyboards() {
}

build_keyboard_user_input() {
local build_json="${1}/fp_build.json"
local keyboard_base_dir="${1}"
local keyboard_name="${1#${2}/}"
local run_build="${4}"

local build_string="make ${keyboard_base_dir#keyboards\/}:${3}"
local build_json=$(get_build_json_path "${keyboard_base_dir}")
if [[ -z "${build_json}" ]]; then
echo "No fp_build.json found in userspace or keyboard directory"
exit 1
fi

local build_string="qmk compile -kb ${keyboard_base_dir#keyboards\/} -km ${3}"
echo "${build_string}"
# get the total number of paramters
top_level_element_count=$(cat "${build_json}" | jq 'length')
Expand Down Expand Up @@ -141,10 +163,10 @@ build_keyboard_user_input() {
param_names_counter=1
param_names=$(cat "${build_json}" | jq -r ".[${param_iter}].names | @sh" | tr -d \')
for param_name in $param_names; do
if [[ $param_names_counter -eq $user_choice ]]; then
build_string+=" ${param_name}=yes"
fi
((param_names_counter+=1))
if [[ $param_names_counter -eq $user_choice ]]; then
build_string+=" -e ${param_name}=yes"
fi
((param_names_counter+=1))
done
# if it's a single value choice for a parmeter, or "yes or no" question
elif [[ "${param_type}" == "single" ]]; then
Expand All @@ -167,7 +189,7 @@ build_keyboard_user_input() {
fi

param_name=$(cat "${build_json}" | jq -r ".[${param_iter}].name")
build_string+=" ${param_name}=${user_choice}"
build_string+=" -e ${param_name}=${user_choice}"
elif [[ "${param_type}" == "convert-to" ]]; then
# Do nothing, we can skip this for interactive mode
param_name=$(cat "${build_json}" | jq -r ".[${param_iter}].name")
Expand Down Expand Up @@ -195,7 +217,7 @@ build_keyboard_all_combinations() {
local keyboard_name="${1#${2}/}"
local run_build="${4}"

local build_string_base="make ${keyboard_base_dir#keyboards\/}:${3}"
local build_string_base="qmk compile -kb ${keyboard_base_dir#keyboards\/} -km ${3}"

if [[ -n "${5}" && "${5}" != "no" ]]; then
build_string_base+=" CONVERT_TO=${5}"
Expand Down

0 comments on commit 986fe99

Please sign in to comment.