From ff19d727b7c74d621072faa51f4f77122d3ea696 Mon Sep 17 00:00:00 2001 From: "M.Sz" Date: Mon, 17 Apr 2023 07:06:29 +0000 Subject: [PATCH 1/5] Revert "Revert "generattor: add --cflags command line flag"" This reverts commit 2ae35c8b4673a6f9b683b4ac8d838fd3f34b4237. --- generator/generator.sh | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/generator/generator.sh b/generator/generator.sh index e2840c5..794efe1 100755 --- a/generator/generator.sh +++ b/generator/generator.sh @@ -16,10 +16,38 @@ # arg[2] options as words in one string: internal for imgui_internal generation, freetype for freetype generation, comments for comments generation, nochar to skip char* function version, noimstrv to skip imstrv # examples: "" "internal" "internal freetype" "comments internal" # arg[3..n] name of implementations to generate and/or CLFLAGS (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32) +# +#!/bin/bash + +# parse command line arguments +# ref: https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash +POSITIONAL_ARGS=() + +while [[ $# -gt 0 ]]; do + case $1 in + -c|--cflags) + CFLAGS="$2" + shift # past argument + shift # past value + ;; + -*|--*) + echo "Unknown option $1" + exit 1 + ;; + *) + POSITIONAL_ARGS+=("$1") # save positional arg + shift # past argument + ;; + esac +done + +set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then suffix='.exe' fi -luajit$suffix ./generator.lua gcc "internal noimstrv" glfw opengl3 opengl2 sdl2 "$@" +echo "CFLAGS: " $CFLAGS + +luajit$suffix ./generator.lua gcc "internal noimstrv" glfw opengl3 opengl2 sdl2 $CFLAGS From fa81118e09c4a7285a8e00024ac246e079729221 Mon Sep 17 00:00:00 2001 From: "M.Sz" Date: Mon, 17 Apr 2023 07:13:26 +0000 Subject: [PATCH 2/5] generator: add -t/--tagret options --- generator/generator.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/generator/generator.sh b/generator/generator.sh index 794efe1..4935806 100755 --- a/generator/generator.sh +++ b/generator/generator.sh @@ -1,4 +1,4 @@ -#!/usr/bin/sh +#!/bin/bash # this script must be executed in this directory # all the output goes to generator/output folder @@ -30,6 +30,11 @@ while [[ $# -gt 0 ]]; do shift # past argument shift # past value ;; + -t|--target) + TARGETS="$2" + shift # past argument + shift # past value + ;; -*|--*) echo "Unknown option $1" exit 1 @@ -49,5 +54,6 @@ then fi echo "CFLAGS: " $CFLAGS +echo "TARGETS: " $TARGETS -luajit$suffix ./generator.lua gcc "internal noimstrv" glfw opengl3 opengl2 sdl2 $CFLAGS +luajit$suffix ./generator.lua gcc "internal noimstrv $TARGETS" glfw opengl3 opengl2 sdl2 $CFLAGS From e2093ffbc111fd49b766d4d3f0dc0b6239511d2e Mon Sep 17 00:00:00 2001 From: "M.Sz" Date: Mon, 17 Apr 2023 07:15:31 +0000 Subject: [PATCH 3/5] generator: remove unnecessary header comment --- generator/generator.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/generator/generator.sh b/generator/generator.sh index 4935806..5a022ee 100755 --- a/generator/generator.sh +++ b/generator/generator.sh @@ -17,7 +17,6 @@ # examples: "" "internal" "internal freetype" "comments internal" # arg[3..n] name of implementations to generate and/or CLFLAGS (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32) # -#!/bin/bash # parse command line arguments # ref: https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash From 0c22b34cb6005af034f2ac3dd18129228e656886 Mon Sep 17 00:00:00 2001 From: "M.Sz" Date: Mon, 17 Apr 2023 10:13:09 +0000 Subject: [PATCH 4/5] generator: set default values --- generator/generator.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generator/generator.sh b/generator/generator.sh index 5a022ee..cc92ac5 100755 --- a/generator/generator.sh +++ b/generator/generator.sh @@ -22,6 +22,9 @@ # ref: https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash POSITIONAL_ARGS=() +TARGETS="internal noimstrv" +CFLAGS="glfw opengl3 opengl2 sdl2" + while [[ $# -gt 0 ]]; do case $1 in -c|--cflags) @@ -55,4 +58,4 @@ fi echo "CFLAGS: " $CFLAGS echo "TARGETS: " $TARGETS -luajit$suffix ./generator.lua gcc "internal noimstrv $TARGETS" glfw opengl3 opengl2 sdl2 $CFLAGS +luajit$suffix ./generator.lua gcc "$TARGETS" $CFLAGS From 9ac8211a3dcd76e9b6f0ce9610d8c6cc51a8aab3 Mon Sep 17 00:00:00 2001 From: gucio321 <73652197+gucio321@users.noreply.github.com> Date: Mon, 17 Apr 2023 17:13:38 +0200 Subject: [PATCH 5/5] generator: add help page --- generator/generator.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/generator/generator.sh b/generator/generator.sh index cc92ac5..bafb063 100755 --- a/generator/generator.sh +++ b/generator/generator.sh @@ -25,6 +25,17 @@ POSITIONAL_ARGS=() TARGETS="internal noimstrv" CFLAGS="glfw opengl3 opengl2 sdl2" +help() { + cat <