0daea2d7ec6201a1ac209767fe898059cc065390 — octaspire 7 months ago 3c99d84 v0.483.0
MSVC build script: fix and add summary

* Fix MSVC build script; .lib files were generated
  in wrong place and the script didn't work after
  being run only once. After being run the second
  time, it started to work.

* Add summary with games and ANSI colors.

* Fix MSVC compiler warnings from nuklear plugin, sdl2 plugin
  and chipmunk plugin.

* Fix some of the MSVC compiler warnings from the external
  Chipmunk library.
M dev/include/octaspire/dern/octaspire_dern_config.h => dev/include/octaspire/dern/octaspire_dern_config.h +1 -1
@@ 18,7 18,7 @@ #define OCTASPIRE_DERN_CONFIG_H
  
  #define OCTASPIRE_DERN_CONFIG_VERSION_MAJOR "0"
- #define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "482"
+ #define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "483"
  #define OCTASPIRE_DERN_CONFIG_VERSION_PATCH "0"
  
  #define OCTASPIRE_DERN_CONFIG_VERSION_STR "Octaspire Dern version " \

M release/how-to-build/windows-msvc.py => release/how-to-build/windows-msvc.py +49 -6
@@ 36,6 36,11 @@ import zipfile
  
  ###############################################################################
+ # Global variables                                                            #
+ ###############################################################################
+ summary = []
+ 
+ ###############################################################################
  # Helper functions                                                            #
  ###############################################################################
  def octaspire_copydir(p):


@@ 73,7 78,7 @@ octaspire_copydir(copyFromPath)
      print('')
  
- def octaspire_build(resultName, desc, buildCommand, *runExamples):
+ def octaspire_build(resultName, desc, buildCommand, isExample, *runExamples):
      print('- Building   {}\n\t     {}'.format(resultName, desc))
      print('-----------------------------------------------------')
      os.system(buildCommand)


@@ 81,8 86,28 @@ if not os.path.isfile(resultName):
          print('\t ERROR {} FAILED TO BUILD'.format(resultName))
          sys.exit(1)
+     examples = ''
      for a in runExamples:
          print('             Run or test like this: {}'.format(a))
+         examples += '\n\t{}'.format(a)
+     print('')
+     ansiColor = '\033[1;32;31m'
+     if isExample:
+         ansiColor = '\033[1;32;32m'
+     summary.append('{}{}\033[0m {}'.format(ansiColor, desc, examples))
+ 
+ def octaspire_game(resultName, *runExamples):
+     examples = ''
+     for a in runExamples:
+         examples += '\n\t{}'.format(a)
+     ansiColor = '\033[1;32;33m'
+     summary.append('{}{}\033[0m {}'.format(ansiColor, resultName, examples))
+ 
+ def octaspire_summary():
+     print('\nSUMMARY OF \033[1;32;31mTOOLS\033[0m, \033[1;32;32mEXAMPLES\033[0m AND \033[1;32;33mGAMES\033[0m AND HOW TO RUN THEM')
+     print('========================================================')
+     for i in summary:
+         print(i)
      print('')
  
  def octaspire_create_lib_file(dllFileName):


@@ 156,9 181,6 @@ 'SDL2_ttf-2.0.14-win32-x86.zip',
          'SDL2_ttf-2.0.14-win32-x86',
          '')
-     octaspire_create_lib_file('SDL2_image.dll')
-     octaspire_create_lib_file('SDL2_mixer.dll')
-     octaspire_create_lib_file('SDL2_ttf.dll')
      # Get dependency: SDL2_ttf headers
      octaspire_depend(
          'https://www.libsdl.org/projects/SDL_ttf/release/',


@@ 189,6 211,10 @@ 'SDL2_image-2.0.4.zip',
          'SDL2_image-2.0.4',
          '')
+     # Generate some required .lib files for few dependencies
+     octaspire_create_lib_file('SDL2_image.dll')
+     octaspire_create_lib_file('SDL2_mixer.dll')
+     octaspire_create_lib_file('SDL2_ttf.dll')
      ###########################################################################
      # Build programs, plugins and examples                                    #
      ###########################################################################


