Skip to content

Commit acd62b7

Browse files
authored
Merge pull request #63 from TitanSnow/makefile
add global makefile intending to replace unsafe install script
2 parents 0710193 + c3fc084 commit acd62b7

3 files changed

Lines changed: 91 additions & 16 deletions

File tree

.travis.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ os:
44
- linux
55
- osx
66

7-
branches:
8-
only:
9-
- master
10-
- dev
11-
127
install:
13-
- sudo ./install
8+
- cd ..
9+
- cp -r xmake xmake4build
10+
- cd xmake4build
11+
- make build; sudo make install
1412
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update --verbose; fi
1513
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install dmd --verbose; fi
1614
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install rust --verbose; fi
1715

1816
script:
19-
- xmake create -P ./test
20-
- xmake -P ./test
21-
- ./tests/tests
17+
- cd ../xmake/core
18+
- xmake -v
19+
- sudo cp -v build/xmake /usr/local/share/xmake
20+
- xmake --version
21+
- xmake create test_project
22+
- cd test_project
23+
- xmake

Makefile

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# is debug?
2+
debug :=n
3+
verbose:=
4+
5+
#debug :=y
6+
#verbose:=-v
7+
8+
# prefix
9+
prefix:=$(if $(prefix),$(prefix),$(if $(findstring /usr/local/bin,$(PATH)),/usr/local,/usr))
10+
11+
# platform
12+
PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i linux},linux,))
13+
PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i darwin},macosx,))
14+
PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i cygwin},cygwin,))
15+
PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i mingw},mingw,))
16+
PLAT :=$(if $(PLAT),$(PLAT),$(if ${shell uname | egrep -i windows},windows,))
17+
PLAT :=$(if $(PLAT),$(PLAT),linux)
18+
19+
# architecture
20+
ifeq ($(ARCH),)
21+
22+
ARCH :=$(if $(findstring windows,$(PLAT)),x86,$(ARCH))
23+
ARCH :=$(if $(findstring mingw,$(PLAT)),x86,$(ARCH))
24+
ARCH :=$(if $(findstring macosx,$(PLAT)),x$(shell getconf LONG_BIT),$(ARCH))
25+
ARCH :=$(if $(findstring linux,$(PLAT)),x$(shell getconf LONG_BIT),$(ARCH))
26+
ARCH :=$(if $(findstring x32,$(ARCH)),i386,$(ARCH))
27+
ARCH :=$(if $(findstring x64,$(ARCH)),x86_64,$(ARCH))
28+
ARCH :=$(if $(findstring iphoneos,$(PLAT)),armv7,$(ARCH))
29+
ARCH :=$(if $(findstring android,$(PLAT)),armv7,$(ARCH))
30+
31+
endif
32+
33+
xmake_dir_install :=$(prefix)/share/xmake
34+
xmake_core :=./core/bin/demo.pkg/bin/$(PLAT)/$(ARCH)/demo.b
35+
xmake_core_install :=$(xmake_dir_install)/xmake
36+
xmake_loader :=/tmp/xmake_loader
37+
xmake_loader_install:=$(prefix)/bin/xmake
38+
39+
tip:
40+
@echo '$(MAKE) build; sudo $(MAKE) install'
41+
42+
build:
43+
@echo compiling xmake-core ...
44+
@if [ -f core/.config.mak ]; then rm core/.config.mak; fi
45+
@$(MAKE) -C core --no-print-directory f DEBUG=$(debug)
46+
@$(MAKE) -C core --no-print-directory c
47+
@$(MAKE) -C core --no-print-directory
48+
49+
install:
50+
@echo installing to $(prefix) ...
51+
@echo plat: $(PLAT)
52+
@echo arch: $(ARCH)
53+
@# create the xmake install directory
54+
@$(MAKE) -C core --no-print-directory i
55+
@if [ -d $(xmake_dir_install) ]; then rm -rf $(xmake_dir_install); fi
56+
@if [ ! -d $(xmake_dir_install) ]; then mkdir -p $(xmake_dir_install); fi
57+
@# install the xmake core file
58+
@cp $(xmake_core) $(xmake_core_install)
59+
@chmod 777 $(xmake_core_install)
60+
@# install the xmake directory
61+
@cp -r xmake/* $(xmake_dir_install)
62+
@# make the xmake loader
63+
@echo '#!/bin/bash' > $(xmake_loader)
64+
@echo 'export XMAKE_PROGRAM_DIR=$(xmake_dir_install)' >> $(xmake_loader)
65+
@echo '$(xmake_core_install) $(verbose) "$$@"' >> $(xmake_loader)
66+
@# install the xmake loader
67+
@if [ ! -d $(prefix)/bin ]; then mkdir -p $(prefix)/bin; fi
68+
@mv $(xmake_loader) $(xmake_loader_install)
69+
@chmod 777 $(xmake_loader_install)
70+
@# tip
71+
@$(if $(findstring $(prefix)/bin,$(PATH)),,echo 'please export PATH=$$PATH:$(prefix)/bin')
72+
@# remove xmake.out
73+
@if [ -f '/tmp/xmake.out' ]; then rm /tmp/xmake.out; fi
74+
@# ok
75+
@echo ok!
76+
77+
.PHONY: tip build install

appveyor.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ before_build:
1616
- cmd: dir C:\xmake
1717

1818
build_script:
19-
- cmd: cd tests\console_c
20-
- cmd: if %platform%==Win32 xmake f -m debug
21-
- cmd: if %platform%==Win64 xmake f -m debug -a x64
22-
- cmd: xmake
23-
24-
test_script:
25-
- cmd: xmake --version
19+
- cmd: cd core
20+
- cmd: if %platform%==Win64 xmake f -a x64
21+
- cmd: xmake -v

0 commit comments

Comments
 (0)