Add a utils modules for helper functions

This commit is contained in:
Sameer Rahmani 2023-04-07 11:06:48 +01:00
parent 0152c82f3e
commit 8c339d6e81
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
3 changed files with 40 additions and 17 deletions

40
conf/utils.py Normal file
View File

@ -0,0 +1,40 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
class current_dir:
def __init__(self, path):
self.current = os.getcwd()
self.target = path
def __enter__(self):
print(f"Entering dir: {self.target} from: {self.current}")
os.chdir(self.target)
return self
def __exit__(self, exc_type, exc_value, exc_traceback):
print(f"Exiting dir: {self.target}")
os.chdir(self.current)
def with_static_flags(cmake_vars):
cmake_vars["CMAKE_C_FLAGS"] = f"-static {cmake_vars.get('CMAKE_C_FLAGS', '')}"
cmake_vars["CMAKE_CXX_FLAGS"] = f"-static {cmake_vars.get('CMAKE_CXX_FLAGS', '')}"
cmake_vars[
"CMAKE_EXE_LINKER_FLAGS_INIT"
] = f"-static {cmake_vars.get('CMAKE_EXE_LINKER_FLAGS_INIT', '')}"
return cmake_vars

View File

View File

@ -1,17 +0,0 @@
# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(CMAKE_USE_OPENSSL OFF CACHE BOOL "")
set(BUILD_TESTING OFF CACHE BOOL "")