@@ 197,36 223,42 @@ 'octaspire-dern-unit-test-runner.exe',
          'stand alone unit test runner',
          cl + cflags + '/DOCTASPIRE_DERN_AMALGAMATED_UNIT_TEST_IMPLEMENTATION octaspire-dern-amalgamated.c /link /out:octaspire-dern-unit-test-runner.exe',
+         False,
          'octaspire-dern-unit-test-runner.exe')
      # Build interactive Dern REPL
      octaspire_build(
          'octaspire-dern-repl.exe',
          'interactive Dern REPL',
          cl + cflags + '/DOCTASPIRE_DERN_AMALGAMATED_REPL_IMPLEMENTATION octaspire-dern-amalgamated.c /link /out:octaspire-dern-repl.exe',
+         False,
          'octaspire-dern-repl.exe')
      # Build Dern ncurses plugin
      octaspire_build(
          'libdern_ncurses.dll',
          'Dern ncurses plugin (uses pdcurses)',
          cl + cflags + '/I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_ncurses.c /link pdcurses.lib /out:libdern_ncurses.dll',
+         True,
          'octaspire-dern-repl.exe examples\dern-ncurses-example.dern')
      # Build Dern SDL2 plugin
      octaspire_build(
          'libdern_sdl2.dll',
          'Dern SDL2 plugin (uses SDL2, SDL2_image, SDL2_mixer and SDL2_ttf)',
          cl + cflags + '/I. /ISDL2-2.0.9\include /ISDL2_image-2.0.4 /ISDL2_mixer-2.0.4 /ISDL2_ttf-2.0.14 /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /DOCTASPIRE_DERN_SDL2_PLUGIN_USE_OPENGL2_LIBRARY /DOCTASPIRE_DERN_SDL2_PLUGIN_USE_SDL_IMAGE_LIBRARY /DOCTASPIRE_DERN_SDL2_PLUGIN_USE_SDL_MIXER_LIBRARY /DOCTASPIRE_DERN_SDL2_PLUGIN_USE_SDL_TTF_LIBRARY /Dmain=SDL_main /LD plugins\dern_sdl2.c /link SDL2.lib SDL2_mixer.lib SDL2_ttf.lib SDL2_image.lib opengl32.lib glu32.lib /out:libdern_sdl2.dll',
+         True,
          'octaspire-dern-repl.exe examples\dern-sdl2-example.dern')
      # Build Dern Nuklear plugin
      octaspire_build(
          'libdern_nuklear.dll',
          'Dern Nuklear plugin',
          cl + cflags + '/I. /Iplugins/external/nuklear /ISDL2-2.0.9\include /ISDL2_image-2.0.4 /ISDL2_mixer-2.0.4 /ISDL2_ttf-2.0.14 /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /DOCTASPIRE_DERN_SDL2_PLUGIN_USE_OPENGL2_LIBRARY /DOCTASPIRE_DERN_SDL2_PLUGIN_USE_SDL_IMAGE_LIBRARY /DOCTASPIRE_DERN_SDL2_PLUGIN_USE_SDL_MIXER_LIBRARY /DOCTASPIRE_DERN_SDL2_PLUGIN_USE_SDL_TTF_LIBRARY /LD plugins\dern_nuklear.c /link SDL2.lib SDL2_mixer.lib SDL2_ttf.lib SDL2_image.lib opengl32.lib glu32.lib /out:libdern_nuklear.dll',
+         True,
          'octaspire-dern-repl.exe examples\dern-nuklear-example.dern')
      # Build Dern socket plugin
      octaspire_build(
          'libdern_socket.dll',
          'Dern socket plugin',
          cl + cflags + '/I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_socket.c /link ws2_32.lib /out:libdern_socket.dll',
+         True,
          'octaspire-dern-repl.exe -I examples examples\irc-client-ncurses.dern',
          'octaspire-dern-repl.exe -I examples examples\irc-client-nuklear.dern')
      # Build Dern easing plugin


@@ 234,18 266,21 @@ 'libdern_easing.dll',
          'Dern easing plugin',
          cl + cflags + '/I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_easing.c /link /out:libdern_easing.dll',
