diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 61d5c21..5ffd0bf 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -6,124 +6,42 @@ on:
jobs:
- build-dist:
+ build:
runs-on: ubuntu-latest
steps:
#--------------------------------------------collect--------------------------------------------
- - uses: actions/checkout@v3
-
- - name: 🏷️ Get infomations
- run: |
- tag="${GITHUB_REF#refs/tags/}"
- echo "tag=$tag" >> $GITHUB_ENV
- echo "pkgname=cppp-platform-$tag" >> $GITHUB_ENV
- echo "srcdir=$(pwd)" >> $GITHUB_ENV
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-python@v5
+ with:
+ python-version: "3.13"
- name: 📁 Collect dependencies
run: |
sudo apt-get update
sudo apt-get install p7zip-full zip xz-utils -y
sudo apt-get install cmake gcc python3 -y
-
- #--------------------------------------------build--------------------------------------------
- - name: 🧳 Prepare for source distribution building
- run: |
- mkdir -p ./dist
- ./setup.sh
-
- - name: 🛠️ Build source distribution
- run: |
- ./cpppdist.py
-
- - name: 📦 Make packages
- run: |
- tar cvf ${{ env.pkgname }}.tar ${{ env.pkgname }}
- zip -r -9 dist/${{ env.pkgname }}.zip ${{ env.pkgname }}
- 7z a dist/${{ env.pkgname }}.7z ${{ env.pkgname }}
- xz -c -9 -k ${{ env.pkgname }}.tar > dist/${{ env.pkgname }}.tar.xz
- gzip -c -9 -k ${{ env.pkgname }}.tar > dist/${{ env.pkgname }}.tar.gz
-
- cd dist
- for i in $(ls) ; do md5sum $i > $i.md5 ; done
- cd ..
-
- #--------------------------------------------publish--------------------------------------------
-
- - name: ⬆️ Create release and upload assets
- uses: softprops/action-gh-release@v1
- with:
- tag_name: ${{ env.tag }}
- files: ./dist/*
+ python -m pip install --upgrade pip
+ python -m pip install rubisco
- build:
-
- needs: build-dist
-
- strategy:
- fail-fast: false
- matrix:
- arch: [
- any-any-any
- ]
-
- runs-on: ubuntu-latest
-
- steps:
-
- #--------------------------------------------collect--------------------------------------------
- - name: 🏷️ Get infomations
- run: |
- tag="${GITHUB_REF#refs/tags/}"
- echo "tag=$tag" >> $GITHUB_ENV
- echo "pkgname=cppp-platform-$tag" >> $GITHUB_ENV
- echo "srcdir=$(pwd)" >> $GITHUB_ENV
-
- - name: 📁 Collect dependencies
- run: |
- sudo apt-get update
- sudo apt-get install p7zip-full zip xz-utils wget -y
- sudo apt-get install cmake -y
- sudo apt-get install gcc g++ -y
-
- - name: 📁 Get source distribution tarball
- run: |
- wget https://github.com/${{ github.repository }}/releases/download/${{ env.tag }}/${{ env.pkgname }}.tar.gz
- tar zxvf ${{ env.pkgname }}.tar.gz
- mv ${{ env.pkgname }}/* .
-
#--------------------------------------------build--------------------------------------------
- - name: 🧳 Prepare for binary distribution building
+ - name: 🛠️ Build distribution
run: |
- mkdir -p dist
-
- - name: 🛠️ Build binary distribution
- run: |
- mkdir build
- cd build
- cmake .. -DCMAKE_INSTALL_PREFIX=${{ env.srcdir }}/${{ env.pkgname }}-${{ matrix.arch }}
- cmake --build . --config=Release
- cmake --install .
- cd ..
+ rubisco build
- name: 📦 Make packages
run: |
- tar cvf ${{ env.pkgname }}-${{ matrix.arch }}.tar ${{ env.pkgname }}-${{ matrix.arch }}
- zip -r -9 dist/${{ env.pkgname }}-${{ matrix.arch }}.zip ${{ env.pkgname }}-${{ matrix.arch }}
- 7z a dist/${{ env.pkgname }}-${{ matrix.arch }}.7z ${{ env.pkgname }}-${{ matrix.arch }}
- xz -c -9 -k ${{ env.pkgname }}-${{ matrix.arch }}.tar > dist/${{ env.pkgname }}-${{ matrix.arch }}.tar.xz
- gzip -c -9 -k ${{ env.pkgname }}-${{ matrix.arch }}.tar > dist/${{ env.pkgname }}-${{ matrix.arch }}.tar.gz
-
cd dist
- for i in $(ls) ; do md5sum $i > $i.md5 ; done
+ for i in $(ls) ; do sha256sum $i > $i.sha256 ; done
cd ..
#--------------------------------------------publish--------------------------------------------
- name: ⬆️ Create release and upload assets
- uses: softprops/action-gh-release@v1
+ uses: softprops/action-gh-release@v2
+ if: startsWith(github.ref, 'refs/tags/')
with:
- tag_name: ${{ env.tag }}
- files: ./dist/*
+ files: ./dist/*
diff --git a/.gitignore b/.gitignore
index 75b677f..4f9274d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
# CMake build files
build/
+dist/
+install/
CMakeFiles
*.so
*.so.*.*.*
@@ -33,9 +35,6 @@ Testing
.vscode
.cache
-# Autopull modules
-build-aux
-
# Dist directory and temps
-cppp-platform-v*
+cppp-platform-*
__pycache__
diff --git a/.rubisco/build.yaml b/.rubisco/build.yaml
new file mode 100644
index 0000000..7a9224d
--- /dev/null
+++ b/.rubisco/build.yaml
@@ -0,0 +1,43 @@
+name: 🛠️ Build cppp-platfrom
+
+steps:
+ - name: 📦 Make source distribution directory
+ mkdir: ${{ project.name }}-${{ project.version }}
+ - mkdir: dist
+
+ - name: 📦 Copy files to source distribution directory
+ copy: ${{ cwd }}
+ to: ${{ project.name }}-${{ project.version }}
+ excludes:
+ [
+ ".git*",
+ "build",
+ "dist",
+ "*.7z",
+ "*.gz",
+ "*.xz",
+ "*.zip",
+ ".vscode",
+ ".rubisco/extensions",
+ "${{ project.name }}-*",
+ ]
+
+ - name: 📦 Packing the source distribution
+ compress: ${{ project.name }}-${{ project.version }}
+ to: dist/${{ project.name }}-${{ project.version }}
+ format: [zip, tar.xz]
+
+ - name: 🛠️ Build the project.
+ mkdir: build
+ - cwd: build
+ run: ["cmake", "..", "-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_INSTALL_PREFIX=install"]
+ - cwd: build
+ run: ["cmake", "--build", ".", "--config", "Release"]
+ - cwd: build
+ run: ["cmake", "--install", ".", "--config", "Release"]
+
+ - name: 📦 Packing the binary distribution.
+ compress: build/install
+ start: build
+ to: dist/${{ project.name }}-${{ project.version }}-unknown-unknown-unknown
+ format: [zip, tar.xz]
diff --git a/CMakeLists.txt b/CMakeLists.txt
index abb91fc..e2c2385 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,55 +1,28 @@
-# Copyright (C) 2023 The C++ Plus Project.
-# This file is part of the cppp-platform library.
-#
-# The cppp-platform library is free software; you can redistribute it
-# and/or modify it under the terms of the The Unlicense as published
-# by the unlicense.org
-#
-# The cppp-platform library 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 The
-# Unlicense for more details.
-#
-# You should have received a copy of the The Unlicense along with the
-# cppp-platform library; see the file COPYING.
-# If not, see .
-
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.10)
project(cppp-platform VERSION 1.3.0)
-# Set C++ standard
-set(CMAKE_CXX_STANDARD 11)
-
-if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/build-aux")
- set(BUILD_AUX "${CMAKE_CURRENT_SOURCE_DIR}/build-aux")
-elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../build-aux")
- set(BUILD_AUX "${CMAKE_CURRENT_SOURCE_DIR}/../build-aux")
-else()
- message(FATAL_ERROR "CMake build-aux directory is not exists, try to execute 'setup.cmd' or './setup.sh' to get it.")
-endif()
-set(AUX_DIR "${BUILD_AUX}/cmake")
-
-message(STATUS "Using '${BUILD_AUX}' for C++ Plus build-aux directory.")
-add_subdirectory("${BUILD_AUX}")
-
-include("${AUX_DIR}/cppp.cmake")
+option(BUILD_EXAMPLE "Build example" OFF)
# Read source files
-file(READ "${srcdir}/src/architectures.h" ARCHITECTURES)
-file(READ "${srcdir}/src/compilers.h" COMPILERS)
-file(READ "${srcdir}/src/languagestandards.h" LANGUAGESTANDARDS)
-file(READ "${srcdir}/src/platforms.h" PLATFORMS)
+file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/architectures.h" ARCHITECTURES)
+file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/compilers.h" COMPILERS)
+file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/languagestandards.h" LANGUAGESTANDARDS)
+file(READ "${CMAKE_CURRENT_SOURCE_DIR}/src/platforms.h" PLATFORMS)
# Genetate header
-configure_file("${srcdir}/include/cppp/cppp-platform.h.in" "${output_includedir}/cppp/cppp-platform.h")
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/include/cppp/cppp-platform.h.in" "${CMAKE_BINARY_DIR}/include/cppp/cppp-platform.h")
+
+# Build example
+if(BUILD_EXAMPLE)
+ add_executable(example "${CMAKE_CURRENT_SOURCE_DIR}/src/example.c")
+ target_include_directories(example PRIVATE "${CMAKE_BINARY_DIR}/include")
+endif()
-# Generate header file for install
-cppp_nls_autotranslate("${output_includedir}/cppp/cppp-platform.h" "${srcdir}/lang")
# Install
# Includes
# PERMISSIONS 0644
-install(FILES "${output_includedir}/cppp/cppp-platform.h"
- DESTINATION "${install_includedir}"
+install(FILES "${CMAKE_BINARY_DIR}/include/cppp/cppp-platform.h"
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/include"
RENAME "cppp/cppp-platform.h"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ )
diff --git a/CPPPPKG b/CPPPPKG
deleted file mode 100644
index 9b7fe2c..0000000
--- a/CPPPPKG
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "name" : "cppp-platform",
- "version" : "1.3.0",
- "list_file_path": "FILELIST",
- "description": "Portable platform check library for C++ Plus.",
- "authors": [
- "The C++ Plus Project",
- "ChenPi11"
- ],
- "webpage": "https://github.com/cppp-project/cppp-platform",
- "subpackages": {
- "build-aux": { "path": "build-aux", "ignore": true }
- },
- "license": [
- "Unlicense"
- ]
-}
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index 1f00ce4..0000000
--- a/ChangeLog
+++ /dev/null
@@ -1,74 +0,0 @@
-2023-08-09 ChenPi11
-
- Add C++ Plus package infomation.
- Update docs.
- Add GitHub CI.
- Prepare for release v1.3.0.
-
-2023-08-08 ChenPi11
-
- Add CMake buildsystem support.
- Add submodule 'build-aux'.
- Add NLS Language Map.
-
-2023-08-07 ChenPi11
-
- Update docs.
- Change project structure.
- Remove Autoconf buildsystem support.
- Add ChangeLog.
- Rename the project to 'cppp-platform'.
-
-2023-06-01 ChenPi11
-
- Add prepare-release.
- Update build rules.
- - Add autoconf build script.
- - Remove MS-DOS support.
- - Remove CMake build rules.
- - Fix bugs.
- - Update docs.
- - Remove Python build script.
-
-2023-04-09 ChenPi11
-
- Add so many things.
- - 更新了GNU Make规则
- - 完善了README.md文档,添加了多种生成方式的说明和使用手册的链接
- - 添加了使用手册文档
- - 完善了Windows下make.cmd的生成方式
- - 将lparchs中__arch_xxx__和__arch__的值改为数字,方便预处理判断
- - 优化了lparchs宏的实现逻辑,避免某些编译器出错
- - 将lpcomps中的__has_acc__改为__has_acc_compiler__,统一命名
- - 删除lpstds的__has_c89__,因为它是世界上C语言的第一个标准,标准C语言都支持
- - 添加了Python版本的生成规则
- - 添加了MS-DOS下的生成方式
-
-2023-04-05 ChenPi11
-
- Add CMake and cmd build.
- - 添加了CMake生成方式和cmd.exe生成方式
- - 完善了项目结构
- - 完善了Makefile
- - 删除Python生成方式:make.py
- - 修复了一些bug
- - 将所有文件结尾由CR LF改为LF,make.cmd除外
- - 完善了README.md文档,添加生成方式和用法的说明
- - 修改了输出文件名,libplatform.h改名为platform_predef.h
- - 更新.gitignore
-
-2023-03-26 ChenPi11
-
- 1.0.1 Add Haiku OS support.
-
-2023-02-18 ChenPi11
-
- Update title.h
-
-2023-02-18 ChenPi11
-
- 1.0.0
-
-2023-02-18 ChenPi11
-
- Initial commit.
diff --git a/FILELIST b/FILELIST
deleted file mode 100644
index 38fb07b..0000000
--- a/FILELIST
+++ /dev/null
@@ -1,19 +0,0 @@
-README.md
-cpppdist.py
-doc/compilers.md
-doc/architectures.md
-doc/languagestandards.md
-doc/doc.md
-doc/platforms.md
-FILELIST
-include/cppp/cppp-platform.h.in
-src/platforms.h
-src/languagestandards.h
-src/architectures.h
-src/compilers.h
-CMakeLists.txt
-CPPPPKG
-lang/zh_CN.langmap
-lang/en_US.langmap
-ChangeLog
-COPYING
diff --git a/COPYING b/LICENSE
similarity index 100%
rename from COPYING
rename to LICENSE
diff --git a/README.md b/README.md
index b8f9f02..84776e4 100644
--- a/README.md
+++ b/README.md
@@ -1,39 +1,22 @@
-# Introduction
-cppp-platform is a portable platform check library for C++ Plus.
+# cppp-platfrom -- Portable platform check library
-# Build
-## Dependence
-+ CMake (version >= 3.12)
+## Build
+
+### Dependencies
+
++ CMake (version >= 3.10)
+
+### Command
-## Command
```shell
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=[[PREFIX]]
+# If you want to build the example, add -DBUILD_EXAMPLE=ON
cmake --build .
cmake --install .
```
-# Example
-After install, you can use cppp-platform in C/C++
-```c
-#include
-#include
-int main()
-{
- if(__has_windows__)
- {
- printf("Compile in Windows!\n");
- }
- else
- {
- printf("Compile non-Windows!\n");
- }
- printf("Target arch:%s\n",__arch__);
- printf("Target arch name:%s\n",__arch_name__);
- printf("Pointer width:%d\n",__POINTER_WIDTH__);
-}
-```
+## Documentation
-# Manual
-[User Manual](doc/doc.md)
+[Documentation](doc/doc.md)
diff --git a/cpppdist.py b/cpppdist.py
deleted file mode 100755
index f65e6bd..0000000
--- a/cpppdist.py
+++ /dev/null
@@ -1,195 +0,0 @@
-#!/usr/bin/env python3
-
-# Copyright (C) 2023 The C++ Plus Project.
-# This file is part of the cppp library.
-#
-# The cppp library is free software; you can redistribute it
-# and/or modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either version 3
-# of the License, or (at your option) any later version.
-#
-# The cppp library 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
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with the cppp library; see the file COPYING.
-# If not, see .
-
-# C++ Plus dist utils.
-
-import os
-import sys
-import json
-import shutil
-import importlib.util
-
-PACKAGE_INFO = "CPPPPKG"
-PROGNAME = "cpppdist.py"
-
-def import_file(path):
- """
- Import a Python file from it's path
-
- Args:
- path (str): Python file's path
-
- Raises:
- ModuleNotFoundError: When module invalid, load error or not found.
-
- Returns:
- ModuleType: module
- """
- spec = importlib.util.spec_from_file_location(os.path.basename(path).replace(".py", ""), path)
- if(spec == None):
- raise ModuleNotFoundError("Invalid module or module not found: " + path)
- module = importlib.util.module_from_spec(spec)
- spec.loader.exec_module(module)
- return module
-
-class Package:
- """
- A dist package type
- """
- name = ""
- version = ""
- list_file_path = ""
- filelist = []
- subpackages = {}
-
- def __init__(self, pkginfo_filepath) -> None:
- try:
- os.chdir(fwd)
- with open(pkginfo_filepath, "r", encoding="UTF-8") as info_file:
- data = json.load(info_file)
- self.name = data["name"]
- self.version = data["version"]
- self.list_file_path = data["list_file_path"]
- try:
- _subpackages = data["subpackages"]
- for pkgname in _subpackages:
- pkgpath = _subpackages[pkgname]["path"]
- try:
- pkgmodule = import_file(os.path.join(pkgpath, PROGNAME))
- self.subpackages[pkgpath] = pkgmodule.package
- except Exception as e:
- if(not _subpackages[pkgname]["ignore"]):
- raise
- else:
- print(f"DEBUG: Ignore a subpackage '{pkgname}': {e}", file=sys.stderr)
- except KeyError:
- pass
- self.filelist = self.get_file_list()
- finally:
- os.chdir(cwd)
-
- def get_file_list(self) -> list:
- """
- Get file list for dist.
- """
- try:
- os.chdir(fwd)
- file_list = []
- with open(self.list_file_path, "rt", encoding="UTF-8") as list_file:
- data = list_file.read()
- file_list = data.strip().split("\n")
- return file_list
- finally:
- os.chdir(cwd)
-
- def copy_files(self, dest):
- """
- Copy files to dist dest
- """
- try:
- os.chdir(fwd)
- if(os.path.exists(dest)):
- shutil.rmtree(dest)
- print(f"Copy package '{self.name}' to '{dest}' ... ", file=sys.stderr)
- progressbar = ProgressBar(len(self.filelist))
- for file in self.filelist:
- relpath = os.path.relpath(file, fwd)
- filedir = os.path.abspath(os.path.join(dest, relpath, ".."))
- if(not os.path.exists(filedir)):
- os.makedirs(filedir)
- shutil.copy(file, os.path.join(dest, relpath))
- progressbar.add(1)
- progressbar.end()
- print("", end="\n", file=sys.stderr)
- # Copy subpackages
- for (pkgpath, pkg) in self.subpackages.items():
- pkg.copy_files(os.path.join(dest, os.path.join(dest, pkgpath)))
- finally:
- os.chdir(cwd)
-
-class ProgressBar:
- """
- Progress bar type.
- """
- def __init__(self, total):
- self.total = total
- self.cur = 0
- sys.stderr.write("\n")
- self.update()
-
- def add(self, step):
- """
- Add current value and update.
- """
- self.cur += step
- self.update()
-
- def set(self, cur):
- """
- Set current value and update.
- """
- self.cur = cur
- self.update()
-
- def update(self):
- """
- Update progress bar.
- """
- try:
- progress = 0.0
- if(self.cur):
- progress = self.cur / self.total
- term_width = os.get_terminal_size(sys.stderr.fileno()).columns
- part_width = term_width - len("[]100.0%")
- if(part_width <= 0):
- # Terminal is too small, ignore.
- return
- sys.stderr.write("\r")
- # Part1 is '#'
- part1 = int(part_width * progress) * '#'
- # Part2 is ' '
- part2 = int(part_width - len(part1)) * ' '
- # Part3 is 'xxx.x%'
- part3 = str(int(progress * 1000) / 10) + "%"
- sys.stderr.write(f"[{part1}{part2}]{part3}")
- sys.stderr.flush()
- except:
- return
-
- def end(self):
- """
- End this progress bar
- """
- self.set(self.total)
- sys.stderr.write("\n")
- sys.stderr.flush()
-
-cwd = os.path.abspath(os.curdir)
-fwd = os.path.abspath(os.path.join(__file__, ".."))
-
-package = None
-try:
- package = Package(PACKAGE_INFO)
-except Exception as exc:
- print("Getting packge infomation error:", exc, file=sys.stderr)
- raise exc
-
-if __name__ == "__main__":
- distdir = f"{package.name}-v{package.version}"
- package.copy_files(os.path.abspath(distdir))
diff --git a/doc/architectures.md b/doc/architectures.md
index c3b8892..e3878a0 100644
--- a/doc/architectures.md
+++ b/doc/architectures.md
@@ -1,14 +1,23 @@
# Architectures
+
## Source
-src/architectures.h
-## Content
+
+[src/architectures.h](https://github.com/cppp-project/cppp-platform/blob/main/src/architectures.h)
+
+## Contents
+
### \_\_arch\_\_
-#### Type
-macros
-#### Description
-Represents the processor architecture type
-If the judgment fails, the value is '\_\_arch_unknown\_\_'
-#### We provide preset architecture macros
+
+#### The type of \_\_arch\_\_
+
+macro
+
+#### Description of \_\_arch\_\_
+
+Represents the processor architecture type. If the judgment fails, the value is set to '\_\_arch_unknown\_\_'.
+
+#### Value of \_\_arch\_\_
+
| Architecture | Macro |
| :----: | :----: |
| Alpha | \_\_arch_alpha\_\_ |
@@ -31,40 +40,60 @@ If the judgment fails, the value is '\_\_arch_unknown\_\_'
| TMS470 | \_\_arch_tms470\_\_8 |
| Unknown architecture | \_\_arch_unknown\_\_ |
-#### Usage
+#### Example of \_\_arch\_\_
+
```c
#include
+
#if (__arch__ == __arch_x86__)
-#pragma message "Build in x86 arch"
+#pragma message "Build in x86."
#elif (__arch__ == __arch_arm__)
-#pragma message "Build in arm arch"
+#pragma message "Build in arm."
#elif
-#pragma message "Build in other arch"
+#pragma message "Build in other."
#endif
-int main(){}
+
+int main()
+{
+ return 0;
+}
```
+
### \_\_arch_name\_\_
-#### Type
+
+#### Type of \_\_arch_name\_\_
+
macro
-#### Description
-Architecture name, like 'uname -m'
-If the judgment fails, the value is "unknown"
-#### Usage
+
+#### Description of \_\_arch_name\_\_
+
+Architecture name, like `uname -m`. If the judgment fails, the value is `"Unknown"`.
+
+#### Example of \_\_arch_name\_\_
+
```c
#include
+
#include
+
int main()
{
printf("Arch name: %s\n", __arch_name__);
}
```
+
### \_\_POINTER_WIDTH\_\_
-#### Type
+
+#### Type of \_\_POINTER_WIDTH\_\_
+
macro
-#### Description
-This represents the calculation formula for pointer length
-The value is generally 32 or 64
-#### Usage
+
+#### Description of \_\_POINTER_WIDTH\_\_
+
+This represents the pointer length. The value is generally 32 or 64.
+
+#### Example of \_\_POINTER_WIDTH\_\_
+
```c
#include
#include
diff --git a/doc/compilers.md b/doc/compilers.md
index 3861145..fafee4c 100644
--- a/doc/compilers.md
+++ b/doc/compilers.md
@@ -1,24 +1,27 @@
# Compilers
+
## Source
-src/compilers.h
+
+[src/compilers.h](https://github.com/cppp-project/cppp-platform/blob/main/src/compilers.h)
+
## Content
+
### \_\_has_xxx_compiler\_\_
-#### Type
-macros
-#### Description
-1 if there is a corresponding compiler, otherwise 0.
-The 'xxx' here refers to the compiler name, and details can be found in the 'src/compilers.h' source code.
-
-**Note: An environment may contain multiple compiler environments.**
-#### Usage
-```c
-#include
-#if __has_msvc_compiler__
-#error "This project do not support MSVC!"
-#endif
-int main(){}
-```
-#### We provide preset compiler macros
+
+#### Type of \_\_has_xxx_compiler\_\_
+
+macro
+
+#### Description of \_\_has_xxx_compiler\_\_
+
+`1` if there is a corresponding compiler, otherwise `0`.
+
+The 'xxx' here refers to the compiler name, and details can be found in the `src/compilers.h` source code.
+
+**Note: An environment may contain multiple compiler environments, so multiple compiler macros may be defined at the same time. e.g. `__has_gcc_compiler__`, `__has_clang_compiler__`.**
+
+#### Compiler List
+
| Compiler | Macro |
| :----: | :----: |
| ACC | \_\_has_acc_compiler\_\_ |
@@ -92,3 +95,18 @@ int main(){}
| VBCC | \_\_has_vbcc_compiler\_\_ |
| Watcom C++ | \_\_has_watcom_compiler\_\_ |
| Zortech C++ | \_\_has_zortech_compiler\_\_ |
+
+#### Example of \_\_has_xxx_compiler\_\_
+
+```c
+#include
+
+#if __has_msvc_compiler__
+#error "This project do not support MSVC!"
+#endif
+
+int main()
+{
+ return 0;
+}
+```
diff --git a/doc/doc.md b/doc/doc.md
index ff30986..89510ae 100644
--- a/doc/doc.md
+++ b/doc/doc.md
@@ -1,4 +1,5 @@
-# cppp-platform Manual
+# cppp-platform Documentation
+
[Architectures](./architectures.md)
[Compilers](./compilers.md)
diff --git a/doc/languagestandards.md b/doc/languagestandards.md
index c05337b..ddcd58f 100644
--- a/doc/languagestandards.md
+++ b/doc/languagestandards.md
@@ -1,44 +1,81 @@
# C/C++ Standards
+
## Source
-src/languagestandards.h
+
+[src/languagestandards.h](https://github.com/cppp-project/cppp-platform/blob/main/src/languagestandards.h)
+
## Content
-## \_\_has_cXX\_\_
-#### Type
-macros
-#### Description
+
+### \_\_has_cXX\_\_
+
+#### Type of \_\_has_cXX\_\_
+
+macro
+
+#### Description of \_\_has_cXX\_\_
+
The 'XX' here refers to the C standard, and details can be found in the 'src/languagestandards.h' source code.
+
#### Usage
+
```c
#include
+
#if __has_c11__
#pragma message "You are in C11."
#endif
-int main(){}
+
+int main()
+{
+ return 0;
+}
```
-## \_\_has_cppXX\_\_
-#### Type
-macros
-#### Description
-The 'XX' here refers to the C++ standard, and details can be found in the 'src/languagestandards.h' source code.
-#### Usage
+
+### \_\_has_cppXX\_\_
+
+#### Type of \_\_has_cppXX\_\_
+
+macro
+
+#### Description of \_\_has_cppXX\_\_
+
+The 'XX' here refers to the C++ standard, and details can be found in the `src/languagestandards.h` source code.
+
+#### Usage of \_\_has_cppXX\_\_
+
```c
#include
+
#if __has_cpp17__
#pragma message "You are in C++17."
#endif
-int main(){}
+
+int main()
+{
+ return 0;
+}
```
-## \_\_cpp_version\_\_
-#### Type
+
+### \_\_cpp_version\_\_
+
+#### Type of \_\_cpp_version\_\_
+
macro
-#### Description
+
+#### Description of \_\_cpp_version\_\_
+
C++ standard for fixing issues with '\_MSVC_LANG'
-### Usage
+
+### Usage of \_\_cpp_version\_\_
+
```cpp
#include
+
#include
+
int main()
{
- std::cout<<__cpp_version__<<"\n";
+ std::cout << __cpp_version__ << std::endl;
+ return EXIT_SUCCESS;
}
```
diff --git a/doc/platforms.md b/doc/platforms.md
index c9ffe41..8621c66 100644
--- a/doc/platforms.md
+++ b/doc/platforms.md
@@ -1,24 +1,27 @@
# Platforms
+
## Source
-src/platforms.h
+
+[src/platforms.h](https://github.com/cppp-project/cppp-platform/blob/main/src/platforms.h)
+
## Content
-## \_\_has_xxx\_\_
-#### Type
-macros
-#### Description
-If there is a corresponding OS environment, it is 1, otherwise it is 0.
-The 'xxx' here refers to the OS name, and details can be found in the 'src/platforms.h' source code.
-
-**Note: An compile environment may contain multiple environments**
-#### Usage
-```c
-#include
-#if __has_windows__
-#error "We do not support Windows!"
-#endif
-int main(){}
-```
+
+### \_\_has_xxx\_\_
+
+#### Type of \_\_has_xxx\_\_
+
+macro
+
+#### Description of \_\_has_xxx\_\_
+
+If there is a corresponding OS environment, it is `1`, otherwise it is `0`.
+
+The 'xxx' here refers to the OS name, and details can be found in the `src/platforms.h` source code.
+
+**Note: An compile environment may contain multiple environments at the same time. e.g. Cygwin Environment is a Unix-like environment, but it is also a Windows environment.**
+
#### We provide preset compiler macros
+
| Platform | Macro |
| :----: | :----: |
| AIX | \_\_has_aix\_\_ |
@@ -51,7 +54,7 @@ int main(){}
| MinGW | \_\_has_mingw\_\_ |
| MorphOS | \_\_has_morph_os\_\_ |
| MPE/iX | \_\_has_mpe_ix\_\_ |
-| MSDOS (C++ Plus C unsupport platform) | \_\_has_dos\_\_ |
+| MSDOS | \_\_has_dos\_\_ |
| NonStop | \_\_has_non_stop\_\_ |
| Nucleus RTOS | \_\_has_nucleus\_\_ |
| OS/2 | \_\_has_os2\_\_ |
@@ -80,3 +83,18 @@ int main(){}
| Windows CE | \_\_has_windows_ce\_\_ |
| Wind/U Environment | \_\_has_windu\_\_ |
| z/OS | \_\_has_zos\_\_ |
+
+#### Example of \_\_has_xxx\_\_
+
+```c
+#include
+
+#if __has_windows__
+#error "We do not support Windows!"
+#endif
+
+int main()
+{
+ return 0;
+}
+```
diff --git a/include/cppp/cppp-platform.h.in b/include/cppp/cppp-platform.h.in
index affa290..92706a6 100644
--- a/include/cppp/cppp-platform.h.in
+++ b/include/cppp/cppp-platform.h.in
@@ -1,31 +1,14 @@
/**
* @file cppp/cppp-platform.h
* @author ChenPi11
- * @copyright Copyright (C) 2023 The C++ Plus Project
- * @date 2023-08-07
* @brief C++ Plus platform predefined detection.
* @version @PROJECT_VERSION@
- * @see https://sourceforge.net/p/predef/wiki/Home/
+ * @see https://github.com/cpredef/predef
* @link https://github.com/cppp-project/cppp-platform
*/
-/* Copyright (C) 2023 The C++ Plus Project
- This file is part of the cppp-platform library.
- The cppp-platform library is free software; you can redistribute it
- and/or modify it under the terms of the The Unlicense as published
- by the unlicense.org
-
- The cppp-platform library 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 The
- Unlicense for more details.
-
- You should have received a copy of the The Unlicense along with the
- cppp-platform library; see the file COPYING.
- If not, see . */
-
-#ifndef _CPPP_PLATFORM_H
-#define _CPPP_PLATFORM_H
+#ifndef _CPPP_PLATFORM_H_INCLUDED
+#define _CPPP_PLATFORM_H_INCLUDED 1
/* Architectures detection. */
@ARCHITECTURES@
diff --git a/lang/en_US.langmap b/lang/en_US.langmap
deleted file mode 100644
index b7efe0a..0000000
--- a/lang/en_US.langmap
+++ /dev/null
@@ -1,96 +0,0 @@
-# C++ Plus NLS Util language map for cppp-platform.
-# en_US
-
-'''
-/* Copyright (C) 2023 The C++ Plus Project
- This file is part of the cppp-platform library.
-
- The cppp-platform library is free software; you can redistribute it
- and/or modify it under the terms of the The Unlicense as published
- by the unlicense.org
-
- The cppp-platform library 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 The
- Unlicense for more details.
-
- You should have received a copy of the The Unlicense along with the
- cppp-platform library; see the file COPYING.
- If not, see . */
-'''
-/* Copyright (C) 2023 The C++ Plus Project
- This file is part of the cppp-platform library.
-
- The cppp-platform library is free software; you can redistribute it
- and/or modify it under the terms of the The Unlicense as published
- by the unlicense.org
-
- The cppp-platform library 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 The
- Unlicense for more details.
-
- You should have received a copy of the The Unlicense along with the
- cppp-platform library; see the file COPYING.
- If not, see . */
-'''
-
-'''
-/* Architectures detection. */
-'''
-/* Architectures detection. */
-'''
-
-'''
-/* Fix amd64 and 8086 bug */
-'''
-/* Fix amd64 and 8086 bug */
-'''
-
-'''
-/* Compilers detection. */
-'''
-/* Compilers detection. */
-'''
-
-'''
-/* C/C++ standards detection. */
-'''
-/* C/C++ standards detection. */
-'''
-
-'''
-/* Platforms detection. */
-'''
-/* Platforms detection. */
-'''
-
-'''
-/* Unknown architectures */
-'''
-/* Unknown architectures */
-'''
-
-'''
-/* Usually C17 means C18. */
-'''
-/* Usually C17 means C18. */
-'''
-
-'''
-/* C++ predefines */
-'''
-/* C++ predefines */
-'''
-
-'''
-/* Fix MSVC++ __cplusplus's feature. */
-'''
-/* Fix MSVC++ __cplusplus's feature. */
-'''
-
-'''
-/* C++ version */
-'''
-/* C++ version */
-'''
diff --git a/lang/zh_CN.langmap b/lang/zh_CN.langmap
deleted file mode 100644
index 9aa8eff..0000000
--- a/lang/zh_CN.langmap
+++ /dev/null
@@ -1,90 +0,0 @@
-# C++ Plus NLS Util language map for cppp-platform.
-# zh_CN
-
-'''
-/* Copyright (C) 2023 The C++ Plus Project
- This file is part of the cppp-platform library.
-
- The cppp-platform library is free software; you can redistribute it
- and/or modify it under the terms of the The Unlicense as published
- by the unlicense.org
-
- The cppp-platform library 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 The
- Unlicense for more details.
-
- You should have received a copy of the The Unlicense along with the
- cppp-platform library; see the file COPYING.
- If not, see . */
-'''
-/* 版权所有 (C) 2023 The C++ Plus Project
- 本文件是 cppp-platform 库的一部分。
-
- cppp-platform 库是自由软件;您可以在 unlicense.org 上发布的 The Unlicense 条款下重新分发或修改它。
- cppp-platform 库是基于无任何保证的;没有明示的保证,包括但不限于适销性或对特定用途的适用性。
- 有关更多细节,请参阅 The Unlicense。
-
- 您应该已经收到了 The Unlicense 的副本,与 cppp-platform 库一起;请参阅 COPYING 文件。
- 如果没有收到,请访问 。 */
-'''
-
-'''
-/* Architectures detection. */
-'''
-/* CPU 架构检测。 */
-'''
-
-'''
-/* Fix amd64 and 8086 bug */
-'''
-/* 修复 amd64 和 8086 检测的错误 */
-'''
-
-'''
-/* Compilers detection. */
-'''
-/* 编译器检测。 */
-'''
-
-'''
-/* C/C++ standards detection. */
-'''
-/* C/C++ 标准检测。 */
-'''
-
-'''
-/* Platforms detection. */
-'''
-/* 平台检测 */
-'''
-
-'''
-/* Unknown architectures */
-'''
-/* 未知的 CPU 架构 */
-'''
-
-'''
-/* Usually C17 means C18. */
-'''
-/* 通常, C17 和 C18 相同。 */
-'''
-
-'''
-/* C++ predefines */
-'''
-/* C++ 预定义 */
-'''
-
-'''
-/* Fix MSVC++ __cplusplus's feature. */
-'''
-/* 修复了 MSVC++ __cplusplus 宏值错误的问题 */
-'''
-
-'''
-/* C++ version */
-'''
-/* C++ 标准 */
-'''
diff --git a/repo.json b/repo.json
new file mode 100644
index 0000000..a53e27c
--- /dev/null
+++ b/repo.json
@@ -0,0 +1,38 @@
+{
+ "name": "cppp-platform",
+ "version": "1.4.0",
+ "description": "C+++ portable platform check library.",
+ "maintainer": "ChenPi11 ",
+ "license": "Unlicense",
+ "hooks": {
+ "build": {
+ "run": ".rubisco/build.yaml"
+ },
+ "format": {
+ "exec": "python -m ruff format rubisco"
+ },
+ "test": {
+ "run": ".rubisco/test.yaml"
+ },
+ "clean": {
+ "workflow": [
+ {
+ "name": "Clean workflow",
+ "remove": [
+ "build",
+ "dist",
+ "*/**/__pycache__",
+ ".rubisco/*.log",
+ "*.7z",
+ "*.gz",
+ "*.xz",
+ "*.zip",
+ "rubisco-*"
+ ],
+ "strict": false
+ }
+ ]
+ }
+ }
+ }
+
\ No newline at end of file
diff --git a/setup.cmd b/setup.cmd
deleted file mode 100644
index 21bbdf8..0000000
--- a/setup.cmd
+++ /dev/null
@@ -1,42 +0,0 @@
-@echo off
-rem Setup a repository during individual development.
-rem
-rem This script requires git program in the PATH.
-
-rem Copyright (C) 2023 The C++ Plus Project.
-rem
-rem This program is free software: you can redistribute it and/or modify
-rem it under the terms of the GNU Lesser General Public License as published by
-rem the Free Software Foundation; either version 3 of the License, or
-rem (at your option) any later version.
-rem
-rem This program is distributed in the hope that it will be useful,
-rem but WITHOUT ANY WARRANTY; without even the implied warranty of
-rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-rem GNU Lesser General Public License for more details.
-rem
-rem You should have received a copy of the GNU Lesser General Public License
-rem along with this program. If not, see .
-
-rem Usage: setup.cmd
-
-if exist .\build-aux (
- echo Success: '.\build-aux' is exists, please don't remove it, and you can develop this package normally.
- goto QUIT
-)
-
-if exist ..\build-aux (
- echo Success: '..\build-aux' is exists, please don't remove it, and you can develop this package normally.
- goto QUIT
-)
-
-echo Notice: '..\build-aux' for C++ Plus are not exists, cloning it......
-git clone https://github.com/cppp-project/build-aux
-if %errorlevel%==0 (
- echo Success: '.\build-aux' cloned successfully, please don't remove it, and you can develop this package normally.
-) else (
- echo Error: .\build-aux' cloned failed, you can clone it by yourself or copy it from C++ Plus release source package.
- echo Notice: try to run 'git clone https://github.com/cppp-project/build-aux'.
-)
-
-:QUIT
diff --git a/setup.sh b/setup.sh
deleted file mode 100755
index a6b5997..0000000
--- a/setup.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env sh
-# Setup a repository during individual development.
-#
-# This script requires git program in the PATH.
-
-# Copyright (C) 2023 The C++ Plus Project.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# 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 Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
-
-# Usage: ./setup.sh
-#
-
-# Usage: text_out [color_id] [level] [msg]
-text_out()
-{
- echo "\033[$1m$2: $3 \033[0m"
-}
-
-# Usage: execute [command]
-execute()
-{
- text_out 94 "$1"
- $1
- return $?
-}
-
-if test -d './build-aux'
-then
- text_out 32 "Success" "'./build-aux' is exists, please don't remove it, and you can develop this package normally."
- exit 0
-fi
-
-if test -d '../build-aux'
-then
- text_out 32 "Success" "'../build-aux' is exists, please don't remove it, and you can develop this package normally."
- exit 0
-fi
-
-text_out 0 "Notice" "'../build-aux' for C++ Plus are not exists, cloning it......"
-execute "git clone https://github.com/cppp-project/build-aux"
-if [ $? -eq 0 ]
-then
- text_out 32 "Success" "'./build-aux' cloned successfully, please don't remove it, and you can develop this package normally."
-else
- text_out 31 "Error" "'./build-aux' cloned failed, you can clone it by yourself or copy it from C++ Plus release source package."
- text_out 0 "Notice" "try to run 'git clone https://github.com/cppp-project/build-aux'. "
-fi
diff --git a/src/architectures.h b/src/architectures.h
index 19f4632..e19981f 100644
--- a/src/architectures.h
+++ b/src/architectures.h
@@ -38,7 +38,7 @@
#define __arch_unknown__ 0
#define __arch__ __arch_unknown__
-#define __arch_name__ "unknown"
+#define __arch_name__ "Unknown"
#if defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
#undef __arch__
#undef __arch_name__
diff --git a/src/example.c b/src/example.c
new file mode 100644
index 0000000..f6ad172
--- /dev/null
+++ b/src/example.c
@@ -0,0 +1,27 @@
+#include
+
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ if (argc != 1)
+ {
+ fprintf(stderr, "Usage: %s\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if (__has_windows__)
+ {
+ printf("Running on Windows!\n");
+ }
+ else
+ {
+ printf("Running non-Windows!\n");
+ }
+ printf("Target architcture id: %d\n", __arch__);
+ printf("Target arch name: %s\n", __arch_name__);
+ printf("Pointer width: %d\n", __POINTER_WIDTH__);
+
+ return EXIT_SUCCESS;
+}