Skip to content

Commit

Permalink
test scons emitter for cached builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Vano committed Oct 3, 2024
1 parent 4df0c27 commit 6c38529
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
24 changes: 11 additions & 13 deletions godot_cppscript.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,6 @@ if __name__ != '__main__':
return env.CppScript(sources, cppscript_env, *args, **kwargs)
class CppScriptBuilder():
def __init__(self):
self.builder = Builder(action=generate_header_scons, emitter=generate_header_emitter)
def __call__(self, env, source, call_args, cwd = os.getcwd(), *args, **kwargs):
cppscript_env, *other = call_args
# Convert scons variables to cppscript's env
Expand Down Expand Up @@ -673,8 +670,18 @@ if __name__ != '__main__':
with open(godotcpp, 'w') as file:
file.write(cppscript_env['code_format'].CPPSCRIPT_BODY.format(cppscript_env['header_name'].replace(' ', '_').replace('.', '_').upper()))
def generate_header_emitter(target, source, env):
generated = [env.File(filename_to_gen_filename(str(i), env['cppscript_env'])) for i in source] + \\
[env.File(bindings), env.File(defs), env.File(godotcpp)]
# To avoid generated sources deletion and re-parsing
env.Precious(generated)
return generated, source
generator = Builder(action=generate, emitter=generate_emitter)(env)
builder = self.builder(env, source=source, *other, *args, **kwargs)
builder = Builder(action=generate_header_scons, emitter=generate_header_emitter) \\
(env, source=source, *other, *args, **kwargs)
env.Depends(builder, generator)
return builder
Expand Down Expand Up @@ -864,15 +871,6 @@ def cursor_get_field_type(cursor):
# Builder
def generate_header_emitter(target, source, env):
generated = [env.File(filename_to_gen_filename(str(i), env['cppscript_env'])) for i in source]
# To avoid generated sources deletion and re-parsing
env.Precious(generated)
return generated, source
def generate_header_scons(target, source, env):
if \"CPPSCRIPT_DEBUG\" in os.environ.keys():
print(json.dumps(env['cppscript_env'], indent=2, default=lambda x: list(x) if type(x) is set else x))
Expand Down
24 changes: 11 additions & 13 deletions godot_cppscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,6 @@ def create_cppscript_target(env, sources, cppscript_env, *args, **kwargs):
return env.CppScript(sources, cppscript_env, *args, **kwargs)

class CppScriptBuilder():
def __init__(self):
self.builder = Builder(action=generate_header_scons, emitter=generate_header_emitter)

def __call__(self, env, source, call_args, cwd = os.getcwd(), *args, **kwargs):
cppscript_env, *other = call_args
# Convert scons variables to cppscript's env
Expand Down Expand Up @@ -656,8 +653,18 @@ def generate(target, source, env):
with open(godotcpp, 'w') as file:
file.write(cppscript_env['code_format'].CPPSCRIPT_BODY.format(cppscript_env['header_name'].replace(' ', '_').replace('.', '_').upper()))

def generate_header_emitter(target, source, env):
generated = [env.File(filename_to_gen_filename(str(i), env['cppscript_env'])) for i in source] + \
[env.File(bindings), env.File(defs), env.File(godotcpp)]

# To avoid generated sources deletion and re-parsing
env.Precious(generated)

return generated, source

generator = Builder(action=generate, emitter=generate_emitter)(env)
builder = self.builder(env, source=source, *other, *args, **kwargs)
builder = Builder(action=generate_header_scons, emitter=generate_header_emitter) \
(env, source=source, *other, *args, **kwargs)
env.Depends(builder, generator)

return builder
Expand Down Expand Up @@ -847,15 +854,6 @@ def cursor_get_field_type(cursor):


# Builder
def generate_header_emitter(target, source, env):
generated = [env.File(filename_to_gen_filename(str(i), env['cppscript_env'])) for i in source]

# To avoid generated sources deletion and re-parsing
env.Precious(generated)

return generated, source


def generate_header_scons(target, source, env):
if "CPPSCRIPT_DEBUG" in os.environ.keys():
print(json.dumps(env['cppscript_env'], indent=2, default=lambda x: list(x) if type(x) is set else x))
Expand Down

0 comments on commit 6c38529

Please sign in to comment.