Skip to content

Commit

Permalink
prepare for lsfw 0.04
Browse files Browse the repository at this point in the history
  • Loading branch information
schlawg committed May 10, 2024
1 parent f7a266e commit e528e56
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 95 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
**/*.nnue

/fishes
/*.js
/*.wasm

.vscode/
.DS_Store
38 changes: 14 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,39 @@ Multiple stockfish wasms for use in lichess.org web analysis

## Building
```
./build.py --flags='-O0 -g3 -sSAFE_HEAP' <target(s)>
# Example: Make debug builds for node with SAFE_HEAP
./build.py --flags='-O0 -g3 -sSAFE_HEAP' --node all
```
Include `--node` for nodejs instead of web. `--flags` for em++ compile and link. Available
targets are `clean`, `all`, `sf-nnue-40`, `sf-nnue-60`, `linrock-nnue-7`, `linrock-nnue-12`,
and `fsf-hce`.
Omit `--node` for default web builds. omit `--flags` to use default em++ flags (-O3 -DNDEBUG --closure=1)
Available targets are `clean`, `all`, `sf16-40`, `sf16-linrock-7`, and `fsf14`.

`./build.py` downloads all stockfish sources to the `./fishes` folder. It then applies git diffs
from the `./patches` folder. Edit the Stockfish sources freely. But to share them here, update
one of the patch files.
`./build.py` downloads sources to the `./fishes` folder. It then applies diffs from the `./patches` folder.
Finally, it builds the targets in the `./builds` folder. Edit the Stockfish sources freely. But to share
them here, you must update the patch file.

```
# Example: Update `sf-nnue-60.patch` with your source changes:
# Example: Update `sf16-linrock-7.patch` with your source changes:
cd fishes/sf-nnue-60
git diff > ../../patches/sf-nnue-60.patch
cd fishes/sf16-linrock-7
git diff > ../../patches/sf16-linrock-7.patch
```

## Sources


This maps targets to their ancestor repo/commit:

### sf-nnue-60
- repo: https://github.com/official-stockfish/Stockfish
- commit: [0024133](https://github.com/official-stockfish/Stockfish/commit/0024133)
- nnue: [nn-0000000000a0.nnue](https://tests.stockfishchess.org/nns?network_name=nn-0000000000a0)

### sf-nnue-40
### sf16-40
- repo: https://github.com/official-stockfish/Stockfish
- commit: [68e1e9b](https://github.com/official-stockfish/Stockfish/commit/68e1e9b)
- tag: sf_16
- nnue: [nn-5af11540bbfe.nnue](https://tests.stockfishchess.org/nns?network_name=nn-5af11540bbfe)

### linrock-nnue-12
- repo: https://github.com/linrock/Stockfish
- commit: [be1b8e0](https://github.com/linrock/Stockfish/commit/be1b8e0)
- nnue: [nn-4fd273888b72.nnue](https://tests.stockfishchess.org/nns?network_name=nn-ecb35f70ff2a)

### linrock-nnue-7
### sf16-linrock-7
- repo: https://github.com/linrock/Stockfish
- commit: [c97f5cb](https://github.com/linrock/Stockfish/commit/c97f5cb)
- nnue: [nn-ecb35f70ff2a.nnue](https://tests.stockfishchess.org/nns?network_name=nn-ecb35f70ff2a)

### fsf-hce
### fsf14
- repo: https://github.com/fairy-stockfish/Fairy-Stockfish
- commit: [a621470](https://github.com/fairy-stockfish/Fairy-Stockfish/commit/a621470)
19 changes: 12 additions & 7 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
patches_dir = os.path.join(script_dir, "patches")

targets = {
"sf-nnue-40": {"url": "https://github.com/official-stockfish/Stockfish", "commit": "68e1e9b"},
"fsf": {"url": "https://github.com/fairy-stockfish/Fairy-Stockfish", "commit": "a621470"},
"sf16-40": {"url": "https://github.com/official-stockfish/Stockfish", "commit": "68e1e9b"},
"sf16-linrock-7": {"url": "https://github.com/official-stockfish/Stockfish", "commit": "68e1e9b"},
"fsf14": {"url": "https://github.com/fairy-stockfish/Fairy-Stockfish", "commit": "a621470"},
}

ignore_sources = ["syzygy/tbprobe.cpp", "pyffish.cpp", "ffishjs.cpp"]
Expand Down Expand Up @@ -62,13 +63,13 @@ def main():
parser.add_argument(
"target",
nargs="*",
help=f"{', '.join(list(targets.keys()))}, clean, or all (default: 'sf-nnue-60')",
help=f"{', '.join(list(targets.keys()))}, clean, or all (default: 'sf16-40')",
)

args = parser.parse_args()
arg_targets = list(args.target)
if len(arg_targets) == 0:
arg_targets = ["sf-nnue-60"]
arg_targets = ["sf16-40"]

if "clean" in arg_targets:
clean()
Expand All @@ -78,6 +79,7 @@ def main():
arg_targets = list(targets.keys())

if len(arg_targets) > 0:
assert_emsdk()
print(f"building: {', '.join(arg_targets)}{' for node.js' if args.node else ''}")
print(f"flags: {args.flags}")
print("")
Expand Down Expand Up @@ -149,16 +151,19 @@ def assert_emsdk():
print("Error:", result.stderr)
exit(1)

version_match = re.search(f"(\d+)\.(\d+)\.(\d)", result)
version_match = re.search(r"([\d]+)\.([\d]+)\.([\d]+)", result.stdout)
if version_match:
major, minor, patch = version_match.groups()
if int(major) < 3 or (int(major) == 3 and int(minor) < 1) or (int(major) == 3 and int(minor) == 1 and int(patch) < 59):
print("emsdk 3.1.59 or later is required.")
print("emsdk 3.1.59 or later is required")
exit(1)
else:
return
else:
print("could not determine emcc version")
exit(1)
except FileNotFoundError:
print("emcc not installed or not found in the system path.")
print("emcc not installed or not found in the system path")
exit(1)


Expand Down
Loading

0 comments on commit e528e56

Please sign in to comment.