Browse Source

Generate bindings if they are not found

Marc Gilleron 4 years ago
parent
commit
f669380811
1 changed files with 11 additions and 3 deletions
  1. 11 3
      SConstruct

+ 11 - 3
SConstruct

@@ -123,10 +123,12 @@ opts.Add(PathVariable(
     None,
     None,
     PathVariable.PathIsFile
     PathVariable.PathIsFile
 ))
 ))
-opts.Add(BoolVariable(
+opts.Add(EnumVariable(
     'generate_bindings',
     'generate_bindings',
     'Generate GDNative API bindings',
     'Generate GDNative API bindings',
-    False
+    'auto',
+    allowed_values = ['yes', 'no', 'auto', 'true'],
+    ignorecase = 2
 ))
 ))
 opts.Add(EnumVariable(
 opts.Add(EnumVariable(
     'android_arch',
     'android_arch',
@@ -387,7 +389,13 @@ if 'custom_api_file' in env:
 else:
 else:
     json_api_file = os.path.join(os.getcwd(), env['headers_dir'], 'api.json')
     json_api_file = os.path.join(os.getcwd(), env['headers_dir'], 'api.json')
 
 
-if env['generate_bindings']:
+if env['generate_bindings'] == 'auto':
+    # Check if generated files exist
+    should_generate_bindings = not os.path.isfile(os.path.join(os.getcwd(), 'src', 'gen', 'Object.cpp'))
+else:
+    should_generate_bindings = env['generate_bindings'] in ['yes', 'true']
+
+if should_generate_bindings:
     # Actually create the bindings here
     # Actually create the bindings here
     import binding_generator
     import binding_generator