Skip to content

Commit 869a877

Browse files
authored
Add Defold License to source files (defold#4790)
* Added Defold License to all files
1 parent 08a3278 commit 869a877

File tree

1,485 files changed

+17946
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,485 files changed

+17946
-9
lines changed

apply_license.py

Lines changed: 94 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,129 @@
1212
CONDITIONS OF ANY KIND, either express or implied. See the License for the
1313
specific language governing permissions and limitations under the License.'''
1414

15-
extensions = [ ".h", ".c", ".cpp", ".m", ".inl", ".sh", ".py", ".java", ".clj" ]
15+
extensions = [ ".h", ".c", ".cpp", ".inl", ".m", ".mm", ".sh", ".py", ".java", ".clj", ".go", ".lua" ]
1616

1717
ext_to_comment = {
1818
".h": "// ",
1919
".c": "// ",
2020
".cpp": "// ",
21-
".m": "// ",
2221
".inl": "// ",
22+
".m": "// ",
23+
".mm": "// ",
2324
".java": "// ",
2425
".sh": "# ",
2526
".py": "# ",
2627
".clj": ";; ",
28+
".go": "// ",
29+
".lua": "-- ",
2730
}
2831

32+
exluded_files = [
33+
"edn.lua",
34+
"mobdebug.lua",
35+
"test_props.lua",
36+
"test_props_url.lua",
37+
"test_props_number.lua",
38+
"test_props_hash.lua",
39+
"test_props_vec3.lua",
40+
"test_props_vec4.lua",
41+
"test_props_quat.lua",
42+
"test_props_bool.lua",
43+
"test_props_material.lua"
44+
]
45+
46+
exluded_patterns = [
47+
"build/"
48+
"dynamo_home/"
49+
"engine/glfw/tests",
50+
"engine/glfw/examples",
51+
"engine/sound/src/openal",
52+
"dlib/src/zlib",
53+
"dlib/src/webp",
54+
"lua/src/lua",
55+
"lua/scripts",
56+
"script/src/luasocket",
57+
"script/src/bitop",
58+
"com.dynamo.cr.bob/generated",
59+
"luajit",
60+
"jagatoo",
61+
"Box2D",
62+
"jsmn",
63+
"msbranco"
64+
]
65+
66+
include_patterns = [
67+
"rig.cpp",
68+
"dstrings.cpp",
69+
"package_win32_sdk.sh",
70+
"Protocol.java",
71+
"script_bitop.cpp",
72+
]
73+
74+
def match_patterns(s, patterns):
75+
for pattern in patterns:
76+
if pattern in s:
77+
return True
78+
return False
79+
80+
81+
def force_include(fullpath):
82+
if match_patterns(fullpath, include_patterns):
83+
return True
84+
return False
85+
86+
def skip_filename(fullpath, basename):
87+
if basename in exluded_files:
88+
return True
89+
90+
if match_patterns(fullpath, exluded_patterns):
91+
return True
92+
93+
return False
94+
95+
def has_other_license(s):
96+
return "Copyright" in s or "License" in s
97+
98+
def get_comment_style_for_file(fullpath):
99+
ext = os.path.splitext(fullpath)[1]
100+
if ext == ".go" and not fullpath.startswith("./go/"):
101+
return None
102+
return ext_to_comment.get(ext)
103+
104+
105+
29106
for subdir, dirs, files in os.walk("."):
30107
# Ignore tmp and build folders
31-
if subdir.startswith("./tmp") or subdir.startswith("./engine/glfw/examples") or "build" in subdir:
108+
if subdir.startswith("./tmp") or "build" in subdir:
32109
continue
33110
for file in files:
34-
#print os.path.join(subdir, file)
35111
filepath = subdir + os.sep + file
36-
filename, ext = os.path.splitext(filepath)
112+
ext = os.path.splitext(filepath)[1]
37113
if ext not in extensions:
38114
continue
39115

116+
comment = get_comment_style_for_file(filepath)
117+
if comment is None:
118+
continue
119+
120+
should_include = force_include(filepath)
121+
if not should_include and skip_filename(filepath, file):
122+
print("Excluded " + filepath)
123+
continue
124+
40125
with open(filepath, "rb+") as f:
41126
contents = f.read()
42127
# Already applied the Defold License?
43128
if "Defold Foundation" in contents:
44129
print("Already applied Defold license to " + filepath)
45130
continue;
131+
46132
# Some other license in the file
47-
if "Copyright" in contents or "License" in contents:
133+
if not should_include and has_other_license(contents):
48134
print("Other license in " + filepath)
49135
continue;
50136

51137
# Make the license text into a language specific comment, based on extension
52-
comment = ext_to_comment.get(ext)
53138
lines = LICENSE.split("\n")
54139
lines = [comment + line for line in lines]
55140
license = "\n".join(lines)
@@ -60,8 +145,8 @@
60145
contents = contents.replace(firstline, "")
61146
license = firstline + "\n" + license
62147

63-
print("Applying Defold License to " + filepath)
148+
print("Applying Defold License to " + filepath + (" (force included)" if should_include else ""))
64149
f.seek(0)
65-
f.write(license + "\n")
150+
f.write(license + "\n\n")
66151
f.write(contents)
67152
f.truncate()

ci/ci.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
#!/usr/bin/env python
2+
# Copyright 2020 The Defold Foundation
3+
# Licensed under the Defold License version 1.0 (the "License"); you may not use
4+
# this file except in compliance with the License.
5+
#
6+
# You may obtain a copy of the License, together with FAQs at
7+
# https://www.defold.com/license
8+
#
9+
# Unless required by applicable law or agreed to in writing, software distributed
10+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
# specific language governing permissions and limitations under the License.
13+
14+
215

316
import sys
417
import subprocess

ci/ci.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
#!/bin/bash
2+
# Copyright 2020 The Defold Foundation
3+
# Licensed under the Defold License version 1.0 (the "License"); you may not use
4+
# this file except in compliance with the License.
5+
#
6+
# You may obtain a copy of the License, together with FAQs at
7+
# https://www.defold.com/license
8+
#
9+
# Unless required by applicable law or agreed to in writing, software distributed
10+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
# specific language governing permissions and limitations under the License.
13+
14+
215
set -e
316

417
OLDPATH=$PATH

ci/trigger-build.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
#!/usr/bin/env python
2+
# Copyright 2020 The Defold Foundation
3+
# Licensed under the Defold License version 1.0 (the "License"); you may not use
4+
# this file except in compliance with the License.
5+
#
6+
# You may obtain a copy of the License, together with FAQs at
7+
# https://www.defold.com/license
8+
#
9+
# Unless required by applicable law or agreed to in writing, software distributed
10+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
# specific language governing permissions and limitations under the License.
13+
14+
215

316
import sys
417
import os

com.dynamo.cr/com.dynamo.cr.bob.test/src/com/dynamo/bob/archive/test/ArchiveTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Copyright 2020 The Defold Foundation
2+
// Licensed under the Defold License version 1.0 (the "License"); you may not use
3+
// this file except in compliance with the License.
4+
//
5+
// You may obtain a copy of the License, together with FAQs at
6+
// https://www.defold.com/license
7+
//
8+
// Unless required by applicable law or agreed to in writing, software distributed
9+
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
// specific language governing permissions and limitations under the License.
12+
113
package com.dynamo.bob.archive.test;
214

315
import static org.junit.Assert.assertEquals;

com.dynamo.cr/com.dynamo.cr.bob.test/src/com/dynamo/bob/archive/test/ManifestTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Copyright 2020 The Defold Foundation
2+
// Licensed under the Defold License version 1.0 (the "License"); you may not use
3+
// this file except in compliance with the License.
4+
//
5+
// You may obtain a copy of the License, together with FAQs at
6+
// https://www.defold.com/license
7+
//
8+
// Unless required by applicable law or agreed to in writing, software distributed
9+
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
// specific language governing permissions and limitations under the License.
12+
113
package com.dynamo.bob.archive.test;
214

315
import static org.junit.Assert.assertArrayEquals;

com.dynamo.cr/com.dynamo.cr.bob.test/src/com/dynamo/bob/bundle/test/BundleHelperTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Copyright 2020 The Defold Foundation
2+
// Licensed under the Defold License version 1.0 (the "License"); you may not use
3+
// this file except in compliance with the License.
4+
//
5+
// You may obtain a copy of the License, together with FAQs at
6+
// https://www.defold.com/license
7+
//
8+
// Unless required by applicable law or agreed to in writing, software distributed
9+
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
// specific language governing permissions and limitations under the License.
12+
113
package com.dynamo.bob.bundle.test;
214

315
import static org.junit.Assert.assertEquals;

com.dynamo.cr/com.dynamo.cr.bob.test/src/com/dynamo/bob/bundle/test/BundlerTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Copyright 2020 The Defold Foundation
2+
// Licensed under the Defold License version 1.0 (the "License"); you may not use
3+
// this file except in compliance with the License.
4+
//
5+
// You may obtain a copy of the License, together with FAQs at
6+
// https://www.defold.com/license
7+
//
8+
// Unless required by applicable law or agreed to in writing, software distributed
9+
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
// specific language governing permissions and limitations under the License.
12+
113
package com.dynamo.bob.bundle.test;
214

315
import java.awt.image.BufferedImage;

com.dynamo.cr/com.dynamo.cr.bob.test/src/com/dynamo/bob/bundle/test/OSXBundlerTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Copyright 2020 The Defold Foundation
2+
// Licensed under the Defold License version 1.0 (the "License"); you may not use
3+
// this file except in compliance with the License.
4+
//
5+
// You may obtain a copy of the License, together with FAQs at
6+
// https://www.defold.com/license
7+
//
8+
// Unless required by applicable law or agreed to in writing, software distributed
9+
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
// specific language governing permissions and limitations under the License.
12+
113
package com.dynamo.bob.bundle.test;
214

315
import static org.apache.commons.io.FilenameUtils.concat;

com.dynamo.cr/com.dynamo.cr.bob.test/src/com/dynamo/bob/fs/test/ClassLoaderMountPointTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// Copyright 2020 The Defold Foundation
2+
// Licensed under the Defold License version 1.0 (the "License"); you may not use
3+
// this file except in compliance with the License.
4+
//
5+
// You may obtain a copy of the License, together with FAQs at
6+
// https://www.defold.com/license
7+
//
8+
// Unless required by applicable law or agreed to in writing, software distributed
9+
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
10+
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
// specific language governing permissions and limitations under the License.
12+
113
package com.dynamo.bob.fs.test;
214

315
import static org.junit.Assert.assertEquals;

0 commit comments

Comments
 (0)