+         True,
          'octaspire-dern-repl.exe examples\dern-easing-example.dern')
      # Build Dern animation plugin
      octaspire_build(
          'libdern_animation.dll',
          'Dern animation plugin',
          cl + cflags + '/I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_animation.c /link /out:libdern_animation.dll',
+         True,
          'octaspire-dern-repl.exe examples\dern-animation-example.dern')
      # Build Dern dir plugin
      octaspire_build(
          'libdern_dir.dll',
          'Dern directory plugin',
          cl + cflags + '/W2 /I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_dir.c /link /out:libdern_dir.dll',
+         True,
          'octaspire-dern-repl.exe examples\dern-dir-example.dern')
      print('Building Chipmunk library...')
      os.system(cl + cflagsChipmunk + '/Iplugins/external/chipmunk/include /Iplugins/external/chipmunk/include/chipmunk /LD plugins/external/chipmunk/src/*.c /link /out:libchipmunk.dll')


@@ 254,27 289,35 @@ 'libdern_chipmunk.dll',
          'Dern chipmunk plugin',
          cl + cflags + '/I. /Iplugins/external/chipmunk/include/ /Iplugins/external/chipmunk/include/chipmunk /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\dern_chipmunk.c plugins\external\sqlite3\sqlite3.c /link chipmunk.lib /out:libdern_chipmunk.dll',
+         True,
          'octaspire-dern-repl.exe examples\dern-chipmunk-example.dern')
-     #print('Compiling SQLite3...')
-     #os.system(cl + cflags + '/Iplugins/external/sqlite3 plugins/external/sqlite3/sqlite3.c')
      # Build Dern SQLite3 plugin
      octaspire_build(
          'libdern_sqlite3.dll',
          'Dern SQLite3 plugin',
          cl + cflags + '/I. /Iplugins/external/sqlite3/ /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD plugins\external\sqlite3\sqlite3.c plugins\dern_sqlite3.c /link /out:libdern_sqlite3.dll',
+         True,
          'octaspire-dern-repl.exe examples\dern-sqlite3-example.dern')
      # Build embedding example
      octaspire_build(
          'embedding-example.exe',
          'embedding example',
          cl + cflags + '/I. /DOCTASPIRE_DERN_CONFIG_BINARY_PLUGINS examples\embedding-example.c /link /out:embedding-example.exe',
+         True,
          'embedding-example.exe')
      # Build binary library example
      octaspire_build(
          'libmylib.dll',
          'binary library example',
          cl + cflags + '/I. /DOCTASPIRE_DERN_AMALGAMATED_IMPLEMENTATION /LD examples\mylib.c /link /out:libmylib.dll',
+         True,
          'octaspire-dern-repl.exe examples\use-mylib.dern')
+     # Add information about games into summary
+     octaspire_game('octaspire-maze',      'octaspire-dern-repl.exe games\octaspire-maze.dern')
+     octaspire_game('octaspire-lightcube', 'octaspire-dern-repl.exe games\octaspire-lightcube.dern')
+     octaspire_game('octaspire-bounce',    'octaspire-dern-repl.exe games\octaspire-bounce.dern')
+     # Print summary of runnable examples and how to run them
+     octaspire_summary()
  
  if __name__ == '__main__':
      main(sys.argv[1:])

M release/octaspire-dern-amalgamated.c => release/octaspire-dern-amalgamated.c +1 -1
@@ 26336,7 26336,7 @@ #define OCTASPIRE_DERN_CONFIG_H
  
  #define OCTASPIRE_DERN_CONFIG_VERSION_MAJOR "0"
- #define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "482"
+ #define OCTASPIRE_DERN_CONFIG_VERSION_MINOR "483"
  #define OCTASPIRE_DERN_CONFIG_VERSION_PATCH "0"
  
  #define OCTASPIRE_DERN_CONFIG_VERSION_STR "Octaspire Dern version " \

M release/plugins/dern_chipmunk.c => release/plugins/dern_chipmunk.c +2 -1
@@ 2618,7 2618,8 @@ }
  
      cpCollisionType const collisionType =
-         octaspire_dern_value_as_number_get_value(secondArg);
+         (cpCollisionType const)octaspire_dern_value_as_number_get_value(
+             secondArg);
  
      // (Lambda) function for postSolve callback
  

M release/plugins/dern_nuklear.c => release/plugins/dern_nuklear.c +10 -10
@@ 835,7 835,7 @@ return numberOrErrorMin.unpushedError;
      }
  
