Skip to content

Commit 1f51605

Browse files
committed
upload
1 parent ca169a4 commit 1f51605

File tree

16 files changed

+937
-2
lines changed

16 files changed

+937
-2
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
*.dmg
3+
.vscode/
4+
build/
5+
build-cache/
6+
cspkg-repo/
7+
temp.wxs
8+
*.wixobj
9+
*.msi

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# legacy_windows_support
2-
Legacy Windows Support for CovScript
1+
# Legacy Windows Support for CovScript
2+
This toolset is built under Microsoft Windows XP Professional SP3 x86

auto-build.bat

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@echo off
2+
mkdir build-cache
3+
cd %~dp0\build-cache
4+
5+
set GIT_REPO="https://github.com/covscript/"
6+
7+
call:git_fetch covscript
8+
call:git_fetch covscript-regex
9+
call:git_fetch covscript-codec
10+
call:git_fetch covscript-process
11+
12+
call:call_bat covscript
13+
set CS_DEV_PATH=%cd%\covscript\csdev
14+
call:call_bat covscript-regex
15+
call:call_bat covscript-codec
16+
call:call_bat covscript-process
17+
18+
cd ..
19+
rd /S /Q .\build
20+
mkdir build
21+
cd build-cache
22+
23+
xcopy /E /Y covscript\build ..\build\
24+
xcopy /E /Y covscript\csdev ..\build\
25+
xcopy /E /Y covscript-regex\build ..\build\
26+
xcopy /E /Y covscript-codec\build ..\build\
27+
xcopy /E /Y covscript-process\build ..\build\
28+
29+
cd ..
30+
.\build\bin\cs -i .\build\imports .\misc\win32_build.csc .\misc\win32_config.json
31+
.\build\bin\cs -i .\build\imports .\misc\cspkg_build.csc .\misc\cspkg_config.json
32+
33+
goto:eof
34+
:call_bat
35+
cd %1%
36+
call csbuild\make.bat
37+
cd ..
38+
goto:eof
39+
:git_fetch
40+
if exist %1% (
41+
cd %1%
42+
git fetch
43+
git pull
44+
git clean -dfx
45+
cd ..
46+
) else (
47+
git clone %GIT_REPO%/%1% --depth=1
48+
)
49+
goto:eof

misc/cmd_call.csc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
switch context.cmd_args[1]
2+
case "make"
3+
system.run(".\\csbuild\\make.bat"); end
4+
case "git"
5+
system.run("git fetch")
6+
system.run("git pull")
7+
system.run("git clean -dfx"); end
8+
end

