Skip to content

Commit 5f791ca

Browse files
committed
Initial commit
0 parents  commit 5f791ca

File tree

10 files changed

+466
-0
lines changed

10 files changed

+466
-0
lines changed

.cargo/config.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[build]
2+
3+
[target.'cfg(target_vendor = "rust9x")']
4+
rustflags = [
5+
# Show linker args if needed
6+
# '--print=link-args',
7+
8+
# statically linked runtime
9+
'-Ctarget-feature=+crt-static',
10+
# dynamically linked runtime
11+
# '-Ctarget-feature=-crt-static',
12+
13+
# Add search paths
14+
'-Clink-args=/LIBPATH:D:\rustprojs\rust9x\r9x-buildtools\vc71\Vc7\lib',
15+
'-Clink-args=/LIBPATH:D:\rustprojs\rust9x\r9x-buildtools\vc71\Vc7\PlatformSDK\Lib',
16+
# '-Clink-args=/LIBPATH:D:\rustprojs\rust9x\r9x-buildtools\vc8\VC\lib',
17+
# '-Clink-args=/LIBPATH:D:\rustprojs\rust9x\r9x-buildtools\vc8\VC\PlatformSDK\Lib',
18+
19+
# (optional) Disable default libs for full control over linked libraries
20+
# '-Clink-args=/NODEFAULTLIB',
21+
22+
# Remove default libs that unicows wraps/overrides
23+
'-Clink-args=/nod:kernel32.lib /nod:advapi32.lib /nod:user32.lib /nod:gdi32.lib /nod:shell32.lib /nod:comdlg32.lib /nod:version.lib /nod:mpr.lib /nod:rasapi32.lib /nod:winmm.lib /nod:winspool.lib /nod:vfw32.lib /nod:secur32.lib /nod:oleacc.lib /nod:oledlg.lib /nod:sensapi.lib',
24+
25+
# Then link unicows itself, allowing the linker to resolve symbols to it instead of the wrapped
26+
# libraries
27+
'-Clink-arg=unicows.lib',
28+
29+
# Then add back the default libs that were removed
30+
'-Clink-args=kernel32.lib advapi32.lib user32.lib gdi32.lib shell32.lib comdlg32.lib version.lib mpr.lib rasapi32.lib winmm.lib winspool.lib vfw32.lib secur32.lib oleacc.lib oledlg.lib sensapi.lib',
31+
]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "rust9x_sample"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[features]
9+
# Enables the sockaddr and TCP tests, which in turn add a static dependency on WinSock 2
10+
# (ws2_32.dll). This has to be turned off for Windows NT < 4.0, or for Windows 95 without intstalled
11+
network = []
12+
13+
[dependencies]
14+
15+
[profile.release]
16+
lto = "thin"
17+
codegen-units = 1
18+
debug = 2
19+
20+
panic = "abort"
21+
# Unwind support needs at least VC8 (VS2005)
22+
# panic = "unwind"

LICENSE-APACHE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2020 Dennis Duda
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

LICENSE-MIT

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2020 Dennis Duda
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Small test app for various rust9x functionality
2+
3+
1. Install `just` (`cargo install just`).
4+
2. Update the lib paths in `.cargo/config.toml` to match yours. If you want to build for a system
5+
that is already supported natively by your default msvc installation, you can remove these or
6+
comment them out.
7+
3. Update the variables in the `justfile`. The rust9x toolchain name and `editbin.exe` path (from
8+
your modern msvc build tools) in particular are important.
9+
4. Use `just build --release` to build using the rust9x toolchain, and regular `cargo` for normal
10+
toolchain builds.
11+
12+
- Make sure to put `hh3gf.golden.exe` next to the executable for testing.
13+
- If you plan on testing on Windows 9x/ME, make sure to place `unicows.dll` next to the executable
14+
- If you link dynamically, make sure to provide the necessary runtime libraries.
15+
16+
## Credits
17+
18+
`hh3gf.golden.exe` is taken from https://github.com/pts/pts-tinype to test stdout redirection.

hh3gf.golden.exe

2 KB
Binary file not shown.

justfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
set shell := ['powershell.exe', '-c']
2+
3+
r9x_toolchain := 'rust9x'
4+
r9x_target := 'i586-rust9x-windows-msvc'
5+
r9x_editbin := 'C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.32.31326\bin\Hostx64\x64\editbin.exe'
6+
7+
subsystem := 'CONSOLE,4.0'
8+
os_version := '3.1'
9+
10+
build *FLAGS: (do-build 'debug' FLAGS)
11+
release *FLAGS: (do-build 'release' '--release' FLAGS)
12+
do-build PROFILE *FLAGS='': (r9x 'build' '--target' r9x_target FLAGS) (editbin 'target\'+r9x_target+'\'+PROFILE+'\rust9x_sample.exe')
13+
run *FLAGS: (r9x 'run' '--target' r9x_target FLAGS)
14+
15+
r9x $COMMAND *FLAGS:
16+
cargo +{{ r9x_toolchain }} {{ COMMAND }} {{ FLAGS }}
17+
18+
# PE executables specify the subsystem and subsystem version as well as the required OS version.
19+
#
20+
# `link.exe` has the same switches, but doesn't allow setting them to values that lie outside of the
21+
# supported range of the toolset. `editbin.exe` is a bit more forgiving, only warning about
22+
# "invalid" values (`LINK : warning LNK4241: invalid subsystem version number 4`), but still
23+
# carrying out the change as requested. `/OSVERSION` is entirely undocumented, but still works,
24+
# setting the minimum required OS version. Both values must be in a supported range for the target
25+
# OS to accept and run the executable.
26+
editbin EXECUTABLE:
27+
& "{{ r9x_editbin }}" {{ EXECUTABLE }} /SUBSYSTEM:{{ subsystem }} /OSVERSION:{{ os_version }} /RELEASE

0 commit comments

Comments
 (0)