Skip to main content

A lightweight cross-platform C/C++ build system written in Python.

Project description

make0

make0 是一個輕量級、跨平台的 C/C++ 專案建置工具。

安裝

pip install make0

使用方法

在專案目錄下建立

檔案: make0.py

app = target("ssl_app")
app.set_kind("binary")
app.add_files("main.c", "math_utils.c")
app.add_packages("openssl")

檔案: main.c

#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>  // 由 pmake 的 add_packages("openssl") 處理路徑
#include "math_utils.h"

int main() {
    // 1. 測試自定義函式庫
    int num = 5;
    printf("--- pmake 跨平台測試 ---\n");
    printf("數字 %d 的平方是: %d\n", num, square(num));

    // 2. 測試 OpenSSL SHA256
    const char *data = "Hello make0!";
    unsigned char hash[SHA256_DIGEST_LENGTH];

    // 呼叫 OpenSSL 函式
    SHA256((unsigned char*)data, strlen(data), hash);

    printf("字串: \"%s\"\n", data);
    printf("SHA256 結果: ");
    for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
        printf("%02x", hash[i]);
    }
    printf("\n------------------------\n");

    return 0;
}

檔案: math_util.h

#ifndef MATH_UTILS_H
#define MATH_UTILS_H

int square(int a);

#endif

檔案: math_util.c

#include "math_utils.h"

int square(int a) {
    return a * a;
}

然後執行建置:

make0 build

這樣就會產生

(venv) cccuser@cccimacdeiMac hello_make0 % ls -all
total 104
drwxr-xr-x@ 8 cccuser  staff    256 Mar 15 17:32 .
drwxr-xr-x@ 3 cccuser  staff     96 Mar 15 17:32 ..
drwxr-xr-x@ 4 cccuser  staff    128 Mar 15 17:32 .pmake_cache
-rw-r--r--@ 1 cccuser  staff    752 Mar 15 20:14 main.c
-rw-r--r--@ 1 cccuser  staff     64 Mar 15 16:14 math_utils.c
-rw-r--r--@ 1 cccuser  staff     69 Mar 15 16:01 math_utils.h
-rw-r--r--@ 1 cccuser  staff    195 Mar 15 16:28 make0file
-rwxr-xr-x@ 1 cccuser  staff  33688 Mar 15 17:32 ssl_app

最後你就可以執行

(venv) cccuser@cccimacdeiMac hello_make0 % make0    
🛠️  正在建置目標: ssl_app
  [CC] main.c
  [LINK] ssl_app
✅ 建置成功: ssl_app

(venv) cccuser@cccimacdeiMac hello_make0 % ./ssl_app
--- pmake 跨平台測試 ---
數字 5 的平方是: 25
字串: "Hello make0!"
SHA256 結果: 7125ba4e245a131db68a904342602208aefed07ace1b6ea02a8efff3fb07b6a4
------------------------

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

make0-0.1.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

make0-0.1.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file make0-0.1.1.tar.gz.

File metadata

  • Download URL: make0-0.1.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for make0-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7c00b4cfa19289954728046d1548435d3405b48055d907c0f4dd1b98b82fb075
MD5 a725dbb88f374ff22af6d1ac92c77a17
BLAKE2b-256 e7bb963bde0c5c845f8c0c517403aab9e28997eff66e28fe427999d87b9da50f

See more details on using hashes here.

File details

Details for the file make0-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: make0-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for make0-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93971f761556627945cdab788bf5c77038c1d1470f2d2078bbd4c643f932adda
MD5 bd5c0fc60516a2000aa2e75998abef6e
BLAKE2b-256 9daefa997682ecd0f7c5ea72aefd869be15b4786e788c3b17bc8bac3214e98f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page