misc/cspkg_build.csc

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
#!/usr/bin/env cs
2+
#
3+
# Covariant Script Builder v2.0
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# Copyright (C) 2017-2021 Michael Lee(李登淳)
18+
#
19+
# Email: lee@covariant.cn, mikecovlee@163.com
20+
# Github: https://github.com/mikecovlee
21+
# Website: http://covscript.org.cn
22+
23+
import codec.json as json
24+
import process
25+
import regex
26+
27+
namespace utils
28+
function open_json(path)
29+
var ifs = iostream.ifstream(path)
30+
return json.to_var(json.from_stream(ifs))
31+
end
32+
function save_json(val, path)
33+
var ofs = iostream.ofstream(path)
34+
ofs.print(json.to_string(json.from_var(val)))
35+
end
36+
function filter(str, cond)
37+
var _s = ""
38+
foreach ch in str
39+
if cond(ch)
40+
_s += ch
41+
end
42+
end
43+
return move(_s)
44+
end
45+
end
46+
47+
namespace env
48+
function user_home()
49+
if system.is_platform_windows()
50+
return system.getenv("USERPROFILE")
51+
else
52+
return system.getenv("HOME")
53+
end
54+
end
55+
function covscript_home()
56+
try
57+
return system.getenv("COVSCRIPT_HOME")
58+
catch e; end
59+
if system.is_platform_windows()
60+
return env.user_home() + system.path.separator + "Documents" + system.path.separator + "CovScript"
61+
end
62+
if system.is_platform_linux()
63+
return "/usr/share/covscript"
64+
end
65+
if system.is_platform_darwin()
66+
return "/Applications/CovScript.app/Contents/MacOS/covscript"
67+
end
68+
end
69+
function platform()
70+
if system.is_platform_windows()
71+
return "windows"
72+
end
73+
if system.is_platform_linux()
74+
return "linux"
75+
end
76+
if system.is_platform_darwin()
77+
return "macos"
78+
end
79+
end
80+
function arch()
81+
if system.is_platform_unix()
82+
var p = process.exec("arch", {})
83+
return p.out().getline()
84+
else
85+
return "legacy_i386"
86+
end
87+
end
88+
function covscript_abi()
89+
var abi_reg = regex.build("ABI Version: ([A-Z0-9]{6})")
90+
var p = process.exec("./build/bin/cs", {"-v"})
91+
var r = null, line = null
92+
loop; until !(r = abi_reg.search(line = p.out().getline())).empty()
93+
return r.str(1)
94+
end
95+
end
96+
97+
var json_reg = regex.build("^(.*)\\.json$")
98+
99+
function is_json_file(name)
100+
return !json_reg.match(name).empty()
101+
end
102+
103+
if context.cmd_args.size != 2 || !is_json_file(context.cmd_args[1])
104+
system.out.println("csbuild: wrong command line arguments. usage: \'csbuild target.json\'")
105+
system.exit(0)
106+
end
107+
108+
var target = utils.open_json(context.cmd_args[1])
109+
110+
if target.remote_base[-1] != '/'
111+
target.remote_base += '/'
112+
end
113+
114+
system.out.println("csbuild: installing packages...")
115+
116+
var idx_path = "cspkg-repo" + system.path.separator + "index_files" + system.path.separator + "packages" + system.path.separator + "universal"
117+
var pkg_path = "cspkg-repo" + system.path.separator + "universal"
118+
var idx_os_path = "cspkg-repo" + system.path.separator + "index_files" + system.path.separator + "packages" + system.path.separator + env.platform() + system.path.separator + env.arch()
119+
var pkg_os_path = "cspkg-repo" + system.path.separator + env.platform() + system.path.separator + env.arch()
120+
var pkg_install_path = "build" + system.path.separator + "imports"
121+
122+
system.path.mkdir_p(idx_path)
123+
system.path.mkdir_p(pkg_path)
124+
system.path.mkdir_p(idx_os_path)
125+
system.path.mkdir_p(pkg_os_path)
126+
system.path.mkdir_p(pkg_install_path)
127+
128+
foreach it in target.install
129+
var path = "build-cache" + system.path.separator + it
130+
if !system.path.exist(path + system.path.separator + "csbuild")
131+
system.out.println("csbuild: configure directory not found in module \'" + it + "\'")
132+
continue
133+
end
134+
var files = system.path.scan(path + system.path.separator + "csbuild")
135+
foreach entry in files
136+
if entry.type == system.path.type.reg
137+
if is_json_file(entry.name)
138+
var info = utils.open_json(path + system.path.separator + "csbuild" + system.path.separator + entry.name)
139+
if info.Type == "Extension"
140+
info.Version += "_ABI" + env.covscript_abi()
141+
end
142+
system.out.println("csbuild: building package " + info.Name + "(" + info.Version + ")...")
143+
var file_reg = regex.build("^.*?(\\w+\\.(cse|csp))$")
144+
var file_name = file_reg.match(info.Target)
145+
if file_name.empty() || !system.file.exist(path + system.path.separator + info.Target)
146+
system.out.println("csbuild: invalid target in module \'" + it + "\'")
147+
continue
148+
end
149+
system.file.copy(path + system.path.separator + info.Target, pkg_install_path + system.path.separator + file_name.str(1))
150+
if info.Type == "Extension"
151+
system.file.copy(path + system.path.separator + info.Target, pkg_os_path + system.path.separator + file_name.str(1))
152+
info.Target = target.remote_base + env.platform() + "/" + env.arch() + "/" + file_name.str(1)
153+
info.erase("Type")
154+
utils.save_json(info, idx_os_path + system.path.separator + info.Name + ".json")
155+
continue
156+
end
157+
if info.Type == "Package"
158+
system.file.copy(path + system.path.separator + info.Target, pkg_path + system.path.separator + file_name.str(1))
159+
info.Target = target.remote_base + "universal/" + file_name.str(1)
160+
info.erase("Type")
161+
utils.save_json(info, idx_path + system.path.separator + info.Name + ".json")
162+
end
163+
end
164+
end
165+
end
166+
end

