Skip to content

Commit

Permalink
Workaround for GDScript issue godotengine/godot#21461.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkollmann committed Jun 28, 2021
1 parent 4e8f79a commit d8e1b98
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 94 deletions.
42 changes: 0 additions & 42 deletions scripts/buildconfiguration.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
77 changes: 77 additions & 0 deletions scripts/buildfactory.gd
Original file line number Diff line number Diff line change
@@ -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
45 changes: 0 additions & 45 deletions scripts/buildplatform.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 3 additions & 7 deletions scripts/easycpp.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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!!")
Expand All @@ -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!!")
Expand Down

0 comments on commit d8e1b98

Please sign in to comment.