diff --git a/scripts/buildconfiguration.gd b/scripts/buildconfiguration.gd index d7900e8..d819a07 100644 --- a/scripts/buildconfiguration.gd +++ b/scripts/buildconfiguration.gd @@ -4,45 +4,3 @@ class_name BuildConfiguration var debuglibs :bool - - -static func parse_csv(csv :String) -> Array: - var lst := [] - var lines := csv.split("\n", false) - - for i in range(len(lines)): - var l := lines[i].strip_edges() - - if l.begins_with("#"): - continue - - var b := create(i, l) - - if b != null: - lst.append(b) - - return lst - - -static func create(idx :int, line :String) -> BuildConfiguration: - var params := Utils.split_clean(line, "|", true) - - assert(len(params) == 5) - - # check if enabled - var enabled := Utils.is_true(params[1]) - - if enabled: - var b := BuildConfiguration.new() - - b.index = idx - b.name = params[0].strip_edges() - b.arguments = Utils.split_clean(params[2], " ", false) - b.defines = Utils.split_clean(params[3], " ", false) - b.debuglibs = Utils.is_true(params[4]) - - b.parse_arguments() - - return b - - return null diff --git a/scripts/buildfactory.gd b/scripts/buildfactory.gd new file mode 100644 index 0000000..7cf226a --- /dev/null +++ b/scripts/buildfactory.gd @@ -0,0 +1,77 @@ +tool +extends Object +class_name BuildFactory + + +static func parse_csv(csv :String, createfunc :FuncRef) -> Array: + var lst := [] + var lines := csv.split("\n", false) + + for i in range(len(lines)): + var l := lines[i].strip_edges() + + if l.begins_with("#"): + continue + + var params := Utils.split_clean(l, "|", true) + var b :BuildBase = createfunc.call_func(i, params) + + if b != null: + lst.append(b) + + return lst + + +func parse_csv_pltfrm(csv :String) -> Array: + return parse_csv(csv, funcref(self, "create_pltfm")) + + +func parse_csv_cfg(csv :String) -> Array: + return parse_csv(csv, funcref(self, "create_cfg")) + + +func create_pltfm(idx :int, params :Array) -> BuildPlatform: + assert(len(params) == 8) + + # check if available and enabled + var enabled := Utils.is_true(params[1]) + var availableon = params[2] + + if enabled and OS.get_name() in availableon: + var p := BuildPlatform.new() + + p.index = idx + p.name = params[0].strip_edges() + p.arguments = Utils.split_clean(params[3], " ", false) + p.defines = Utils.split_clean(params[4], " ", false) + p.outputname = params[5] + p.gdnlibkey = params[6].strip_edges() + p.vsplatform = params[7].strip_edges() + + p.parse_arguments() + + return p + + return null + + +func create_cfg(idx :int, params :Array) -> BuildConfiguration: + assert(len(params) == 5) + + # check if enabled + var enabled := Utils.is_true(params[1]) + + if enabled: + var b := BuildConfiguration.new() + + b.index = idx + b.name = params[0].strip_edges() + b.arguments = Utils.split_clean(params[2], " ", false) + b.defines = Utils.split_clean(params[3], " ", false) + b.debuglibs = Utils.is_true(params[4]) + + b.parse_arguments() + + return b + + return null diff --git a/scripts/buildplatform.gd b/scripts/buildplatform.gd index 199f76b..ec2af31 100644 --- a/scripts/buildplatform.gd +++ b/scripts/buildplatform.gd @@ -6,48 +6,3 @@ class_name BuildPlatform var outputname :String var gdnlibkey :String var vsplatform :String - - -static func parse_csv(csv :String) -> Array: - var lst := [] - var lines := csv.split("\n", false) - - for i in range(len(lines)): - var l := lines[i].strip_edges() - - if l.begins_with("#"): - continue - - var b := create(i, l) - - if b != null: - lst.append(b) - - return lst - - -static func create(idx :int, line :String) -> BuildPlatform: - var params := Utils.split_clean(line, "|", true) - - assert(len(params) == 8) - - # check if available and enabled - var enabled := Utils.is_true(params[1]) - var availableon := params[2] - - if enabled and OS.get_name() in availableon: - var p := BuildPlatform.new() - - p.index = idx - p.name = params[0].strip_edges() - p.arguments = Utils.split_clean(params[3], " ", false) - p.defines = Utils.split_clean(params[4], " ", false) - p.outputname = params[5] - p.gdnlibkey = params[6].strip_edges() - p.vsplatform = params[7].strip_edges() - - p.parse_arguments() - - return p - - return null diff --git a/scripts/easycpp.gd b/scripts/easycpp.gd index 8ac12af..e0a861f 100644 --- a/scripts/easycpp.gd +++ b/scripts/easycpp.gd @@ -99,11 +99,7 @@ enum VisualProjectLocation { const supportCmake := false const allowMacOSSConsFix := true -const __preload_utils := preload("res://addons/easycpp/scripts/utils.gd") -const __preload_buildbase := preload("res://addons/easycpp/scripts/buildbase.gd") -const __preload_buildconfig := preload("res://addons/easycpp/scripts/buildconfiguration.gd") -const __preload_buildplatform := preload("res://addons/easycpp/scripts/buildplatform.gd") -var utils := __preload_utils.new() +var utils := preload("res://addons/easycpp/scripts/utils.gd").new() const toolsres := "res://addons/easycpp/tools" const tempres := "res://addons/easycpp/temp" @@ -311,7 +307,7 @@ func read_build_platforms_configurations(): platforms = utils.get_project_setting_string(setting_buildplatforms, platforms, PROPERTY_HINT_MULTILINE_TEXT) - buildplatforms = BuildPlatform.new().parse_csv(platforms) + buildplatforms = BuildFactory.new().parse_csv_pltfrm(platforms) if len(buildplatforms) < 1: print("Failed to load build platforms from settings!!") @@ -326,7 +322,7 @@ func read_build_platforms_configurations(): configurations = utils.get_project_setting_string(setting_buildconfigurations, configurations, PROPERTY_HINT_MULTILINE_TEXT) - buildconfigurations = BuildConfiguration.new().parse_csv(configurations) + buildconfigurations = BuildFactory.new().parse_csv_cfg(configurations) if len(buildconfigurations) < 1: print("Failed to load build configurations from settings!!")