misc/cspkg_config.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"remote_base" : "http://mirrors.covariant.cn/cspkg/",
3+
"install": [
4+
"csdbc",
5+
"stdutils",
6+
"covscript-process",
7+
"covscript-database",
8+
"covscript-regex",
9+
"covscript-codec",
10+
"covscript-darwin",
11+
"covscript-sqlite",
12+
"covscript-network",
13+
"covscript-imgui",
14+
"covscript-process",
15+
"covscript-zip"
16+
]
17+
}

misc/win32_build.csc

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import codec.json as json
2+
import process
3+
import regex
4+
5+
namespace utils
6+
function open_json(path)
7+
var ifs = iostream.ifstream(path)
8+
return json.to_var(json.from_stream(ifs))
9+
end
10+
end
11+
12+
function read_to_end(ofs)
13+
while !ofs.eof()
14+
var ch = ofs.get()
15+
if ofs.eof()
16+
break
17+
end
18+
system.out.put(ch)
19+
end
20+
end
21+
22+
function call_parallel(arg_list)
23+
var plist = new list
24+
foreach it in arg_list
25+
var b = new process.builder
26+
b.dir(it[0])
27+
b.cmd(it[1])
28+
b.arg(it[2])
29+
plist.push_back(b.start())
30+
end
31+
loop
32+
for it = plist.begin, it != plist.end, null
33+
if it.data.has_exited()
34+
read_to_end(it.data.out())
35+
it = plist.erase(it)
36+
else
37+
it.next()
38+
end
39+
end
40+
until plist.empty()
41+
end
42+
43+
var json_reg = regex.build("^(.*)\\.json$")
44+
45+
function is_json_file(name)
46+
return !json_reg.match(name).empty()
47+
end
48+
49+
if context.cmd_args.size != 2 || !is_json_file(context.cmd_args[1])
50+
system.out.println("csbuild: wrong command line arguments. usage: \'csbuild target.json\'")
51+
system.exit(0)
52+
end
53+
54+
var target = utils.open_json(context.cmd_args[1])
55+
var vlist = new array
56+
57+
foreach it in target.repos
58+
var module = it.split({'/'})[1]
59+
if system.path.exist("build-cache" + system.path.separator + module)
60+
vlist.push_back({"build-cache" + system.path.separator + module, ".\\build\\bin\\cs.exe", {"..\\..\\misc\\cmd_call.csc", "git"}})
61+
else
62+
vlist.push_back({"build-cache", "git", {"clone", target.git_repo + it, "--depth=1"}})
63+
end
64+
end
65+
66+
system.out.println("csbuild: fetching git repository...")
67+
call_parallel(vlist)
68+
vlist.clear()
69+
foreach it in target.build do vlist.push_back({"build-cache" + system.path.separator + it, ".\\build\\bin\\cs.exe", {"..\\..\\misc\\cmd_call.csc", "make"}})
70+
system.out.println("csbuild: building packages...")
71+
call_parallel(vlist)

misc/win32_config.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"git_repo": "https://github.com/",
3+
"repos": [
4+
"covscript/csdbc",
5+
"covscript/stdutils",
6+
"covscript/covscript-database",
7+
"covscript/covscript-darwin",
8+
"covscript/covscript-sqlite",
9+
"covscript/covscript-network",
10+
"covscript/covscript-imgui",
11+
"covscript/covscript-zip"
12+
],
13+
"build": [
14+
"stdutils",
15+
"covscript-database",
16+
"covscript-darwin",
17+
"covscript-sqlite",
18+
"covscript-network",
19+
"covscript-imgui",
20+
"covscript-zip"
21+
]
22+
}

package_tools/wix/gen.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
echo %~dp0
2+
heat dir ..\..\build\ -cg Package -gg -sfrag -template:fragment -out temp.wxs

0 commit comments

Comments
 (0)