2023-04-17 07:13:26 +00:00
#!/bin/bash
2019-07-30 23:15:39 -04:00
# this script must be executed in this directory
# all the output goes to generator/output folder
# .cpp and .h files:
# cimgui.h and cimgui.cpp with gcc preprocess
# cimgui_nopreprocess.h and cimgui_nopreprocess.cpp generated without preprocess
# cimgui_impl.h with implementation function cdefs
# lua and json files:
# definitions.lua for function definitions
# structs_and_enums.lua with struct and enum information-definitions
# impl_definitions.lua for implementation function definitions
#process files
2020-04-14 11:05:52 +02:00
# arg[1] compiler name gcc, clang, or cl
2023-03-24 17:23:28 +01:00
# 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
2022-10-06 11:11:50 +02:00
# examples: "" "internal" "internal freetype" "comments internal"
2020-10-29 16:31:38 +00:00
# arg[3..n] name of implementations to generate and/or CLFLAGS (e.g. -DIMGUI_USER_CONFIG or -DIMGUI_USE_WCHAR32)
2023-04-17 07:06:29 +00:00
#
# parse command line arguments
# ref: https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash
POSITIONAL_ARGS = ( )
2023-04-17 10:13:09 +00:00
TARGETS = "internal noimstrv"
CFLAGS = "glfw opengl3 opengl2 sdl2"
2023-04-17 07:06:29 +00:00
while [ [ $# -gt 0 ] ] ; do
case $1 in
-c| --cflags)
CFLAGS = " $2 "
shift # past argument
shift # past value
; ;
2023-04-17 07:13:26 +00:00
-t| --target)
TARGETS = " $2 "
shift # past argument
shift # past value
; ;
2023-04-17 07:06:29 +00:00
-*| --*)
echo " Unknown option $1 "
exit 1
; ;
*)
POSITIONAL_ARGS += ( " $1 " ) # save positional arg
shift # past argument
; ;
esac
done
set -- " ${ POSITIONAL_ARGS [@] } " # restore positional parameters
2022-12-15 10:16:41 +02:00
if [ [ " $OSTYPE " = = "cygwin" || " $OSTYPE " = = "msys" || " $OSTYPE " = = "win32" ] ] ;
then
suffix = '.exe'
fi
2023-04-17 07:06:29 +00:00
echo "CFLAGS: " $CFLAGS
2023-04-17 07:13:26 +00:00
echo "TARGETS: " $TARGETS
2023-04-17 07:06:29 +00:00
2023-04-17 10:13:09 +00:00
luajit$suffix ./generator.lua gcc " $TARGETS " $CFLAGS