ccgo 3.0.10

A high-performance C++ cross-platform build CLI
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
# ccgo

A cross-platform C++ build system designed to simplify and accelerate multi-platform development.

[![Crates.io](https://img.shields.io/crates/v/ccgo.svg)](https://crates.io/crates/ccgo)
[![PyPI version](https://img.shields.io/pypi/v/ccgo.svg)](https://pypi.org/project/ccgo/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/MIT)

## Features

- ๐Ÿš€ Fast cross-platform C++ builds for Android, iOS, macOS, Windows, Linux, and OpenHarmony (OHOS)
- ๐Ÿ—‚๏ธ Kotlin Multiplatform (KMP) support
- ๐Ÿ“ฆ Conan C/C++ package manager integration
- ๐ŸŽ›๏ธ Conditional compilation with Features system (similar to Cargo)
- ๐Ÿงช Integrated testing with GoogleTest
- ๐Ÿ“Š Benchmarking support with Google Benchmark
- ๐Ÿ“š Documentation generation
- ๐Ÿ› ๏ธ Project scaffolding from templates
- โœ… Environment dependency checking
- ๐Ÿงน Smart build artifact cleaning

## Installation

```bash
# Install from PyPI (pre-built binaries)
pip install ccgo

# Or install from crates.io
cargo install ccgo

# Or build from source
git clone https://github.com/zhlinh/ccgo.git
cd ccgo
cargo build --release
# Binary will be at target/release/ccgo
```

## Quick Start

```bash
# Create a new C++ library project
ccgo new my-awesome-lib

# Navigate to the project directory
cd my-awesome-lib/<project_relative_path>

# Build for Android
ccgo build android

# Run tests
ccgo test

# Build documentation
ccgo doc --open
```

## Commands Reference

### 1. Project Creation

#### `ccgo new` - Create New Project

Create a new library project in a new directory.

```bash
ccgo new <project-name> [options]
```

**Options:**

- `--template-url <url>` - Custom template repository URL
- `--data <key>=<value>` - Template variables (repeatable)
- `--defaults` - Use default values for all prompts

**Examples:**

```bash
# Create with interactive prompts
ccgo new my-project

# Create with all defaults
ccgo new my-project --defaults

# Use custom template
ccgo new my-project --template-url https://github.com/user/template.git
ccgo new my-project --template-url /path/to/user/template

# Set template variables
ccgo new my-project --data cpy_project_version=2.0.0
```

#### `ccgo init` - Initialize in Current Directory

Initialize a library project in the current directory.

```bash
ccgo init [options]
```

**Options:**

- `--template-url <url>` - Custom template repository URL
- `--data <key>=<value>` - Template variables (repeatable)
- `--defaults` - Use default values for all prompts
- `--force` - Skip confirmation prompt

**Examples:**

```bash
ccgo init
ccgo init --defaults --force
```

### 2. Build Commands

#### `ccgo build` - Build for Platforms

Build your library for specific platforms.

```bash
ccgo build <target> [options]
```

**Targets:**

- `android` - Build for Android (supports `--arch`)
- `ios` - Build for iOS
- `macos` - Build for macOS
- `windows` - Build for Windows
- `linux` - Build for Linux
- `ohos` - Build for OpenHarmony (supports `--arch`)
- `kmp` - Build Kotlin Multiplatform library
- `conan` - Build Conan C/C++ package
- `include` - Build include headers

**Options:**

- `--arch <architectures>` - Comma-separated architecture list (Android/OHOS only)
  - Android: `armeabi-v7a`, `arm64-v8a`, `x86_64`
  - OHOS: `armeabi-v7a`, `arm64-v8a`, `x86_64`
- `--link-type <type>` - Library link type: `static`, `shared`, or `both` (default: `both`)
- `--toolchain <toolchain>` - Windows toolchain: `auto`, `msvc`, or `mingw` (default: `auto`)
- `--ide-project` - Generate IDE project files
- `--docker` - Build using Docker (cross-platform builds)
- `-F, --features <features>` - Comma-separated list of features to enable
- `--no-default-features` - Disable default features
- `--all-features` - Enable all available features

**Examples:**

```bash
# Build for Android with specific architectures
ccgo build android --arch armeabi-v7a,arm64-v8a

# Build for OHOS with all architectures
ccgo build ohos --arch armeabi-v7a,arm64-v8a,x86_64

# Build for iOS
ccgo build ios

# Build for macOS
ccgo build macos

# Build for Windows
ccgo build windows

# Build for Windows with specific toolchain
ccgo build windows --toolchain msvc
ccgo build windows --toolchain mingw

# Build for Linux
ccgo build linux

# Build static libraries only
ccgo build linux --link-type static

# Build shared libraries only
ccgo build macos --link-type shared

# Build both static and shared libraries (default)
ccgo build ios --link-type both

# Build Kotlin Multiplatform library
ccgo build kmp

# Build Conan C/C++ package
ccgo build conan

# Generate IDE project for Android
ccgo build android --ide-project

# Cross-platform build using Docker
ccgo build linux --docker
ccgo build windows --docker

# Build with specific features enabled
ccgo build android --features networking,advanced

# Build without default features
ccgo build linux --no-default-features --features minimal

# Build with all features enabled
ccgo build ios --all-features
```

### 3. Testing & Benchmarking

#### `ccgo test` - Run Tests

Build and run GoogleTest-based unit tests.

```bash
ccgo test [options]
```

**Options:**

- `--build-only` - Only build tests without running
- `--run-only` - Only run tests (assumes already built)
- `--filter <pattern>` - GoogleTest filter (e.g., 'MyTest*')
- `--ide-project` - Generate IDE project for tests
- `--gtest-args <args>` - Additional GoogleTest arguments

**Examples:**

```bash
# Build and run all tests
ccgo test

# Only build tests
ccgo test --build-only

# Run specific tests
ccgo test --filter "MyTest*"

# Run tests multiple times
ccgo test --gtest-args "--gtest_repeat=3"

# Generate IDE project for debugging tests
ccgo test --ide-project
```

#### `ccgo bench` - Run Benchmarks

Build and run Google Benchmark-based performance benchmarks.

```bash
ccgo bench [options]
```

**Options:**

- `--build-only` - Only build benchmarks without running
- `--run-only` - Only run benchmarks (assumes already built)
- `--filter <pattern>` - Google Benchmark filter (e.g., 'BM_Sort*')
- `--ide-project` - Generate IDE project for benchmarks
- `--benchmark-args <args>` - Additional Google Benchmark arguments
- `--format <format>` - Output format: `console`, `json`, `csv` (default: console)

**Examples:**

```bash
# Build and run all benchmarks
ccgo bench

# Only build benchmarks
ccgo bench --build-only

# Run specific benchmarks
ccgo bench --filter "BM_Sort*"

# Output results as JSON
ccgo bench --format json

# Output results as CSV
ccgo bench --format csv
```

### 4. Documentation

#### `ccgo doc` - Build Documentation

Generate project documentation (typically using Doxygen).

```bash
ccgo doc [options]
```

**Options:**

- `--open` - Open documentation in browser after building
- `--serve` - Start local web server to view documentation
- `--port <port>` - Port for web server (default: 8000)
- `--clean` - Clean build before generating

**Examples:**

```bash
# Build documentation
ccgo doc

# Build and open in browser
ccgo doc --open

# Build and serve on localhost:8000
ccgo doc --serve

# Serve on custom port
ccgo doc --serve --port 3000

# Clean build
ccgo doc --clean
```

### 5. Publishing

#### `ccgo publish` - Publish Libraries

Publish your library to package repositories.

```bash
ccgo publish <target>
```

**Targets:**

- `android` - Publish to Maven repository
- `ohos` - Publish to OHPM repository
- `kmp` - Publish KMP library to Maven (local or remote)

**Examples:**

```bash
# Publish Android library to Maven
ccgo publish android

# Publish OHOS library to OHPM
ccgo publish ohos

# Publish Kotlin Multiplatform library
ccgo publish kmp
```

### 6. Maintenance Commands

#### `ccgo check` - Check Dependencies

Verify that platform-specific development dependencies are installed.

```bash
ccgo check [target] [options]
```

**Targets:**

- `all` - Check all platforms (default)
- `android` - Check Android development environment
- `ios` - Check iOS development environment
- `macos` - Check macOS development environment
- `windows` - Check Windows development environment
- `linux` - Check Linux development environment
- `ohos` - Check OpenHarmony development environment

**Options:**

- `--verbose` - Show detailed information

**Examples:**

```bash
# Check all platforms
ccgo check

# Check Android environment
ccgo check android

# Check with verbose output
ccgo check ios --verbose
```

#### `ccgo clean` - Clean Build Artifacts

Remove build artifacts and caches.

```bash
ccgo clean [target] [options]
```

**Targets:**

- `all` - Clean all platforms (default)
- `android` - Clean Android build caches
- `ios` - Clean iOS build caches
- `macos` - Clean macOS build caches
- `ohos` - Clean OpenHarmony build caches
- `kmp` - Clean Kotlin Multiplatform build caches
- `examples` - Clean examples build caches

**Options:**

- `--native-only` - Clean only `cmake_build/` (native CMake builds)
- `--dry-run` - Show what would be cleaned without deleting
- `-y, --yes` - Skip confirmation prompts

**Examples:**

```bash
# Clean all (with confirmation)
ccgo clean

# Clean only Android
ccgo clean android

# Preview what will be deleted
ccgo clean --dry-run

# Clean all without confirmation
ccgo clean -y

# Clean only native CMake builds
ccgo clean --native-only
```

### 7. Help

#### `ccgo help` - Show Help

Display comprehensive help information.

```bash
ccgo help

# Or get help for specific command
ccgo <command> --help
```

## Environment Variables

### Android

- `ANDROID_HOME` - Android SDK location
- `ANDROID_NDK_HOME` - Android NDK location
- `JAVA_HOME` - Java Development Kit location

### OpenHarmony (OHOS)

- `OHOS_SDK_HOME` or `HOS_SDK_HOME` - OHOS Native SDK location

### iOS/macOS

- Requires Xcode and command-line tools

## Project Structure

Projects created with ccgo follow this structure:

```
my-project/
โ”œโ”€โ”€ CCGO.toml                   # CCGO project config
โ”œโ”€โ”€ CMakeLists.txt              # Root CMake configuration
โ”œโ”€โ”€ src/                        # Source code
โ”œโ”€โ”€ include/                    # Public headers
โ”œโ”€โ”€ docs/                       # docs files
โ”œโ”€โ”€ tests/                      # GoogleTest unit tests
โ”œโ”€โ”€ benches/                    # Benchmark tests
โ”œโ”€โ”€ android/                    # Android-specific files (Gradle)
โ”œโ”€โ”€ ohos/                       # OHOS-specific files (hvigor)
โ”œโ”€โ”€ kmp/                        # Kotlin Multiplatform files (Gradle)
```

## SDK Archive Structure

When you run `ccgo build <target>`, the output is placed in `target/{debug|release}/<platform>/` with a unified archive structure.

### Archive Naming Convention

```
{PROJECT}_{PLATFORM}_SDK-{version}[-{suffix}].zip        # Main SDK archive
{PROJECT}_{PLATFORM}_SDK-{version}[-{suffix}]-SYMBOLS.zip  # Debug symbols archive
```

**Examples:**
- `MYLIB_ANDROID_SDK-1.0.0-release.zip`
- `MYLIB_IOS_SDK-1.0.0-beta.5-dirty.zip`
- `MYLIB_LINUX_SDK-2.1.0-SYMBOLS.zip`

### Unified SDK Archive Structure

All platforms follow the same archive structure:

```
{PROJECT}_{PLATFORM}_SDK-{version}.zip
โ”œโ”€โ”€ lib/{platform}/
โ”‚   โ”œโ”€โ”€ static/                    # Static libraries (.a, .lib)
โ”‚   โ”‚   โ””โ”€โ”€ [{arch}/]              # Architecture subdirectory (if multi-arch)
โ”‚   โ”‚       โ””โ”€โ”€ lib{name}.a
โ”‚   โ””โ”€โ”€ shared/                    # Shared libraries (.so, .dylib, .dll)
โ”‚       โ””โ”€โ”€ [{arch}/]
โ”‚           โ””โ”€โ”€ lib{name}.so
โ”œโ”€โ”€ include/{project}/             # Public header files
โ”‚   โ””โ”€โ”€ **/*.h
โ”œโ”€โ”€ haars/{platform}/              # Platform packages (Android AAR / OHOS HAR)
โ”‚   โ””โ”€โ”€ {PROJECT}_{PLATFORM}_SDK-{version}.aar
โ””โ”€โ”€ meta/{platform}/               # Metadata files
    โ”œโ”€โ”€ build_info.json            # Build information
    โ””โ”€โ”€ archive_info.json          # Archive file listing
```

### Platform-Specific Build Artifacts

#### Android

```bash
ccgo build android [--arch armeabi-v7a,arm64-v8a,x86_64]
```

**Output:** `target/{debug|release}/android/`

| File | Description |
|------|-------------|
| `MYLIB_ANDROID_SDK-{version}.zip` | Main SDK archive |
| `MYLIB_ANDROID_SDK-{version}-SYMBOLS.zip` | Debug symbols (unstripped .so) |
| `MYLIB_ANDROID_SDK-{version}.aar` | Android Archive (standalone) |

**SDK Contents:**
```
โ”œโ”€โ”€ lib/android/static/{arch}/lib{name}.a
โ”œโ”€โ”€ lib/android/shared/{arch}/lib{name}.so
โ”œโ”€โ”€ include/{project}/**/*.h
โ”œโ”€โ”€ haars/android/*.aar
โ””โ”€โ”€ meta/android/build_info.json
```

#### iOS

```bash
ccgo build ios
```

**Output:** `target/{debug|release}/ios/`

| File | Description |
|------|-------------|
| `MYLIB_IOS_SDK-{version}.zip` | Main SDK archive |
| `MYLIB_IOS_SDK-{version}-SYMBOLS.zip` | Debug symbols (dSYM) |

**SDK Contents:**
```
โ”œโ”€โ”€ lib/ios/static/{name}.xcframework/
โ”œโ”€โ”€ lib/ios/shared/{name}.xcframework/
โ”œโ”€โ”€ include/{project}/**/*.h
โ””โ”€โ”€ meta/ios/build_info.json
```

**Architectures:** arm64 (device), arm64-simulator, x86_64-simulator

#### macOS

```bash
ccgo build macos
```

**Output:** `target/{debug|release}/macos/`

| File | Description |
|------|-------------|
| `MYLIB_MACOS_SDK-{version}.zip` | Main SDK archive |
| `MYLIB_MACOS_SDK-{version}-SYMBOLS.zip` | Debug symbols (dSYM) |

**SDK Contents:**
```
โ”œโ”€โ”€ lib/macos/static/{name}.xcframework/
โ”œโ”€โ”€ lib/macos/shared/{name}.xcframework/
โ”œโ”€โ”€ include/{project}/**/*.h
โ””โ”€โ”€ meta/macos/build_info.json
```

**Architectures:** Universal binary (arm64 + x86_64)

#### tvOS

```bash
ccgo build tvos
```

**Output:** `target/{debug|release}/tvos/`

**SDK Contents:**
```
โ”œโ”€โ”€ lib/tvos/static/{name}.xcframework/
โ”œโ”€โ”€ lib/tvos/shared/{name}.xcframework/
โ”œโ”€โ”€ include/{project}/**/*.h
โ””โ”€โ”€ meta/tvos/build_info.json
```

**Architectures:** arm64 (device), arm64-simulator

#### watchOS

```bash
ccgo build watchos
```

**Output:** `target/{debug|release}/watchos/`

**SDK Contents:**
```
โ”œโ”€โ”€ lib/watchos/static/{name}.xcframework/
โ”œโ”€โ”€ lib/watchos/shared/{name}.xcframework/
โ”œโ”€โ”€ include/{project}/**/*.h
โ””โ”€โ”€ meta/watchos/build_info.json
```

**Architectures:** arm64_32, armv7k (device), arm64-simulator

#### Linux

```bash
ccgo build linux
```

**Output:** `target/{debug|release}/linux/`

| File | Description |
|------|-------------|
| `MYLIB_LINUX_SDK-{version}.zip` | Main SDK archive |
| `MYLIB_LINUX_SDK-{version}-SYMBOLS.zip` | Debug symbols (unstripped .so) |

**SDK Contents:**
```
โ”œโ”€โ”€ lib/linux/static/lib{name}.a
โ”œโ”€โ”€ lib/linux/shared/lib{name}.so
โ”œโ”€โ”€ include/{project}/**/*.h
โ””โ”€โ”€ meta/linux/build_info.json
```

**Architecture:** x86_64

#### Windows

```bash
ccgo build windows [--toolchain auto|msvc|mingw]
```

**Output:** `target/{debug|release}/windows/`

| File | Description |
|------|-------------|
| `MYLIB_WINDOWS_SDK-{version}.zip` | Main SDK archive |

**SDK Contents (MinGW):**
```
โ”œโ”€โ”€ lib/windows/static/lib{name}.a
โ”œโ”€โ”€ lib/windows/shared/{name}.dll
โ”œโ”€โ”€ lib/windows/shared/lib{name}.dll.a    # Import library
โ”œโ”€โ”€ include/{project}/**/*.h
โ””โ”€โ”€ meta/windows/build_info.json
```

**SDK Contents (MSVC):**
```
โ”œโ”€โ”€ lib/windows/static/{name}.lib
โ”œโ”€โ”€ lib/windows/shared/{name}.dll
โ”œโ”€โ”€ lib/windows/shared/{name}.lib         # Import library
โ”œโ”€โ”€ include/{project}/**/*.h
โ””โ”€โ”€ meta/windows/build_info.json
```

**Architecture:** x86_64

#### OpenHarmony (OHOS)

```bash
ccgo build ohos [--arch armeabi-v7a,arm64-v8a,x86_64]
```

**Output:** `target/{debug|release}/ohos/`

| File | Description |
|------|-------------|
| `MYLIB_OHOS_SDK-{version}.zip` | Main SDK archive |
| `MYLIB_OHOS_SDK-{version}-SYMBOLS.zip` | Debug symbols (unstripped .so) |
| `MYLIB_OHOS_SDK-{version}.har` | Harmony Archive (standalone) |

**SDK Contents:**
```
โ”œโ”€โ”€ lib/ohos/static/{arch}/lib{name}.a
โ”œโ”€โ”€ lib/ohos/shared/{arch}/lib{name}.so
โ”œโ”€โ”€ include/{project}/**/*.h
โ”œโ”€โ”€ haars/ohos/*.har
โ””โ”€โ”€ meta/ohos/build_info.json
```

#### Conan

```bash
ccgo build conan
```

**Output:** `target/{debug|release}/conan/`

**SDK Contents:**
```
โ”œโ”€โ”€ lib/conan/static/lib{name}.a
โ”œโ”€โ”€ lib/conan/shared/lib{name}.so
โ”œโ”€โ”€ include/{project}/**/*.h
โ””โ”€โ”€ meta/conan/build_info.json
```

### Metadata Files

#### build_info.json

Contains build metadata:

```json
{
  "project": "mylib",
  "platform": "android",
  "version": "1.0.0",
  "link_type": "both",
  "build_time": "2024-01-15T10:30:00.123456",
  "build_host": "Darwin",
  "architectures": ["arm64-v8a", "armeabi-v7a", "x86_64"],
  "git_commit": "abc1234",
  "git_branch": "main"
}
```

#### archive_info.json

Contains file listing with sizes:

```json
{
  "archive_metadata": {
    "version": "1.0",
    "generated_at": "2024-01-15T10:30:00Z",
    "archive_name": "MYLIB_ANDROID_SDK-1.0.0.zip",
    "archive_size": 1234567
  },
  "files": [
    {"path": "lib/android/shared/arm64-v8a/libmylib.so", "size": 123456}
  ],
  "summary": {
    "total_files": 10,
    "total_size": 500000,
    "library_count": 6,
    "platforms": ["android"],
    "architectures": ["arm64-v8a", "armeabi-v7a", "x86_64"]
  }
}
```

### Excluded Files

The following files are automatically excluded from archives:
- `CPPLINT.cfg`
- `.clang-format`
- `.clang-tidy`

## Features System

CCGO supports a features system similar to Cargo's, enabling conditional compilation and optional dependencies. This allows you to:

- Enable/disable parts of your library at build time
- Make dependencies optional and only include them when needed
- Define feature groups that enable multiple sub-features

### Defining Features in CCGO.toml

```toml
[package]
name = "mylib"
version = "1.0.0"

[features]
# Default features enabled when none are specified
default = ["std"]

# Feature definitions
std = []
networking = ["http-client"]        # Enables optional dependency
advanced = ["networking", "async"]  # Enables other features
full = ["networking", "advanced", "logging"]

# Dependency feature syntax
derive = ["serde/derive"]           # Enables feature on dependency

[[dependencies]]
name = "http-client"
version = "^1.0"
optional = true                     # Only included when enabled by a feature

[[dependencies]]
name = "async"
version = "^2.0"
optional = true

[[dependencies]]
name = "serde"
version = "^1.0"
features = ["std"]                  # Features to enable on this dependency
default_features = false            # Disable dependency's default features
```

### Using Features in Builds

```bash
# Build with default features
ccgo build android

# Build with specific features
ccgo build android --features networking,advanced

# Build without default features
ccgo build linux --no-default-features

# Build with specific features, no defaults
ccgo build linux --no-default-features --features minimal

# Build with all available features
ccgo build ios --all-features
```

### CMake Integration

Features are passed to CMake as compile definitions with the `CCGO_FEATURE_` prefix:

```cmake
# In your CMakeLists.txt, check for features:
if(DEFINED CCGO_FEATURE_DEFINITIONS)
    foreach(def ${CCGO_FEATURE_DEFINITIONS})
        target_compile_definitions(${PROJECT_NAME} PRIVATE ${def})
    endforeach()
endif()
```

In your C++ code:

```cpp
#ifdef CCGO_FEATURE_NETWORKING
#include "networking/http_client.h"
#endif

#ifdef CCGO_FEATURE_ADVANCED
void advanced_function() {
    // Advanced implementation
}
#endif
```

### Feature Resolution

Features are resolved transitively:

1. **Default features** are enabled unless `--no-default-features` is specified
2. **Requested features** from `--features` are added
3. **Transitive features** are resolved (e.g., `full` enables `advanced` which enables `networking`)
4. **Optional dependencies** are included only if enabled by an active feature

Example resolution for `--features full`:
```
full โ†’ advanced, networking, logging
advanced โ†’ networking, async
networking โ†’ http-client (optional dep)
```

Result: `full`, `advanced`, `networking`, `logging`, `async`, `http-client` are all enabled.

## Workspaces

CCGO supports workspaces for managing multiple related packages in a single repository. Workspaces provide:

- Unified dependency management across packages
- Shared configuration and settings
- Single-command builds for all packages

### Creating a Workspace

Create a root `CCGO.toml` with a `[workspace]` section:

```toml
# Root CCGO.toml (workspace root)
[workspace]
members = [
    "core",
    "utils",
    "examples/*"      # Glob patterns supported
]
exclude = ["examples/deprecated"]
resolver = "2"        # Dependency resolver version

# Shared dependencies for workspace members
[[workspace.dependencies]]
name = "fmt"
version = "^10.0"
git = "https://github.com/fmtlib/fmt.git"
features = ["std"]

[[workspace.dependencies]]
name = "spdlog"
version = "^1.12"
```

### Workspace Member Configuration

Member packages can inherit dependencies from the workspace:

```toml
# core/CCGO.toml
[package]
name = "my-core"
version = "1.0.0"

[[dependencies]]
name = "fmt"
workspace = true          # Inherit from workspace
features = ["extra"]      # Additional features (merged with workspace)

[[dependencies]]
name = "spdlog"
workspace = true
```

### Workspace Structure

```
my-workspace/
โ”œโ”€โ”€ CCGO.toml              # Workspace root configuration
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ CCGO.toml          # Member package
โ”‚   โ”œโ”€โ”€ CMakeLists.txt
โ”‚   โ””โ”€โ”€ src/
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ CCGO.toml          # Member package
โ”‚   โ”œโ”€โ”€ CMakeLists.txt
โ”‚   โ””โ”€โ”€ src/
โ””โ”€โ”€ examples/
    โ”œโ”€โ”€ demo1/
    โ”‚   โ””โ”€โ”€ CCGO.toml      # Member (matched by glob)
    โ””โ”€โ”€ deprecated/
        โ””โ”€โ”€ CCGO.toml      # Excluded member
```

### Workspace with Root Package

A workspace root can also be a package itself (virtual workspace):

```toml
[workspace]
members = ["crates/*"]

[package]
name = "my-workspace-root"
version = "1.0.0"
```

### Dependency Inheritance

When a member uses `workspace = true`:

1. **Version** is inherited from workspace if not specified locally
2. **Git/Path** sources are inherited from workspace
3. **Features** are merged (workspace features + local features)
4. **default_features** uses workspace setting if not specified locally

```toml
# Workspace defines:
[[workspace.dependencies]]
name = "fmt"
version = "^10.0"
features = ["std"]

# Member uses:
[[dependencies]]
name = "fmt"
workspace = true
features = ["color"]  # Results in: ["std", "color"]
```

### Resolver Versions

- `resolver = "1"` - Legacy resolver (default)
- `resolver = "2"` - New resolver with better feature unification across packages

## Advanced Usage

### Using Custom Templates

You can create projects from custom templates:

```bash
# From GitHub repository
ccgo new my-project --template-url=https://github.com/user/my-template.git

# From local directory
ccgo new my-project --template-url=/path/to/local/template
```

### CI/CD Integration

The generated `build.py` script supports CI/CD workflows with environment variables:

- `CI_IS_RELEASE` - Build as release vs beta
- `CI_BUILD_<PLATFORM>` - Enable/disable platform builds

Example:

```bash
export CI_IS_RELEASE=1
export CI_BUILD_ANDROID=1
export CI_BUILD_IOS=1
python3 build.py
```

### Multi-Architecture Builds

Build for multiple architectures simultaneously:

```bash
# Android: build for 32-bit ARM, 64-bit ARM, and x86_64
ccgo build android --arch armeabi-v7a,arm64-v8a,x86_64

# OHOS: build for all supported architectures
ccgo build ohos --arch armeabi-v7a,arm64-v8a,x86_64
```

## Troubleshooting

### Common Issues

1. **"Command not found" after installation**

   - Ensure `pip` or `cargo` install directory is in your PATH
   - For pip: typically `~/.local/bin` (Linux/macOS) or `%APPDATA%\Python\Scripts` (Windows)
   - For cargo: typically `~/.cargo/bin`

2. **Android build fails**
   
   - Verify `ANDROID_HOME`, `ANDROID_NDK_HOME`, and `JAVA_HOME` are set
   - Run `ccgo check android --verbose` to diagnose

3. **OHOS build fails**
   
   - Verify `OHOS_SDK_HOME` or `HOS_SDK_HOME` is set
   - Run `ccgo check ohos --verbose` to diagnose

4. **iOS/macOS build fails**
   
   - Ensure Xcode and command-line tools are installed
   - Run `xcode-select --install` if needed

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

ccgo is available under the [MIT license](https://opensource.org/license/MIT).
See the LICENSE file for the full license text.

## Links

- [GitHub Repository]https://github.com/zhlinh/ccgo
- [Crates.io Package]https://crates.io/crates/ccgo
- [PyPI Package]https://pypi.org/project/ccgo/
- [Issue Tracker]https://github.com/zhlinh/ccgo/issues