-     int const minVal = numberOrErrorMin.number;
+     int const minVal = (int const)numberOrErrorMin.number;
  
      // value
  


@@ 853,7 853,7 @@ return numberOrErrorValue.unpushedError;
      }
  
-     int  valueVal = numberOrErrorValue.number;
+     int  valueVal = (int)numberOrErrorValue.number;
  
      // max
  


@@ 871,7 871,7 @@ return numberOrErrorMax.unpushedError;
      }
  
-     int const maxVal = numberOrErrorMax.number;
+     int const maxVal = (int const)numberOrErrorMax.number;
  
      // step
  


@@ 889,7 889,7 @@ return numberOrErrorStep.unpushedError;
      }
  
-     int const stepVal = numberOrErrorStep.number;
+     int const stepVal = (int const)numberOrErrorStep.number;
  
      // Show the widget.
  


@@ 1307,7 1307,7 @@ return numberOrError.unpushedError;
      }
  
-     int const len = numberOrError.number;
+     int const len = (int const)numberOrError.number;
  
      if (len < 2)
      {


@@ 1756,7 1756,7 @@ return numberOrErrorNumColumns.unpushedError;
      }
  
-     int const columns = numberOrErrorNumColumns.number;
+     int const columns = (int const)numberOrErrorNumColumns.number;
  
      nk_layout_row_dynamic(ctx, height, columns);
  


@@ 1855,7 1855,7 @@ return numberOrErrorItemWidth.unpushedError;
      }
  
-     int const item_width = numberOrErrorItemWidth.number;
+     int const item_width = (int const)numberOrErrorItemWidth.number;
  
      // columns
  


@@ 1873,7 1873,7 @@ return numberOrErrorColumns.unpushedError;
      }
  
-     int const columns = numberOrErrorColumns.number;
+     int const columns = (int const)numberOrErrorColumns.number;
  
      nk_layout_row_static(ctx, height, item_width, columns);
  


@@ 2001,7 2001,7 @@ return numberOrErrorColumns.unpushedError;
      }
  
-     int const columns = numberOrErrorColumns.number;
+     int const columns = (int const)numberOrErrorColumns.number;
  
      if (columns <= 0)
      {


@@ 2440,7 2440,7 @@ return numberOrError.unpushedError;
          }
  
-         numbers[i] = numberOrError.number;
+         numbers[i] = (int)numberOrError.number;
      }
  
      struct nk_color *color = octaspire_allocator_malloc(

M release/plugins/dern_sdl2.c => release/plugins/dern_sdl2.c +7 -7
@@ 4357,7 4357,7 @@ octaspire_dern_value_helper_get_type_as_c_string(arg->typeTag));
      }
  
-     x = octaspire_dern_value_as_number_get_value(arg);
+     x = (int)octaspire_dern_value_as_number_get_value(arg);
  
      // y
      arg = octaspire_dern_value_as_vector_get_element_at_const(arguments, 1);


@@ 4376,7 4376,7 @@ octaspire_dern_value_helper_get_type_as_c_string(arg->typeTag));
      }
  
-     y = octaspire_dern_value_as_number_get_value(arg);
+     y = (int)octaspire_dern_value_as_number_get_value(arg);
  
  #ifdef OCTASPIRE_DERN_SDL2_PLUGIN_USE_OPENGL2_LIBRARY
      glFlush();


@@ 4810,7 4810,7 @@ mouseYinGL = viewport[3] - (GLint)(args[1]) - 1;
  
      glReadPixels(
-         args[0],            // mouse x
+         (GLint)args[0],     // mouse x
          mouseYinGL,         // mouse y
          1,                  // width
          1,                  // height


@@ 5057,7 5057,7 @@ octaspire_dern_value_helper_get_type_as_c_string(arg->typeTag));
      }
  
-     x = octaspire_dern_value_as_number_get_value(arg);
+     x = (int)octaspire_dern_value_as_number_get_value(arg);
  
      // y
      arg = octaspire_dern_value_as_vector_get_element_at_const(arguments, 1);


@@ 5076,7 5076,7 @@ octaspire_dern_value_helper_get_type_as_c_string(arg->typeTag));
      }
  
