mirror of
https://github.com/tiyn/yeschess.git
synced 2026-02-22 10:34:47 +01:00
configs and projectPath
In the last few commits the problem occured that absolute paths are needed for correct and unambiguous locations for binary files or the database. For the compiler arguments the problem is now solved with an automatic script, that creates the absolute paths automatically for different systems. The database path is now specified by calling a new function, that finds the root of the project followed by a relative path.
This commit is contained in:
@@ -2,7 +2,7 @@ import nimpy
|
||||
import asyncnet, asyncdispatch
|
||||
|
||||
import chess
|
||||
import secret
|
||||
import engine/secret
|
||||
import engine/engine
|
||||
|
||||
let berserk = pyImport("berserk")
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
--outdir:"../../bin/src"
|
||||
@@ -3,10 +3,12 @@ import sequtils
|
||||
import strutils
|
||||
import sugar
|
||||
import tables
|
||||
import os
|
||||
|
||||
include chess
|
||||
|
||||
import secret
|
||||
import project
|
||||
|
||||
type
|
||||
BookMove* = object
|
||||
@@ -20,7 +22,7 @@ type
|
||||
rating*: int # `rating` is the average rating of the player to move.
|
||||
|
||||
|
||||
let dbConn = projectdir & "src/engine/openings.db"
|
||||
let dbConn = joinPath(getProjRootDir(), "ressources/openings.db")
|
||||
let dbUser = ""
|
||||
let dbPasswd = ""
|
||||
let dbName = ""
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
--outdir:"../bin/src"
|
||||
--path:"."
|
||||
15
src/project.nim
Normal file
15
src/project.nim
Normal file
@@ -0,0 +1,15 @@
|
||||
import os
|
||||
|
||||
proc getProjRootDir*(): string =
|
||||
## Returns the root directory for the ychess project.
|
||||
var maxDepth = 4
|
||||
var path = os.getCurrentDir()
|
||||
var projectDir: string
|
||||
while maxDepth > 0:
|
||||
if dirExists(joinPath(path, "src")):
|
||||
projectDir = path
|
||||
break
|
||||
else:
|
||||
path = parentDir(path)
|
||||
maxDepth -= 1
|
||||
return projectDir
|
||||
Reference in New Issue
Block a user