-     y = octaspire_dern_value_as_number_get_value(arg);
+     y = (int)octaspire_dern_value_as_number_get_value(arg);
  
      // width
      arg = octaspire_dern_value_as_vector_get_element_at_const(arguments, 2);


@@ 5095,7 5095,7 @@ octaspire_dern_value_helper_get_type_as_c_string(arg->typeTag));
      }
  
-     width = octaspire_dern_value_as_number_get_value(arg);
+     width = (size_t)octaspire_dern_value_as_number_get_value(arg);
  
      // height
      arg = octaspire_dern_value_as_vector_get_element_at_const(arguments, 3);


@@ 5114,7 5114,7 @@ octaspire_dern_value_helper_get_type_as_c_string(arg->typeTag));
      }
  
-     height = octaspire_dern_value_as_number_get_value(arg);
+     height = (size_t)octaspire_dern_value_as_number_get_value(arg);
  
  #ifdef OCTASPIRE_DERN_SDL2_PLUGIN_USE_OPENGL2_LIBRARY
      glViewport(x, y, width, height);

M release/plugins/external/chipmunk/include/chipmunk/chipmunk.h => release/plugins/external/chipmunk/include/chipmunk/chipmunk.h +4 -1
@@ 1,3 1,6 @@+//
+ // Modified version by octaspire 2019.
+ //
  /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software
   * 
   * Permission is hereby granted, free of charge, to any person obtaining a copy


@@ 149,7 152,7 @@ CP_EXPORT cpFloat cpAreaForSegment(cpVect a, cpVect b, cpFloat radius);
  
  /// Calculate the moment of inertia for a solid polygon shape assuming it's center of gravity is at it's centroid. The offset is added to each vertex.
- CP_EXPORT cpFloat cpMomentForPoly(cpFloat m, int count, const cpVect *verts, cpVect offset, cpFloat radius);
+ CP_EXPORT cpFloat cpMomentForPoly(cpFloat m, const int count, const cpVect *verts, cpVect offset, cpFloat r);
  
  /// Calculate the signed area of a polygon. A Clockwise winding gives positive area.
  /// This is probably backwards from what you expect, but matches Chipmunk's the winding for poly shapes.

M release/plugins/external/chipmunk/include/chipmunk/chipmunk_private.h => release/plugins/external/chipmunk/include/chipmunk/chipmunk_private.h +5 -2
@@ 1,3 1,6 @@+//
+ // Modified version by octaspire 2019.
+ //
  /* This is modified version, NOT the original. Modifications are
   * copyright 2018 by octaspire and are released under the same license
   * as the original.


@@ 54,7 57,7 @@   //MARK: cpHashSet
  
- typedef cpBool (*cpHashSetEqlFunc)(void *ptr, void *elt);
+ typedef cpBool (*cpHashSetEqlFunc)(void const * const ptr, void const * const elt);
  typedef void *(*cpHashSetTransFunc)(void *ptr, void *data);
  
  cpHashSet *cpHashSetNew(int size, cpHashSetEqlFunc eqlFunc);


@@ 64,7 67,7 @@   int cpHashSetCount(cpHashSet *set);
  void *cpHashSetInsert(cpHashSet *set, cpHashValue hash, void *ptr, cpHashSetTransFunc trans, void *data);
- void *cpHashSetRemove(cpHashSet *set, cpHashValue hash, void *ptr);
+ void *cpHashSetRemove(cpHashSet *set, cpHashValue hash, void const * const ptr);
  void *cpHashSetFind(cpHashSet *set, cpHashValue hash, void *ptr);
  
  typedef void (*cpHashSetIteratorFunc)(void *elt, void *data);

M release/plugins/external/chipmunk/src/cpHashSet.c => release/plugins/external/chipmunk/src/cpHashSet.c +4 -1
@@ 1,3 1,6 @@+//
+ // Modified version by octaspire 2019.
+ //
  /* Copyright (c) 2013 Scott Lembcke and Howling Moon Software
   * 
   * Permission is hereby granted, free of charge, to any person obtaining a copy


@@ 176,7 179,7 @@ }
  
  void *
- cpHashSetRemove(cpHashSet *set, cpHashValue hash, void *ptr)
+ cpHashSetRemove(cpHashSet *set, cpHashValue hash, void const * const ptr)
  {
  	cpHashValue idx = hash%set->size;